Skip to content

Commit 1a3cf6a

Browse files
committed
EDAC/sysfs: move to use bus_get_dev_root()
JIRA: https://issues.redhat.com/browse/RHEL-1023 commit cb4a0be Author: Greg Kroah-Hartman <[email protected]> Date: Mon Mar 13 19:28:43 2023 +0100 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]> Signed-off-by: Mark Langsdorf <[email protected]>
1 parent 822c790 commit 1a3cf6a

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
@@ -230,8 +230,9 @@ static struct kobj_type ktype_device_ctrl = {
230230
*/
231231
int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
232232
{
233+
struct device *dev_root;
233234
struct bus_type *edac_subsys;
234-
int err;
235+
int err = -ENODEV;
235236

236237
edac_dbg(1, "\n");
237238

@@ -249,15 +250,16 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
249250
*/
250251
edac_dev->owner = THIS_MODULE;
251252

252-
if (!try_module_get(edac_dev->owner)) {
253-
err = -ENODEV;
253+
if (!try_module_get(edac_dev->owner))
254254
goto err_out;
255-
}
256255

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

drivers/edac/edac_pci_sysfs.c

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

341342
edac_dbg(0, "\n");
342343

@@ -355,7 +356,6 @@ static int edac_pci_main_kobj_setup(void)
355356
*/
356357
if (!try_module_get(THIS_MODULE)) {
357358
edac_dbg(1, "try_module_get() failed\n");
358-
err = -ENODEV;
359359
goto decrement_count_fail;
360360
}
361361

@@ -367,9 +367,13 @@ static int edac_pci_main_kobj_setup(void)
367367
}
368368

369369
/* Instanstiate the pci object */
370-
err = kobject_init_and_add(edac_pci_top_main_kobj,
371-
&ktype_edac_pci_main_kobj,
372-
&edac_subsys->dev_root->kobj, "pci");
370+
dev_root = bus_get_dev_root(edac_subsys);
371+
if (dev_root) {
372+
err = kobject_init_and_add(edac_pci_top_main_kobj,
373+
&ktype_edac_pci_main_kobj,
374+
&dev_root->kobj, "pci");
375+
put_device(dev_root);
376+
}
373377
if (err) {
374378
edac_dbg(1, "Failed to register '.../edac/pci'\n");
375379
goto kobject_init_and_add_fail;

0 commit comments

Comments
 (0)