Commit cb4a0bec authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6b301ded
...@@ -228,8 +228,9 @@ static struct kobj_type ktype_device_ctrl = { ...@@ -228,8 +228,9 @@ static struct kobj_type ktype_device_ctrl = {
*/ */
int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
{ {
struct device *dev_root;
struct bus_type *edac_subsys; struct bus_type *edac_subsys;
int err; int err = -ENODEV;
edac_dbg(1, "\n"); edac_dbg(1, "\n");
...@@ -247,15 +248,16 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -247,15 +248,16 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
*/ */
edac_dev->owner = THIS_MODULE; edac_dev->owner = THIS_MODULE;
if (!try_module_get(edac_dev->owner)) { if (!try_module_get(edac_dev->owner))
err = -ENODEV;
goto err_out; goto err_out;
}
/* register */ /* register */
dev_root = bus_get_dev_root(edac_subsys);
if (dev_root) {
err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
&edac_subsys->dev_root->kobj, &dev_root->kobj, "%s", edac_dev->name);
"%s", edac_dev->name); put_device(dev_root);
}
if (err) { if (err) {
edac_dbg(1, "Failed to register '.../edac/%s'\n", edac_dbg(1, "Failed to register '.../edac/%s'\n",
edac_dev->name); edac_dev->name);
......
...@@ -337,8 +337,9 @@ static struct kobj_type ktype_edac_pci_main_kobj = { ...@@ -337,8 +337,9 @@ static struct kobj_type ktype_edac_pci_main_kobj = {
*/ */
static int edac_pci_main_kobj_setup(void) static int edac_pci_main_kobj_setup(void)
{ {
int err; int err = -ENODEV;
struct bus_type *edac_subsys; struct bus_type *edac_subsys;
struct device *dev_root;
edac_dbg(0, "\n"); edac_dbg(0, "\n");
...@@ -357,7 +358,6 @@ static int edac_pci_main_kobj_setup(void) ...@@ -357,7 +358,6 @@ static int edac_pci_main_kobj_setup(void)
*/ */
if (!try_module_get(THIS_MODULE)) { if (!try_module_get(THIS_MODULE)) {
edac_dbg(1, "try_module_get() failed\n"); edac_dbg(1, "try_module_get() failed\n");
err = -ENODEV;
goto decrement_count_fail; goto decrement_count_fail;
} }
...@@ -369,9 +369,13 @@ static int edac_pci_main_kobj_setup(void) ...@@ -369,9 +369,13 @@ static int edac_pci_main_kobj_setup(void)
} }
/* Instanstiate the pci object */ /* Instanstiate the pci object */
dev_root = bus_get_dev_root(edac_subsys);
if (dev_root) {
err = kobject_init_and_add(edac_pci_top_main_kobj, err = kobject_init_and_add(edac_pci_top_main_kobj,
&ktype_edac_pci_main_kobj, &ktype_edac_pci_main_kobj,
&edac_subsys->dev_root->kobj, "pci"); &dev_root->kobj, "pci");
put_device(dev_root);
}
if (err) { if (err) {
edac_dbg(1, "Failed to register '.../edac/pci'\n"); edac_dbg(1, "Failed to register '.../edac/pci'\n");
goto kobject_init_and_add_fail; goto kobject_init_and_add_fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment