Skip to content

Commit 74f2c59

Browse files
commododtor
authored andcommitted
Input: adp5589-keys - use devm_gpiochip_add_data() for gpios
This change makes use of the devm_gpiochip_add_data() function. With this the gpiochip_remove() function can be removed, and the adp5589_gpio_remove() function as well. The kpad->export_gpio variable is also redundant now, and has been removed. Signed-off-by: Alexandru Ardelean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 3b95bc5 commit 74f2c59

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

drivers/input/keyboard/adp5589-keys.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ struct adp5589_kpad {
238238
bool support_row5;
239239
#ifdef CONFIG_GPIOLIB
240240
unsigned char gpiomap[ADP5589_MAXGPIO];
241-
bool export_gpio;
242241
struct gpio_chip gc;
243242
struct mutex gpio_lock; /* Protect cached dir, dat_out */
244243
u8 dat_out[3];
@@ -512,8 +511,6 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad)
512511
return 0;
513512
}
514513

515-
kpad->export_gpio = true;
516-
517514
kpad->gc.direction_input = adp5589_gpio_direction_input;
518515
kpad->gc.direction_output = adp5589_gpio_direction_output;
519516
kpad->gc.get = adp5589_gpio_get_value;
@@ -526,11 +523,9 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad)
526523

527524
mutex_init(&kpad->gpio_lock);
528525

529-
error = gpiochip_add_data(&kpad->gc, kpad);
530-
if (error) {
531-
dev_err(dev, "gpiochip_add_data() failed, err: %d\n", error);
526+
error = devm_gpiochip_add_data(dev, &kpad->gc, kpad);
527+
if (error)
532528
return error;
533-
}
534529

535530
for (i = 0; i <= kpad->var->bank(kpad->var->maxgpio); i++) {
536531
kpad->dat_out[i] = adp5589_read(kpad->client, kpad->var->reg(
@@ -541,23 +536,11 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad)
541536

542537
return 0;
543538
}
544-
545-
static void adp5589_gpio_remove(struct adp5589_kpad *kpad)
546-
{
547-
if (!kpad->export_gpio)
548-
return;
549-
550-
gpiochip_remove(&kpad->gc);
551-
}
552539
#else
553540
static inline int adp5589_gpio_add(struct adp5589_kpad *kpad)
554541
{
555542
return 0;
556543
}
557-
558-
static inline void adp5589_gpio_remove(struct adp5589_kpad *kpad)
559-
{
560-
}
561544
#endif
562545

563546
static void adp5589_report_switches(struct adp5589_kpad *kpad,
@@ -1025,7 +1008,6 @@ static int adp5589_remove(struct i2c_client *client)
10251008
struct adp5589_kpad *kpad = i2c_get_clientdata(client);
10261009

10271010
adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0);
1028-
adp5589_gpio_remove(kpad);
10291011

10301012
return 0;
10311013
}

0 commit comments

Comments
 (0)