@@ -94,6 +94,8 @@ static void faux_device_release(struct device *dev)
* into, can be NULL.
* @groups: The set of sysfs attributes that will be created for this
* device when it is registered with the driver core.
+ * @plat_data: The specific data that want to associated with this new device,
+ * can be NULL.Just call 'dev_get_platdata()' to get the data.
*
* Create a new faux device and register it in the driver core properly.
* If present, callbacks in @faux_ops will be called with the device that
@@ -113,7 +115,8 @@ static void faux_device_release(struct device *dev)
struct faux_device *faux_device_create_with_groups(const char *name,
struct device *parent,
const struct faux_device_ops *faux_ops,
- const struct attribute_group **groups)
+ const struct attribute_group **groups,
+ void *plat_data)
{
struct faux_object *faux_obj;
struct faux_device *faux_dev;
@@ -141,6 +144,8 @@ struct faux_device *faux_device_create_with_groups(const char *name,
dev->groups = groups;
dev_set_name(dev, "%s", name);
+ dev->platform_data = plat_data;
+
ret = device_add(dev);
if (ret) {
pr_err("%s: device_add for faux device '%s' failed with %d\n",
@@ -191,7 +196,7 @@ struct faux_device *faux_device_create(const char *name,
struct device *parent,
const struct faux_device_ops *faux_ops)
{
- return faux_device_create_with_groups(name, parent, faux_ops, NULL);
+ return faux_device_create_with_groups(name, parent, faux_ops, NULL, NULL);
}
EXPORT_SYMBOL_GPL(faux_device_create);
@@ -813,7 +813,7 @@ static int __init tlclk_init(void)
goto out3;
}
- tlclk_device = faux_device_create_with_groups("telco_clock", NULL, NULL, tlclk_groups);
+ tlclk_device = faux_device_create_with_groups("telco_clock", NULL, NULL, tlclk_groups, NULL);
if (!tlclk_device) {
ret = -ENODEV;
goto out4;
@@ -864,7 +864,7 @@ ATTRIBUTE_GROUPS(lis3lv02d);
static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
{
- lis3->fdev = faux_device_create_with_groups(DRIVER_NAME, NULL, NULL, lis3lv02d_groups);
+ lis3->fdev = faux_device_create_with_groups(DRIVER_NAME, NULL, NULL, lis3lv02d_groups, NULL);
if (!lis3->fdev)
return -ENODEV;
@@ -53,7 +53,8 @@ struct faux_device *faux_device_create(const char *name,
struct faux_device *faux_device_create_with_groups(const char *name,
struct device *parent,
const struct faux_device_ops *faux_ops,
- const struct attribute_group **groups);
+ const struct attribute_group **groups,
+ void *plat_data);
void faux_device_destroy(struct faux_device *faux_dev);
static inline void *faux_device_get_drvdata(const struct faux_device *faux_dev)