Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: Replace the dangerous to_root_device macro with an inline 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>

authored by

Ferenc Wagner and committed by
Greg Kroah-Hartman
481e2079 6add7cd6

+4 -1
+4 -1
drivers/base/core.c
··· 1320 1320 struct module *owner; 1321 1321 }; 1322 1322 1323 - #define to_root_device(dev) container_of(dev, struct root_device, dev) 1323 + inline struct root_device *to_root_device(struct device *d) 1324 + { 1325 + return container_of(d, struct root_device, dev); 1326 + } 1324 1327 1325 1328 static void root_device_release(struct device *dev) 1326 1329 {