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

EDAC/sysfs: move to use bus_get_dev_root()

Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Robert Richter <rric@kernel.org>
Cc: linux-edac@vger.kernel.org
Link: https://lore.kernel.org/r/20230313182918.1312597-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+18 -12
+9 -7
drivers/edac/edac_device_sysfs.c
··· 228 228 */ 229 229 int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) 230 230 { 231 + struct device *dev_root; 231 232 struct bus_type *edac_subsys; 232 - int err; 233 + int err = -ENODEV; 233 234 234 235 edac_dbg(1, "\n"); 235 236 ··· 248 247 */ 249 248 edac_dev->owner = THIS_MODULE; 250 249 251 - if (!try_module_get(edac_dev->owner)) { 252 - err = -ENODEV; 250 + if (!try_module_get(edac_dev->owner)) 253 251 goto err_out; 254 - } 255 252 256 253 /* register */ 257 - err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, 258 - &edac_subsys->dev_root->kobj, 259 - "%s", edac_dev->name); 254 + dev_root = bus_get_dev_root(edac_subsys); 255 + if (dev_root) { 256 + err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, 257 + &dev_root->kobj, "%s", edac_dev->name); 258 + put_device(dev_root); 259 + } 260 260 if (err) { 261 261 edac_dbg(1, "Failed to register '.../edac/%s'\n", 262 262 edac_dev->name);
+9 -5
drivers/edac/edac_pci_sysfs.c
··· 337 337 */ 338 338 static int edac_pci_main_kobj_setup(void) 339 339 { 340 - int err; 340 + int err = -ENODEV; 341 341 struct bus_type *edac_subsys; 342 + struct device *dev_root; 342 343 343 344 edac_dbg(0, "\n"); 344 345 ··· 358 357 */ 359 358 if (!try_module_get(THIS_MODULE)) { 360 359 edac_dbg(1, "try_module_get() failed\n"); 361 - err = -ENODEV; 362 360 goto decrement_count_fail; 363 361 } 364 362 ··· 369 369 } 370 370 371 371 /* Instanstiate the pci object */ 372 - err = kobject_init_and_add(edac_pci_top_main_kobj, 373 - &ktype_edac_pci_main_kobj, 374 - &edac_subsys->dev_root->kobj, "pci"); 372 + dev_root = bus_get_dev_root(edac_subsys); 373 + if (dev_root) { 374 + err = kobject_init_and_add(edac_pci_top_main_kobj, 375 + &ktype_edac_pci_main_kobj, 376 + &dev_root->kobj, "pci"); 377 + put_device(dev_root); 378 + } 375 379 if (err) { 376 380 edac_dbg(1, "Failed to register '.../edac/pci'\n"); 377 381 goto kobject_init_and_add_fail;