Commit e046de3d authored by Denis Efremov's avatar Denis Efremov Committed by Jonathan Corbet

docs: filesystems: replace to_dev() with kobj_to_dev()

Commit a4232963 ("driver-core: Move kobj_to_dev from genhd.h to device.h")
introduced kobj_to_dev() function.
Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
Link: https://lore.kernel.org/r/20200830144135.6956-1-efremov@linux.comSigned-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent cf92ec60
...@@ -172,14 +172,13 @@ calls the associated methods. ...@@ -172,14 +172,13 @@ calls the associated methods.
To illustrate:: To illustrate::
#define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf) char *buf)
{ {
struct device_attribute *dev_attr = to_dev_attr(attr); struct device_attribute *dev_attr = to_dev_attr(attr);
struct device *dev = to_dev(kobj); struct device *dev = kobj_to_dev(kobj);
ssize_t ret = -EIO; ssize_t ret = -EIO;
if (dev_attr->show) if (dev_attr->show)
......
...@@ -154,14 +154,13 @@ sysfs 会为这个类型调用适当的方法。当一个文件被读写时, ...@@ -154,14 +154,13 @@ sysfs 会为这个类型调用适当的方法。当一个文件被读写时,
示例: 示例:
#define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf) char *buf)
{ {
struct device_attribute *dev_attr = to_dev_attr(attr); struct device_attribute *dev_attr = to_dev_attr(attr);
struct device *dev = to_dev(kobj); struct device *dev = kobj_to_dev(kobj);
ssize_t ret = -EIO; ssize_t ret = -EIO;
if (dev_attr->show) if (dev_attr->show)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment