powerpc: switch to dynamic root devices
Subsystems (2)
cover powerpc: switch to dynamic root devices
This series replaces static root devices with dynamically allocated ones. Included is also a related printk cleanup.
Johan
Johan Hovold (3):
powerpc/ps3: switch to dynamic system bus root device powerpc/pseries: switch to dynamic ibmebus root device powerpc/pseries: clean up ibmebus printks
arch/powerpc/platforms/ps3/system-bus.c | 10 +++---- arch/powerpc/platforms/pseries/ibmebus.c | 34 +++++++++--------------- 2 files changed, 17 insertions(+), 27 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 powerpc/ps3: switch to dynamic system bus root device
Driver core expects devices to be dynamically allocated and will, for example, complain loudly if a device that lacks a release function is ever freed.
Use root_device_register() to allocate and register the root device instead of open coding using a static device.
--- arch/powerpc/platforms/ps3/system-bus.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/powerpc/platforms/ps3/system-bus.c +4 -6
@@ -20,9 +20,7 @@#include "platform.h" -static struct device ps3_system_bus = { - .init_name ="ps3_system" , -}; +static struct device *ps3_system_bus;/* FIXME: need device usage counters! */ static struct {
@@ -486,8 +484,8 @@ static int __init ps3_system_bus_init(void)mutex_init (&usage_hack.mutex); - result =device_register (&ps3_system_bus); -BUG_ON (result); + ps3_system_bus =root_device_register ("ps3_system" ); +BUG_ON (IS_ERR (ps3_system_bus)); result =bus_register (&ps3_system_bus_type);BUG_ON (result);
@@ -744,7 +742,7 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)static unsigned int dev_lpm_count;if (!dev->core.parent) - dev->core.parent = &ps3_system_bus; + dev->core.parent = ps3_system_bus; dev->core.bus = &ps3_system_bus_type; dev->core.release = ps3_system_bus_release_device;
Signature · 1 line
2.53.0
PATCH 2/3 powerpc/pseries: switch to dynamic ibmebus root device
In reply to Johan HovoldDriver core expects devices to be dynamically allocated and will, for example, complain loudly if a device that lacks a release function is ever freed.
Use root_device_register() to allocate and register the root device instead of open coding using a static device.
--- arch/powerpc/platforms/pseries/ibmebus.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
arch/powerpc/platforms/pseries/ibmebus.c +7 -9
@@ -51,9 +51,7 @@#include <asm/ibmebus.h> #include <asm/machdep.h> -static struct device ibmebus_bus_device = {/* fake "parent" device */ - .init_name ="ibmebus" , -}; +static struct device *ibmebus_bus_device;/* fake "parent" device */ const struct bus_type ibmebus_bus_type;
@@ -171,7 +169,7 @@ static int ibmebus_create_device(struct device_node *dn)struct platform_device *dev;int ret; - dev =of_device_alloc (dn,NULL , &ibmebus_bus_device); + dev =of_device_alloc (dn,NULL , ibmebus_bus_device);if (!dev)return -ENOMEM ;
@@ -458,11 +456,11 @@ static int __init ibmebus_bus_init(void)return err; } - err =device_register (&ibmebus_bus_device); -if (err) { -printk (KERN_WARNING "%s: device_register returned %i\n" , + ibmebus_bus_device =root_device_register ("ibmebus" ); +if (IS_ERR (ibmebus_bus_device)) { + err =PTR_ERR (ibmebus_bus_device); +printk (KERN_WARNING "%s: root_device_register returned %i\n" , __func__, err); -put_device (&ibmebus_bus_device);bus_unregister (&ibmebus_bus_type);return err;
@@ -470,7 +468,7 @@ static int __init ibmebus_bus_init(void) err =ibmebus_create_devices (ibmebus_matches);if (err) { -device_unregister (&ibmebus_bus_device); +root_device_unregister (ibmebus_bus_device);bus_unregister (&ibmebus_bus_type);return err; }
Signature · 1 line
2.53.0
PATCH 3/3 powerpc/pseries: clean up ibmebus printks
In reply to Johan HovoldClean up the imbebus printks by switching to pr_warn() and pr_err(), adding a missing newline and making the error messages a bit more uniform.
--- arch/powerpc/platforms/pseries/ibmebus.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
arch/powerpc/platforms/pseries/ibmebus.c +7 -13
@@ -203,8 +203,7 @@ static int ibmebus_create_devices(const struct of_device_id *matches) ret =ibmebus_create_device (child);if (ret) { -printk (KERN_ERR "%s: failed to create device (%i)" , - __func__, ret); +pr_err ("%s: failed to create device: %d\n" , __func__, ret);of_node_put (child);break ; }
@@ -282,8 +281,7 @@ static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t c ibmebus_match_path);if (dev) {put_device (dev); -printk (KERN_WARNING "%s: %s has already been probed\n" , - __func__, path); +pr_warn ("%s: %s has already been probed\n" , __func__, path); rc = -EEXIST ; goto out; }
@@ -292,8 +290,7 @@ static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t c rc =ibmebus_create_device (dn);of_node_put (dn); }else { -printk (KERN_WARNING "%s: no such device node: %s\n" , - __func__, path); +pr_warn ("%s: no such device node: %s\n" , __func__, path); rc = -ENODEV ; }
@@ -322,8 +319,7 @@ static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_tkfree (path);return count; }else { -printk (KERN_WARNING "%s: %s not on the bus\n" , - __func__, path); +pr_warn ("%s: %s not on the bus\n" , __func__, path);kfree (path);return -ENODEV ;
@@ -447,20 +443,18 @@ static int __init ibmebus_bus_init(void) {int err; -printk (KERN_INFO "IBM eBus Device Driver\n" ); +pr_info ("IBM eBus Device Driver\n" ); err =bus_register (&ibmebus_bus_type);if (err) { -printk (KERN_ERR "%s: failed to register IBM eBus.\n" , - __func__); +pr_err ("%s: failed to register IBM eBus\n" , __func__);return err; } ibmebus_bus_device =root_device_register ("ibmebus" );if (IS_ERR (ibmebus_bus_device)) { err =PTR_ERR (ibmebus_bus_device); -printk (KERN_WARNING "%s: root_device_register returned %i\n" , - __func__, err); +pr_err ("%s: failed to register root device: %d\n" , __func__, err);bus_unregister (&ibmebus_bus_type);return err;
Signature · 1 line
2.53.0