Skip to content

Commit

Permalink
docs: filesystems: replace to_dev() with kobj_to_dev()
Browse files Browse the repository at this point in the history
Commit a423296 ("driver-core: Move kobj_to_dev from genhd.h to device.h")
introduced kobj_to_dev() function.

Signed-off-by: Denis Efremov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jonathan Corbet <[email protected]>
  • Loading branch information
evdenis authored and Jonathan Corbet committed Sep 9, 2020
1 parent cf92ec6 commit e046de3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Documentation/filesystems/sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ calls the associated methods.

To illustrate::

#define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)

static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
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;

if (dev_attr->show)
Expand Down
3 changes: 1 addition & 2 deletions Documentation/translations/zh_CN/filesystems/sysfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
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;

if (dev_attr->show)
Expand Down

0 comments on commit e046de3

Please sign in to comment.