Skip to content

Commit cb4a0be

Browse files
committed
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 <[email protected]> Cc: Tony Luck <[email protected]> Cc: James Morse <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Robert Richter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6b301de commit cb4a0be

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

drivers/edac/edac_device_sysfs.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ static struct kobj_type ktype_device_ctrl = {
228228
*/
229229
int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
230230
{
231+
struct device *dev_root;
231232
struct bus_type *edac_subsys;
232-
int err;
233+
int err = -ENODEV;
233234

234235
edac_dbg(1, "\n");
235236

@@ -247,15 +248,16 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
247248
*/
248249
edac_dev->owner = THIS_MODULE;
249250

250-
if (!try_module_get(edac_dev->owner)) {
251-
err = -ENODEV;
251+
if (!try_module_get(edac_dev->owner))
252252
goto err_out;
253-
}
254253

255254
/* register */
256-
err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
257-
&edac_subsys->dev_root->kobj,
258-
"%s", edac_dev->name);
255+
dev_root = bus_get_dev_root(edac_subsys);
256+
if (dev_root) {
257+
err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
258+
&dev_root->kobj, "%s", edac_dev->name);
259+
put_device(dev_root);
260+
}
259261
if (err) {
260262
edac_dbg(1, "Failed to register '.../edac/%s'\n",
261263
edac_dev->name);

drivers/edac/edac_pci_sysfs.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ static struct kobj_type ktype_edac_pci_main_kobj = {
337337
*/
338338
static int edac_pci_main_kobj_setup(void)
339339
{
340-
int err;
340+
int err = -ENODEV;
341341
struct bus_type *edac_subsys;
342+
struct device *dev_root;
342343

343344
edac_dbg(0, "\n");
344345

@@ -357,7 +358,6 @@ static int edac_pci_main_kobj_setup(void)
357358
*/
358359
if (!try_module_get(THIS_MODULE)) {
359360
edac_dbg(1, "try_module_get() failed\n");
360-
err = -ENODEV;
361361
goto decrement_count_fail;
362362
}
363363

@@ -369,9 +369,13 @@ static int edac_pci_main_kobj_setup(void)
369369
}
370370

371371
/* 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+
}
375379
if (err) {
376380
edac_dbg(1, "Failed to register '.../edac/pci'\n");
377381
goto kobject_init_and_add_fail;

0 commit comments

Comments
 (0)