Skip to content

Commit

Permalink
driver core: Replace the dangerous to_root_device macro with an inlin…
Browse files Browse the repository at this point in the history
…e function

The original macro worked only when applied to variables named 'dev'.
While this could have been fixed by simply renaming the macro argument,
a more type-safe replacement by an inline function is preferred.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Ferenc Wagner authored and Greg Kroah-Hartman committed Feb 4, 2011
1 parent 6add7cd commit 481e207
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,10 @@ struct root_device
struct module *owner;
};

#define to_root_device(dev) container_of(dev, struct root_device, dev)
inline struct root_device *to_root_device(struct device *d)
{
return container_of(d, struct root_device, dev);
}

static void root_device_release(struct device *dev)
{
Expand Down

0 comments on commit 481e207

Please sign in to comment.