[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b03b374bc3adad275893e2ad60d4bf5a0ad358e3.1746662386.git.zhouzongmin@kylinos.cn>
Date: Thu, 8 May 2025 17:11:47 +0800
From: Zongmin Zhou <min_halo@....com>
To: gregkh@...uxfoundation.org,
rafael@...nel.org,
dakr@...nel.org,
markgross@...nel.org,
arnd@...db.de,
eric.piel@...mplin-utc.net,
valentina.manea.m@...il.com,
shuah@...nel.org,
i@...ithal.me
Cc: linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zongmin Zhou <zhouzongmin@...inos.cn>
Subject: [PATCH 1/2] driver core:add device's platform_data set for faux device
From: Zongmin Zhou <zhouzongmin@...inos.cn>
Most drivers based on platform bus may have specific data
for the device.And will get this specific data to use
after device added.
So keep the setting for device's platform_data is necessary
for converting platform device to faux device.
Signed-off-by: Zongmin Zhou <zhouzongmin@...inos.cn>
---
drivers/base/faux.c | 9 +++++++--
drivers/char/tlclk.c | 2 +-
drivers/misc/lis3lv02d/lis3lv02d.c | 2 +-
include/linux/device/faux.h | 3 ++-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index 407c1d1aad50..42ec843235cb 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -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);
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index b381ea7e85d2..9334880dec67 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -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;
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 6957091ab6de..e63cb353f425 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -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;
diff --git a/include/linux/device/faux.h b/include/linux/device/faux.h
index 9f43c0e46aa4..36532288a09a 100644
--- a/include/linux/device/faux.h
+++ b/include/linux/device/faux.h
@@ -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)
--
2.25.1
Powered by blists - more mailing lists