maple: switch to dynamic root device
PATCH 1/1 maple: switch to dynamic root device
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided.
Use root_device_register() to allocate and register the root device instead of open coding using a static device.
Note that this also fixes a reference leak in case device_register() fails which may be flagged by static checkers.
--- drivers/sh/maple/maple.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
drivers/sh/maple/maple.c +11 -19
@@ -44,7 +44,7 @@ static LIST_HEAD(maple_sentq);static DEFINE_MUTEX (maple_wlist_lock);static struct maple_driver maple_unsupported_device; -static struct device maple_bus; +static struct device *maple_bus;static int subdevice_map[MAPLE_PORTS ];static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;static unsigned long maple_pnp_time;
@@ -229,7 +229,7 @@ static struct maple_device *maple_alloc_dev(int port, int unit)return NULL ; } mdev->dev.bus = &maple_bus_type; - mdev->dev.parent = &maple_bus; + mdev->dev.parent = maple_bus;init_waitqueue_head (&mdev->maple_wait);return mdev; }
@@ -761,10 +761,6 @@ static int maple_match_bus_driver(struct device *devptr,return 0 ; } -static void maple_bus_release (struct device *dev) -{ -} -static struct maple_driver maple_unsupported_device = { .drv = { .name ="maple_unsupported_device" ,
@@ -779,11 +775,6 @@ static const struct bus_type maple_bus_type = { .match = maple_match_bus_driver, }; -static struct device maple_bus = { - .init_name ="maple" , - .release = maple_bus_release, -}; -static int __init maple_bus_init (void ) {int retval, i;
@@ -791,9 +782,11 @@ static int __init maple_bus_init(void)__raw_writel (0 ,MAPLE_ENABLE ); - retval =device_register (&maple_bus); -if (retval) + maple_bus =root_device_register ("maple" ); +if (IS_ERR (maple_bus)) { + retval =PTR_ERR (maple_bus); goto cleanup; + } retval =bus_register (&maple_bus_type);if (retval)
@@ -806,22 +799,21 @@ static int __init maple_bus_init(void)/* allocate memory for maple bus dma */ retval =maple_get_dma_buffer ();if (retval) { -dev_err (&maple_bus,"failed to allocate DMA buffers\n" ); +dev_err (maple_bus,"failed to allocate DMA buffers\n" ); goto cleanup_basic; }/* set up DMA interrupt handler */ retval =maple_set_dma_interrupt_handler ();if (retval) { -dev_err (&maple_bus,"bus failed to grab maple " -"DMA IRQ\n" ); +dev_err (maple_bus,"bus failed to grab maple DMA IRQ\n" ); goto cleanup_dma; }/* set up VBLANK interrupt handler */ retval =maple_set_vblank_interrupt_handler ();if (retval) { -dev_err (&maple_bus,"bus failed to grab VBLANK IRQ\n" ); +dev_err (maple_bus,"bus failed to grab VBLANK IRQ\n" ); goto cleanup_irq; }
@@ -855,7 +847,7 @@ static int __init maple_bus_init(void) maple_pnp_time = jiffies +HZ ;/* prepare initial queue */ maple_send (); -dev_info (&maple_bus,"bus core now registered\n" ); +dev_info (maple_bus,"bus core now registered\n" );return 0 ;
@@ -878,7 +870,7 @@ static int __init maple_bus_init(void)bus_unregister (&maple_bus_type); cleanup_device: -device_unregister (&maple_bus); +root_device_unregister (maple_bus); cleanup:printk (KERN_ERR "Maple bus registration failed\n" );
Signature · 1 line
2.53.0
Quoted 10 lines · Johan Hovold
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided.
Use
root_device_register()to allocate and register the root device instead of open coding using a static device.Note that this also fixes a reference leak in case
device_register()fails which may be flagged by static checkers.Signed-off-by Johan Hovold <[email protected]>
Hi Johan,
thanks for the patch. Verified on real hardware. LGTM:
John Paul Adrian Glaubitz
maintainerHi Artur,
Quoted 10 lines · Artur Rojek
Quoted 9 lines · Johan Hovold
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided.
Use
root_device_register()to allocate and register the root device instead of open coding using a static device.Note that this also fixes a reference leak in case
device_register()fails which may be flagged by static checkers.
Quoted 7 lines
Quoted 1 line
Signed-off-by Johan Hovold <[email protected]>Hi Johan,
thanks for the patch. Verified on real hardware. LGTM:
Acked-by Artur Rojek <[email protected]>
Maybe add a Tested-by as well.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Artur Rojek
Tested-byQuoted 15 lines · John Paul Adrian Glaubitz
Hi Artur,
Quoted 12 lines · Artur Rojek
Quoted 10 lines · Johan Hovold
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided.
Use
root_device_register()to allocate and register the root device instead of open coding using a static device.Note that this also fixes a reference leak in case
device_register()fails which may be flagged by static checkers.Signed-off-by Johan Hovold <[email protected]>
Quoted 7 lines
Quoted 5 lines
Hi Johan,
thanks for the patch. Verified on real hardware. LGTM:
Acked-by Artur Rojek <[email protected]>Maybe add a Tested-by as well.
Quoted 2 lines
Adrian
Quoted 10 lines · Johan Hovold
Driver core expects devices to be dynamically allocated and will, for example, complain loudly when no release function has been provided.
Use
root_device_register()to allocate and register the root device instead of open coding using a static device.Note that this also fixes a reference leak in case
device_register()fails which may be flagged by static checkers.Signed-off-by Johan Hovold <[email protected]>
Can this one be picked up now?
Johan