diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-07-03 12:49:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-16 21:05:45 -0400 |
commit | b0d1f807f340e91b27aa721f6474956af11571da (patch) | |
tree | 1d5a03c3e63b5bfa01ebdc0bf9b19d6bb0aa4147 /drivers/base | |
parent | a4232963757e62b3b97bbba07cb92c6d448f6f4b (diff) |
driver-core: Use kobj_to_dev instead of re-implementing it
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 17 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 6 |
2 files changed, 10 insertions, 13 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 65849a9aeece..f338037a4f3d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -85,14 +85,13 @@ const char *dev_driver_string(const struct device *dev) | |||
85 | } | 85 | } |
86 | EXPORT_SYMBOL(dev_driver_string); | 86 | EXPORT_SYMBOL(dev_driver_string); |
87 | 87 | ||
88 | #define to_dev(obj) container_of(obj, struct device, kobj) | ||
89 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) | 88 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
90 | 89 | ||
91 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, | 90 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, |
92 | char *buf) | 91 | char *buf) |
93 | { | 92 | { |
94 | struct device_attribute *dev_attr = to_dev_attr(attr); | 93 | struct device_attribute *dev_attr = to_dev_attr(attr); |
95 | struct device *dev = to_dev(kobj); | 94 | struct device *dev = kobj_to_dev(kobj); |
96 | ssize_t ret = -EIO; | 95 | ssize_t ret = -EIO; |
97 | 96 | ||
98 | if (dev_attr->show) | 97 | if (dev_attr->show) |
@@ -108,7 +107,7 @@ static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr, | |||
108 | const char *buf, size_t count) | 107 | const char *buf, size_t count) |
109 | { | 108 | { |
110 | struct device_attribute *dev_attr = to_dev_attr(attr); | 109 | struct device_attribute *dev_attr = to_dev_attr(attr); |
111 | struct device *dev = to_dev(kobj); | 110 | struct device *dev = kobj_to_dev(kobj); |
112 | ssize_t ret = -EIO; | 111 | ssize_t ret = -EIO; |
113 | 112 | ||
114 | if (dev_attr->store) | 113 | if (dev_attr->store) |
@@ -182,7 +181,7 @@ EXPORT_SYMBOL_GPL(device_show_int); | |||
182 | */ | 181 | */ |
183 | static void device_release(struct kobject *kobj) | 182 | static void device_release(struct kobject *kobj) |
184 | { | 183 | { |
185 | struct device *dev = to_dev(kobj); | 184 | struct device *dev = kobj_to_dev(kobj); |
186 | struct device_private *p = dev->p; | 185 | struct device_private *p = dev->p; |
187 | 186 | ||
188 | if (dev->release) | 187 | if (dev->release) |
@@ -200,7 +199,7 @@ static void device_release(struct kobject *kobj) | |||
200 | 199 | ||
201 | static const void *device_namespace(struct kobject *kobj) | 200 | static const void *device_namespace(struct kobject *kobj) |
202 | { | 201 | { |
203 | struct device *dev = to_dev(kobj); | 202 | struct device *dev = kobj_to_dev(kobj); |
204 | const void *ns = NULL; | 203 | const void *ns = NULL; |
205 | 204 | ||
206 | if (dev->class && dev->class->ns_type) | 205 | if (dev->class && dev->class->ns_type) |
@@ -221,7 +220,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj) | |||
221 | struct kobj_type *ktype = get_ktype(kobj); | 220 | struct kobj_type *ktype = get_ktype(kobj); |
222 | 221 | ||
223 | if (ktype == &device_ktype) { | 222 | if (ktype == &device_ktype) { |
224 | struct device *dev = to_dev(kobj); | 223 | struct device *dev = kobj_to_dev(kobj); |
225 | if (dev->bus) | 224 | if (dev->bus) |
226 | return 1; | 225 | return 1; |
227 | if (dev->class) | 226 | if (dev->class) |
@@ -232,7 +231,7 @@ static int dev_uevent_filter(struct kset *kset, struct kobject *kobj) | |||
232 | 231 | ||
233 | static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) | 232 | static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) |
234 | { | 233 | { |
235 | struct device *dev = to_dev(kobj); | 234 | struct device *dev = kobj_to_dev(kobj); |
236 | 235 | ||
237 | if (dev->bus) | 236 | if (dev->bus) |
238 | return dev->bus->name; | 237 | return dev->bus->name; |
@@ -244,7 +243,7 @@ static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) | |||
244 | static int dev_uevent(struct kset *kset, struct kobject *kobj, | 243 | static int dev_uevent(struct kset *kset, struct kobject *kobj, |
245 | struct kobj_uevent_env *env) | 244 | struct kobj_uevent_env *env) |
246 | { | 245 | { |
247 | struct device *dev = to_dev(kobj); | 246 | struct device *dev = kobj_to_dev(kobj); |
248 | int retval = 0; | 247 | int retval = 0; |
249 | 248 | ||
250 | /* add device node properties if present */ | 249 | /* add device node properties if present */ |
@@ -1132,7 +1131,7 @@ int device_register(struct device *dev) | |||
1132 | */ | 1131 | */ |
1133 | struct device *get_device(struct device *dev) | 1132 | struct device *get_device(struct device *dev) |
1134 | { | 1133 | { |
1135 | return dev ? to_dev(kobject_get(&dev->kobj)) : NULL; | 1134 | return dev ? kobj_to_dev(kobject_get(&dev->kobj)) : NULL; |
1136 | } | 1135 | } |
1137 | 1136 | ||
1138 | /** | 1137 | /** |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 5401814c874d..803cfc1597a9 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/sched.h> | 23 | #include <linux/sched.h> |
24 | 24 | ||
25 | #define to_dev(obj) container_of(obj, struct device, kobj) | ||
26 | |||
27 | MODULE_AUTHOR("Manuel Estrada Sainz"); | 25 | MODULE_AUTHOR("Manuel Estrada Sainz"); |
28 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); | 26 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); |
29 | MODULE_LICENSE("GPL"); | 27 | MODULE_LICENSE("GPL"); |
@@ -290,7 +288,7 @@ static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj, | |||
290 | struct bin_attribute *bin_attr, | 288 | struct bin_attribute *bin_attr, |
291 | char *buffer, loff_t offset, size_t count) | 289 | char *buffer, loff_t offset, size_t count) |
292 | { | 290 | { |
293 | struct device *dev = to_dev(kobj); | 291 | struct device *dev = kobj_to_dev(kobj); |
294 | struct firmware_priv *fw_priv = to_firmware_priv(dev); | 292 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
295 | struct firmware *fw; | 293 | struct firmware *fw; |
296 | ssize_t ret_count; | 294 | ssize_t ret_count; |
@@ -384,7 +382,7 @@ static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj, | |||
384 | struct bin_attribute *bin_attr, | 382 | struct bin_attribute *bin_attr, |
385 | char *buffer, loff_t offset, size_t count) | 383 | char *buffer, loff_t offset, size_t count) |
386 | { | 384 | { |
387 | struct device *dev = to_dev(kobj); | 385 | struct device *dev = kobj_to_dev(kobj); |
388 | struct firmware_priv *fw_priv = to_firmware_priv(dev); | 386 | struct firmware_priv *fw_priv = to_firmware_priv(dev); |
389 | struct firmware *fw; | 387 | struct firmware *fw; |
390 | ssize_t retval; | 388 | ssize_t retval; |