gpio: Utilize devm_ functions in driver probe callbacks
Subsystems (6)
cover gpio: Utilize devm_ functions in driver probe callbacks
The devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patchset takes advantage of the resource manager functions and replaces gpiochip_add_data calls and request_irq calls with devm_gpiochip_add_data calls and devm_request_irq calls respectively.
A convenient outcome of these changes is the removal of the respective driver remove callback functions for these drivers; now that clean-up is handled automatically when devices are unbound, custom driver remove functions are no longer necessary for these drivers.
William Breathitt Gray (5):
gpio: 104-dio-48e: Utilize devm_ functions in driver probe callback
gpio: 104-idi-48: Utilize devm_ functions in driver probe callback
gpio: 104-idio-16: Utilize devm_ functions in driver probe callback
gpio: gpio-mm: Utilize devm_ functions in driver probe callback
gpio: ws16c48: Utilize devm_ functions in driver probe callback
drivers/gpio/gpio-104-dio-48e.c | 27 +++++---------------------- drivers/gpio/gpio-104-idi-48.c | 28 +++++----------------------- drivers/gpio/gpio-104-idio-16.c | 27 +++++---------------------- drivers/gpio/gpio-gpio-mm.c | 12 +----------- drivers/gpio/gpio-ws16c48.c | 28 +++++----------------------- 5 files changed, 21 insertions(+), 101 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/5 gpio: 104-dio-48e: Utilize devm_ functions in driver probe callback
The devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call and request_irq call with the devm_gpiochip_add_data call and devm_request_irq call respectively. In addition, the dio48e_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions.
--- drivers/gpio/gpio-104-dio-48e.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/gpio/gpio-104-dio-48e.c +5 -22
@@ -48,7 +48,6 @@ MODULE_PARM_DESC(irq, "ACCES 104-DIO-48E interrupt line numbers");* @control: Control registers state * @lock: synchronization lock to prevent I/O race conditions * @base: base port address of the GPIO device -* @irq: Interrupt line number * @irq_mask: I/O bits affected by interrupts */ struct dio48e_gpio {
@@ -58,7 +57,6 @@ struct dio48e_gpio {unsigned char control[2 ];spinlock_t lock;unsigned base; -unsigned irq;unsigned char irq_mask; };
@@ -329,13 +327,12 @@ static int dio48e_probe(struct device *dev, unsigned int id) dio48egpio->chip.get = dio48e_gpio_get; dio48egpio->chip.set = dio48e_gpio_set; dio48egpio->base = base[id]; - dio48egpio->irq = irq[id];spin_lock_init (&dio48egpio->lock);dev_set_drvdata (dev, dio48egpio); - err =gpiochip_add_data (&dio48egpio->chip, dio48egpio); + err =devm_gpiochip_add_data (dev, &dio48egpio->chip, dio48egpio);if (err) {dev_err (dev,"GPIO registering failed (%d)\n" , err);return err;
@@ -360,30 +357,17 @@ static int dio48e_probe(struct device *dev, unsigned int id) handle_edge_irq, IRQ_TYPE_NONE);if (err) {dev_err (dev,"Could not add irqchip (%d)\n" , err); - goto err_gpiochip_remove; +return err; } - err =request_irq (irq[id], dio48e_irq_handler,0 , name, dio48egpio); + err =devm_request_irq (dev, irq[id], dio48e_irq_handler,0 , name, + dio48egpio);if (err) {dev_err (dev,"IRQ handler registering failed (%d)\n" , err); - goto err_gpiochip_remove; +return err; }return 0 ; - -err_gpiochip_remove: -gpiochip_remove (&dio48egpio->chip); -return err; -} - -static int dio48e_remove (struct device *dev,unsigned int id) -{ -struct dio48e_gpio *const dio48egpio =dev_get_drvdata (dev); - -free_irq (dio48egpio->irq, dio48egpio); -gpiochip_remove (&dio48egpio->chip); - -return 0 ; }static struct isa_driver dio48e_driver = {
@@ -391,7 +375,6 @@ static struct isa_driver dio48e_driver = { .driver = { .name = "104-dio-48e" }, - .remove = dio48e_remove };module_isa_driver (dio48e_driver, num_dio48e);
Signature · 1 line
2.11.0
Re: [PATCH 1/5] gpio: 104-dio-48e: Utilize devm_ functions in driver probe callback
Quoted 9 lines · William Breathitt Gray
The
devm_resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces thegpiochip_add_datacall andrequest_irqcall with thedevm_gpiochip_add_datacall anddevm_request_irqcall respectively. In addition, thedio48e_removefunction has been removed as no longer necessary due to the use of the relevantdevm_resource manager functions.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 2/5 gpio: 104-idi-48: Utilize devm_ functions in driver probe callback
In reply to William Breathitt GrayThe devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call and request_irq call with the devm_gpiochip_add_data call and devm_request_irq call respectively. In addition, the idi_48_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions.
--- drivers/gpio/gpio-104-idi-48.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-)
drivers/gpio/gpio-104-idi-48.c +5 -23
@@ -47,7 +47,6 @@ MODULE_PARM_DESC(irq, "ACCES 104-IDI-48 interrupt line numbers");* @ack_lock: synchronization lock to prevent IRQ handler race conditions * @irq_mask: input bits affected by interrupts * @base: base port address of the GPIO device -* @irq: Interrupt line number * @cos_enb: Change-Of-State IRQ enable boundaries mask */ struct idi_48_gpio {
@@ -56,7 +55,6 @@ struct idi_48_gpio {spinlock_t ack_lock;unsigned char irq_mask[6 ];unsigned base; -unsigned irq;unsigned char cos_enb; };
@@ -244,14 +242,13 @@ static int idi_48_probe(struct device *dev, unsigned int id) idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.get = idi_48_gpio_get; idi48gpio->base = base[id]; - idi48gpio->irq = irq[id];spin_lock_init (&idi48gpio->lock);spin_lock_init (&idi48gpio->ack_lock);dev_set_drvdata (dev, idi48gpio); - err =gpiochip_add_data (&idi48gpio->chip, idi48gpio); + err =devm_gpiochip_add_data (dev, &idi48gpio->chip, idi48gpio);if (err) {dev_err (dev,"GPIO registering failed (%d)\n" , err);return err;
@@ -265,31 +262,17 @@ static int idi_48_probe(struct device *dev, unsigned int id) handle_edge_irq, IRQ_TYPE_NONE);if (err) {dev_err (dev,"Could not add irqchip (%d)\n" , err); - goto err_gpiochip_remove; +return err; } - err =request_irq (irq[id], idi_48_irq_handler,IRQF_SHARED , name, - idi48gpio); + err =devm_request_irq (dev, irq[id], idi_48_irq_handler,IRQF_SHARED , + name, idi48gpio);if (err) {dev_err (dev,"IRQ handler registering failed (%d)\n" , err); - goto err_gpiochip_remove; +return err; }return 0 ; - -err_gpiochip_remove: -gpiochip_remove (&idi48gpio->chip); -return err; -} - -static int idi_48_remove (struct device *dev,unsigned int id) -{ -struct idi_48_gpio *const idi48gpio =dev_get_drvdata (dev); - -free_irq (idi48gpio->irq, idi48gpio); -gpiochip_remove (&idi48gpio->chip); - -return 0 ; }static struct isa_driver idi_48_driver = {
@@ -297,7 +280,6 @@ static struct isa_driver idi_48_driver = { .driver = { .name = "104-idi-48" }, - .remove = idi_48_remove };module_isa_driver (idi_48_driver, num_idi_48);
Signature · 1 line
2.11.0
Re: [PATCH 2/5] gpio: 104-idi-48: Utilize devm_ functions in driver probe callback
Quoted 9 lines · William Breathitt Gray
The
devm_resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces thegpiochip_add_datacall andrequest_irqcall with thedevm_gpiochip_add_datacall anddevm_request_irqcall respectively. In addition, theidi_48_removefunction has been removed as no longer necessary due to the use of the relevantdevm_resource manager functions.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 3/5 gpio: 104-idio-16: Utilize devm_ functions in driver probe callback
In reply to William Breathitt GrayThe devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call and request_irq call with the devm_gpiochip_add_data call and devm_request_irq call respectively. In addition, the idio_16_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions.
--- drivers/gpio/gpio-104-idio-16.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/gpio/gpio-104-idio-16.c +5 -22
@@ -46,7 +46,6 @@ MODULE_PARM_DESC(irq, "ACCES 104-IDIO-16 interrupt line numbers");* @lock: synchronization lock to prevent I/O race conditions * @irq_mask: I/O bits affected by interrupts * @base: base port address of the GPIO device -* @irq: Interrupt line number * @out_state: output bits state */ struct idio_16_gpio {
@@ -54,7 +53,6 @@ struct idio_16_gpio {spinlock_t lock;unsigned long irq_mask;unsigned base; -unsigned irq;unsigned out_state; };
@@ -220,14 +218,13 @@ static int idio_16_probe(struct device *dev, unsigned int id) idio16gpio->chip.get = idio_16_gpio_get; idio16gpio->chip.set = idio_16_gpio_set; idio16gpio->base = base[id]; - idio16gpio->irq = irq[id]; idio16gpio->out_state =0xFFFF ;spin_lock_init (&idio16gpio->lock);dev_set_drvdata (dev, idio16gpio); - err =gpiochip_add_data (&idio16gpio->chip, idio16gpio); + err =devm_gpiochip_add_data (dev, &idio16gpio->chip, idio16gpio);if (err) {dev_err (dev,"GPIO registering failed (%d)\n" , err);return err;
@@ -241,30 +238,17 @@ static int idio_16_probe(struct device *dev, unsigned int id) handle_edge_irq, IRQ_TYPE_NONE);if (err) {dev_err (dev,"Could not add irqchip (%d)\n" , err); - goto err_gpiochip_remove; +return err; } - err =request_irq (irq[id], idio_16_irq_handler,0 , name, idio16gpio); + err =devm_request_irq (dev, irq[id], idio_16_irq_handler,0 , name, + idio16gpio);if (err) {dev_err (dev,"IRQ handler registering failed (%d)\n" , err); - goto err_gpiochip_remove; +return err; }return 0 ; - -err_gpiochip_remove: -gpiochip_remove (&idio16gpio->chip); -return err; -} - -static int idio_16_remove (struct device *dev,unsigned int id) -{ -struct idio_16_gpio *const idio16gpio =dev_get_drvdata (dev); - -free_irq (idio16gpio->irq, idio16gpio); -gpiochip_remove (&idio16gpio->chip); - -return 0 ; }static struct isa_driver idio_16_driver = {
@@ -272,7 +256,6 @@ static struct isa_driver idio_16_driver = { .driver = { .name = "104-idio-16" }, - .remove = idio_16_remove };module_isa_driver (idio_16_driver, num_idio_16);
Signature · 1 line
2.11.0
Re: [PATCH 3/5] gpio: 104-idio-16: Utilize devm_ functions in driver probe callback
Quoted 9 lines · William Breathitt Gray
The
devm_resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces thegpiochip_add_datacall andrequest_irqcall with thedevm_gpiochip_add_datacall anddevm_request_irqcall respectively. In addition, theidio_16_removefunction has been removed as no longer necessary due to the use of the relevantdevm_resource manager functions.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 4/5 gpio: gpio-mm: Utilize devm_ functions in driver probe callback
In reply to William Breathitt GrayThe devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call with the devm_gpiochip_add_data call. In addition, the gpiomm_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions.
--- drivers/gpio/gpio-gpio-mm.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpio/gpio-gpio-mm.c +1 -11
@@ -224,7 +224,7 @@ static int gpiomm_probe(struct device *dev, unsigned int id)dev_set_drvdata (dev, gpiommgpio); - err =gpiochip_add_data (&gpiommgpio->chip, gpiommgpio); + err =devm_gpiochip_add_data (dev, &gpiommgpio->chip, gpiommgpio);if (err) {dev_err (dev,"GPIO registering failed (%d)\n" , err);return err;
@@ -243,21 +243,11 @@ static int gpiomm_probe(struct device *dev, unsigned int id)return 0 ; } -static int gpiomm_remove (struct device *dev,unsigned int id) -{ -struct gpiomm_gpio *const gpiommgpio =dev_get_drvdata (dev); - -gpiochip_remove (&gpiommgpio->chip); - -return 0 ; -} -static struct isa_driver gpiomm_driver = { .probe = gpiomm_probe, .driver = { .name ="gpio-mm" }, - .remove = gpiomm_remove };module_isa_driver (gpiomm_driver, num_gpiomm);
Signature · 1 line
2.11.0
Re: [PATCH 4/5] gpio: gpio-mm: Utilize devm_ functions in driver probe callback
Quoted 8 lines · William Breathitt Gray
The
devm_resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces thegpiochip_add_datacall with thedevm_gpiochip_add_datacall. In addition, thegpiomm_removefunction has been removed as no longer necessary due to the use of the relevantdevm_resource manager functions.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 5/5 gpio: ws16c48: Utilize devm_ functions in driver probe callback
In reply to William Breathitt GrayThe devm_ resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces the gpiochip_add_data call and request_irq call with the devm_gpiochip_add_data call and devm_request_irq call respectively. In addition, the ws16c48_remove function has been removed as no longer necessary due to the use of the relevant devm_ resource manager functions.
--- drivers/gpio/gpio-ws16c48.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-)
drivers/gpio/gpio-ws16c48.c +5 -23
@@ -46,7 +46,6 @@ MODULE_PARM_DESC(irq, "WinSystems WS16C48 interrupt line numbers");* @irq_mask: I/O bits affected by interrupts * @flow_mask: IRQ flow type mask for the respective I/O bits * @base: base port address of the GPIO device -* @irq: Interrupt line number */ struct ws16c48_gpio {struct gpio_chip chip;
@@ -56,7 +55,6 @@ struct ws16c48_gpio {unsigned long irq_mask;unsigned long flow_mask;unsigned base; -unsigned irq; };static int ws16c48_gpio_get_direction (struct gpio_chip *chip,unsigned offset)
@@ -330,13 +328,12 @@ static int ws16c48_probe(struct device *dev, unsigned int id) ws16c48gpio->chip.get = ws16c48_gpio_get; ws16c48gpio->chip.set = ws16c48_gpio_set; ws16c48gpio->base = base[id]; - ws16c48gpio->irq = irq[id];spin_lock_init (&ws16c48gpio->lock);dev_set_drvdata (dev, ws16c48gpio); - err =gpiochip_add_data (&ws16c48gpio->chip, ws16c48gpio); + err =devm_gpiochip_add_data (dev, &ws16c48gpio->chip, ws16c48gpio);if (err) {dev_err (dev,"GPIO registering failed (%d)\n" , err);return err;
@@ -353,31 +350,17 @@ static int ws16c48_probe(struct device *dev, unsigned int id) handle_edge_irq, IRQ_TYPE_NONE);if (err) {dev_err (dev,"Could not add irqchip (%d)\n" , err); - goto err_gpiochip_remove; +return err; } - err =request_irq (irq[id], ws16c48_irq_handler,IRQF_SHARED , name, - ws16c48gpio); + err =devm_request_irq (dev, irq[id], ws16c48_irq_handler,IRQF_SHARED , + name, ws16c48gpio);if (err) {dev_err (dev,"IRQ handler registering failed (%d)\n" , err); - goto err_gpiochip_remove; +return err; }return 0 ; - -err_gpiochip_remove: -gpiochip_remove (&ws16c48gpio->chip); -return err; -} - -static int ws16c48_remove (struct device *dev,unsigned int id) -{ -struct ws16c48_gpio *const ws16c48gpio =dev_get_drvdata (dev); - -free_irq (ws16c48gpio->irq, ws16c48gpio); -gpiochip_remove (&ws16c48gpio->chip); - -return 0 ; }static struct isa_driver ws16c48_driver = {
@@ -385,7 +368,6 @@ static struct isa_driver ws16c48_driver = { .driver = { .name = "ws16c48" }, - .remove = ws16c48_remove };module_isa_driver (ws16c48_driver, num_ws16c48);
Signature · 1 line
2.11.0
Re: [PATCH 5/5] gpio: ws16c48: Utilize devm_ functions in driver probe callback
Quoted 9 lines · William Breathitt Gray
The
devm_resource manager functions allow memory to be automatically released when a device is unbound. This patch takes advantage of the resource manager functions and replaces thegpiochip_add_datacall andrequest_irqcall with thedevm_gpiochip_add_datacall anddevm_request_irqcall respectively. In addition, thews16c48_removefunction has been removed as no longer necessary due to the use of the relevantdevm_resource manager functions.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij