* [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API @ 2014-04-26 5:53 Alexander Shiyan 2014-04-26 5:53 ` [PATCH RESEND 2/2] input: gpio_keys: " Alexander Shiyan 2014-04-29 3:26 ` [PATCH RESEND 1/2] input: gpio_keys_polled: " Dmitry Torokhov 0 siblings, 2 replies; 14+ messages in thread From: Alexander Shiyan @ 2014-04-26 5:53 UTC (permalink / raw) To: linux-input; +Cc: Dmitry Torokhov, Alexander Shiyan Replace existing resource handling in the driver with managed device resource, this ensures more consistent error values and simplifies error paths. kzalloc -> devm_kzalloc gpio_request_one -> devm_gpio_request_one Signed-off-by: Alexander Shiyan <shc_work@mail.ru> --- drivers/input/keyboard/gpio_keys_polled.c | 87 ++++++++----------------------- 1 file changed, 23 insertions(+), 64 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index e571e19..04db0a5 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -108,9 +108,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct struct device_node *node, *pp; struct gpio_keys_platform_data *pdata; struct gpio_keys_button *button; - int error; - int nbuttons; - int i; + int i, nbuttons; node = dev->of_node; if (!node) @@ -120,12 +118,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct if (nbuttons == 0) return NULL; - pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), - GFP_KERNEL); - if (!pdata) { - error = -ENOMEM; - goto err_out; - } + pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button), + GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); pdata->buttons = (struct gpio_keys_button *)(pdata + 1); pdata->nbuttons = nbuttons; @@ -146,12 +142,11 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct gpio = of_get_gpio_flags(pp, 0, &flags); if (gpio < 0) { - error = gpio; - if (error != -EPROBE_DEFER) + if (gpio != -EPROBE_DEFER) dev_err(dev, "Failed to get gpio flags, error: %d\n", - error); - goto err_free_pdata; + gpio); + return ERR_PTR(gpio); } button = &pdata->buttons[i++]; @@ -162,8 +157,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct if (of_property_read_u32(pp, "linux,code", &button->code)) { dev_err(dev, "Button without keycode: 0x%x\n", button->gpio); - error = -EINVAL; - goto err_free_pdata; + return ERR_PTR(-EINVAL); } button->desc = of_get_property(pp, "label", NULL); @@ -178,17 +172,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct button->debounce_interval = 5; } - if (pdata->nbuttons == 0) { - error = -EINVAL; - goto err_free_pdata; - } + if (!pdata->nbuttons) + return ERR_PTR(-EINVAL); return pdata; - -err_free_pdata: - kfree(pdata); -err_out: - return ERR_PTR(error); } static struct of_device_id gpio_keys_polled_of_match[] = { @@ -228,24 +215,21 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (!pdata->poll_interval) { dev_err(dev, "missing poll_interval value\n"); - error = -EINVAL; - goto err_free_pdata; + return -EINVAL; } - bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + - pdata->nbuttons * sizeof(struct gpio_keys_button_data), - GFP_KERNEL); + bdev = devm_kzalloc(&pdev->dev, sizeof(struct gpio_keys_polled_dev) + + pdata->nbuttons * sizeof(struct gpio_keys_button_data), + GFP_KERNEL); if (!bdev) { dev_err(dev, "no memory for private data\n"); - error = -ENOMEM; - goto err_free_pdata; + return -ENOMEM; } poll_dev = input_allocate_polled_device(); if (!poll_dev) { dev_err(dev, "no memory for polled device\n"); - error = -ENOMEM; - goto err_free_bdev; + return -ENOMEM; } poll_dev->private = bdev; @@ -278,15 +262,15 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (button->wakeup) { dev_err(dev, DRV_NAME " does not support wakeup\n"); error = -EINVAL; - goto err_free_gpio; + goto err_out; } - error = gpio_request_one(gpio, GPIOF_IN, - button->desc ?: DRV_NAME); + error = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_IN, + button->desc ? : DRV_NAME); if (error) { dev_err(dev, "unable to claim gpio %u, err=%d\n", gpio, error); - goto err_free_gpio; + goto err_out; } bdata->can_sleep = gpio_cansleep(gpio); @@ -306,7 +290,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (error) { dev_err(dev, "unable to register polled device, err=%d\n", error); - goto err_free_gpio; + goto err_out; } /* report initial state of the buttons */ @@ -316,45 +300,20 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) return 0; -err_free_gpio: - while (--i >= 0) - gpio_free(pdata->buttons[i].gpio); - +err_out: input_free_polled_device(poll_dev); -err_free_bdev: - kfree(bdev); - -err_free_pdata: - /* If we have no platform_data, we allocated pdata dynamically. */ - if (!dev_get_platdata(&pdev->dev)) - kfree(pdata); - return error; } static int gpio_keys_polled_remove(struct platform_device *pdev) { struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); - const struct gpio_keys_platform_data *pdata = bdev->pdata; - int i; input_unregister_polled_device(bdev->poll_dev); - for (i = 0; i < pdata->nbuttons; i++) - gpio_free(pdata->buttons[i].gpio); - input_free_polled_device(bdev->poll_dev); - /* - * If we had no platform_data, we allocated pdata dynamically and - * must free it here. - */ - if (!dev_get_platdata(&pdev->dev)) - kfree(pdata); - - kfree(bdev); - return 0; } -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RESEND 2/2] input: gpio_keys: Convert to devm-* API 2014-04-26 5:53 [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API Alexander Shiyan @ 2014-04-26 5:53 ` Alexander Shiyan 2014-04-29 2:30 ` Dmitry Torokhov 2014-04-29 3:26 ` [PATCH RESEND 1/2] input: gpio_keys_polled: " Dmitry Torokhov 1 sibling, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-04-26 5:53 UTC (permalink / raw) To: linux-input; +Cc: Dmitry Torokhov, Alexander Shiyan Replace existing resource handling in the driver with managed device resource, this ensures more consistent error values and simplifies error paths. kzalloc -> devm_kzalloc gpio_request_one -> devm_gpio_request_one input_allocate_device -> devm_input_allocate_device Signed-off-by: Alexander Shiyan <shc_work@mail.ru> --- drivers/input/keyboard/gpio_keys.c | 96 +++++++++++--------------------------- 1 file changed, 28 insertions(+), 68 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 2db1324..c4bc6e4 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -433,7 +433,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, struct device *dev = &pdev->dev; irq_handler_t isr; unsigned long irqflags; - int irq, error; + int error; bdata->input = input; bdata->button = button; @@ -441,7 +441,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, if (gpio_is_valid(button->gpio)) { - error = gpio_request_one(button->gpio, GPIOF_IN, desc); + error = devm_gpio_request_one(&pdev->dev, button->gpio, + GPIOF_IN, desc); if (error < 0) { dev_err(dev, "Failed to request GPIO %d, error %d\n", button->gpio, error); @@ -457,15 +458,13 @@ static int gpio_keys_setup_key(struct platform_device *pdev, button->debounce_interval; } - irq = gpio_to_irq(button->gpio); - if (irq < 0) { - error = irq; + bdata->irq = gpio_to_irq(button->gpio); + if (bdata->irq < 0) { dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n", - button->gpio, error); - goto fail; + button->gpio, bdata->irq); + return bdata->irq; } - bdata->irq = irq; INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); setup_timer(&bdata->timer, @@ -507,16 +506,10 @@ static int gpio_keys_setup_key(struct platform_device *pdev, if (error < 0) { dev_err(dev, "Unable to claim irq %d; error %d\n", bdata->irq, error); - goto fail; + return error; } return 0; - -fail: - if (gpio_is_valid(button->gpio)) - gpio_free(button->gpio); - - return error; } static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata) @@ -573,28 +566,20 @@ gpio_keys_get_devtree_pdata(struct device *dev) struct device_node *node, *pp; struct gpio_keys_platform_data *pdata; struct gpio_keys_button *button; - int error; - int nbuttons; - int i; + int i, nbuttons; node = dev->of_node; - if (!node) { - error = -ENODEV; - goto err_out; - } + if (!node) + return ERR_PTR(-ENODEV); nbuttons = of_get_child_count(node); - if (nbuttons == 0) { - error = -ENODEV; - goto err_out; - } + if (nbuttons == 0) + return ERR_PTR(-ENODEV); - pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), - GFP_KERNEL); - if (!pdata) { - error = -ENOMEM; - goto err_out; - } + pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button), + GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); pdata->buttons = (struct gpio_keys_button *)(pdata + 1); pdata->nbuttons = nbuttons; @@ -614,12 +599,11 @@ gpio_keys_get_devtree_pdata(struct device *dev) gpio = of_get_gpio_flags(pp, 0, &flags); if (gpio < 0) { - error = gpio; - if (error != -EPROBE_DEFER) + if (gpio != -EPROBE_DEFER) dev_err(dev, "Failed to get gpio flags, error: %d\n", - error); - goto err_free_pdata; + gpio); + return ERR_PTR(gpio); } button = &pdata->buttons[i++]; @@ -630,8 +614,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) if (of_property_read_u32(pp, "linux,code", &button->code)) { dev_err(dev, "Button without keycode: 0x%x\n", button->gpio); - error = -EINVAL; - goto err_free_pdata; + return ERR_PTR(-EINVAL); } button->desc = of_get_property(pp, "label", NULL); @@ -646,17 +629,10 @@ gpio_keys_get_devtree_pdata(struct device *dev) button->debounce_interval = 5; } - if (pdata->nbuttons == 0) { - error = -EINVAL; - goto err_free_pdata; - } + if (!pdata->nbuttons) + return ERR_PTR(-EINVAL); return pdata; - -err_free_pdata: - kfree(pdata); -err_out: - return ERR_PTR(error); } static struct of_device_id gpio_keys_of_match[] = { @@ -681,8 +657,6 @@ static void gpio_remove_key(struct gpio_button_data *bdata) if (bdata->timer_debounce) del_timer_sync(&bdata->timer); cancel_work_sync(&bdata->work); - if (gpio_is_valid(bdata->button->gpio)) - gpio_free(bdata->button->gpio); } static int gpio_keys_probe(struct platform_device *pdev) @@ -700,14 +674,13 @@ static int gpio_keys_probe(struct platform_device *pdev) return PTR_ERR(pdata); } - ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + - pdata->nbuttons * sizeof(struct gpio_button_data), - GFP_KERNEL); - input = input_allocate_device(); + ddata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_keys_drvdata) + + pdata->nbuttons * sizeof(struct gpio_button_data), + GFP_KERNEL); + input = devm_input_allocate_device(&pdev->dev); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); - error = -ENOMEM; - goto fail1; + return -ENOMEM; } ddata->pdata = pdata; @@ -768,13 +741,6 @@ static int gpio_keys_probe(struct platform_device *pdev) while (--i >= 0) gpio_remove_key(&ddata->data[i]); - fail1: - input_free_device(input); - kfree(ddata); - /* If we have no platform data, we allocated pdata dynamically. */ - if (!dev_get_platdata(&pdev->dev)) - kfree(pdata); - return error; } @@ -793,12 +759,6 @@ static int gpio_keys_remove(struct platform_device *pdev) input_unregister_device(input); - /* If we have no platform data, we allocated pdata dynamically. */ - if (!dev_get_platdata(&pdev->dev)) - kfree(ddata->pdata); - - kfree(ddata); - return 0; } -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 2/2] input: gpio_keys: Convert to devm-* API 2014-04-26 5:53 ` [PATCH RESEND 2/2] input: gpio_keys: " Alexander Shiyan @ 2014-04-29 2:30 ` Dmitry Torokhov 0 siblings, 0 replies; 14+ messages in thread From: Dmitry Torokhov @ 2014-04-29 2:30 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input Hi Alexander, On Sat, Apr 26, 2014 at 09:53:14AM +0400, Alexander Shiyan wrote: > Replace existing resource handling in the driver with managed > device resource, this ensures more consistent error values and > simplifies error paths. > kzalloc -> devm_kzalloc > gpio_request_one -> devm_gpio_request_one > input_allocate_device -> devm_input_allocate_device > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru> > --- > drivers/input/keyboard/gpio_keys.c | 96 +++++++++++--------------------------- > 1 file changed, 28 insertions(+), 68 deletions(-) > > diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c > index 2db1324..c4bc6e4 100644 > --- a/drivers/input/keyboard/gpio_keys.c > +++ b/drivers/input/keyboard/gpio_keys.c > @@ -433,7 +433,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, > struct device *dev = &pdev->dev; > irq_handler_t isr; > unsigned long irqflags; > - int irq, error; > + int error; > > bdata->input = input; > bdata->button = button; > @@ -441,7 +441,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, > > if (gpio_is_valid(button->gpio)) { > > - error = gpio_request_one(button->gpio, GPIOF_IN, desc); > + error = devm_gpio_request_one(&pdev->dev, button->gpio, > + GPIOF_IN, desc); > if (error < 0) { > dev_err(dev, "Failed to request GPIO %d, error %d\n", > button->gpio, error); > @@ -457,15 +458,13 @@ static int gpio_keys_setup_key(struct platform_device *pdev, > button->debounce_interval; > } > > - irq = gpio_to_irq(button->gpio); > - if (irq < 0) { > - error = irq; > + bdata->irq = gpio_to_irq(button->gpio); > + if (bdata->irq < 0) { This is wrong, bdata->irq is unsigned. Also I already applied the earlier version of the patch dealing with non-gpio resources. How about the patch below? Thanks. -- Dmitry Input: gpio_keys - more conversions to devm-* API From: Alexander Shiyan <shc_work@mail.ru> Replace existing gpio resource handling in the driver with managed resources, this ensures more consistent error values and simplifies error paths. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/input/keyboard/gpio_keys.c | 69 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 52dc872..8d7d748 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -424,6 +424,16 @@ out: return IRQ_HANDLED; } +static void gpio_keys_quiesce_key(void *data) +{ + struct gpio_button_data *bdata = data; + + if (bdata->timer_debounce) + del_timer_sync(&bdata->timer); + + cancel_work_sync(&bdata->work); +} + static int gpio_keys_setup_key(struct platform_device *pdev, struct input_dev *input, struct gpio_button_data *bdata, @@ -433,7 +443,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, struct device *dev = &pdev->dev; irq_handler_t isr; unsigned long irqflags; - int irq, error; + int irq; + int error; bdata->input = input; bdata->button = button; @@ -441,7 +452,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, if (gpio_is_valid(button->gpio)) { - error = gpio_request_one(button->gpio, GPIOF_IN, desc); + error = devm_gpio_request_one(&pdev->dev, button->gpio, + GPIOF_IN, desc); if (error < 0) { dev_err(dev, "Failed to request GPIO %d, error %d\n", button->gpio, error); @@ -463,7 +475,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n", button->gpio, error); - goto fail; + return error; } bdata->irq = irq; @@ -497,26 +509,33 @@ static int gpio_keys_setup_key(struct platform_device *pdev, input_set_capability(input, button->type ?: EV_KEY, button->code); /* + * Install custom action to cancel debounce timer and + * workqueue item. + */ + error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); + if (error) { + dev_err(&pdev->dev, + "failed to register quiesce action, error: %d\n", + error); + return error; + } + + /* * If platform has specified that the button can be disabled, * we don't want it to share the interrupt line. */ if (!button->can_disable) irqflags |= IRQF_SHARED; - error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata); + error = devm_request_any_context_irq(&pdev->dev, bdata->irq, + isr, irqflags, desc, bdata); if (error < 0) { dev_err(dev, "Unable to claim irq %d; error %d\n", bdata->irq, error); - goto fail; + return error; } return 0; - -fail: - if (gpio_is_valid(button->gpio)) - gpio_free(button->gpio); - - return error; } static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata) @@ -662,16 +681,6 @@ gpio_keys_get_devtree_pdata(struct device *dev) #endif -static void gpio_remove_key(struct gpio_button_data *bdata) -{ - free_irq(bdata->irq, bdata); - if (bdata->timer_debounce) - del_timer_sync(&bdata->timer); - cancel_work_sync(&bdata->work); - if (gpio_is_valid(bdata->button->gpio)) - gpio_free(bdata->button->gpio); -} - static int gpio_keys_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -730,7 +739,7 @@ static int gpio_keys_probe(struct platform_device *pdev) error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) - goto fail2; + return error; if (button->wakeup) wakeup = 1; @@ -740,41 +749,31 @@ static int gpio_keys_probe(struct platform_device *pdev) if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); - goto fail2; + return error; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); - goto fail3; + goto err_remove_group; } device_init_wakeup(&pdev->dev, wakeup); return 0; - fail3: +err_remove_group: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); - fail2: - while (--i >= 0) - gpio_remove_key(&ddata->data[i]); - return error; } static int gpio_keys_remove(struct platform_device *pdev) { - struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); - int i; - sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); device_init_wakeup(&pdev->dev, 0); - for (i = 0; i < ddata->pdata->nbuttons; i++) - gpio_remove_key(&ddata->data[i]); - return 0; } ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-26 5:53 [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API Alexander Shiyan 2014-04-26 5:53 ` [PATCH RESEND 2/2] input: gpio_keys: " Alexander Shiyan @ 2014-04-29 3:26 ` Dmitry Torokhov 2014-04-29 4:43 ` Alexander Shiyan 1 sibling, 1 reply; 14+ messages in thread From: Dmitry Torokhov @ 2014-04-29 3:26 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input Hi Alexander, On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > Replace existing resource handling in the driver with managed > device resource, this ensures more consistent error values and > simplifies error paths. > kzalloc -> devm_kzalloc > gpio_request_one -> devm_gpio_request_one > If we are doing the conversion can we go all the Alexanderway (needs the other 2 patches I just posted and CCed you)? Thanks. -- Dmitry Input: gpio_keys_polled - convert to devm-* API From: Alexander Shiyan <shc_work@mail.ru> Replace existing resource handling in the driver with managed device resources, this ensures more consistent error values and simplifies error handling paths: kzalloc -> devm_kzalloc gpio_request_one -> devm_gpio_request_one input_allocate_polled_device -> devm_input_allocate_polled_device Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/input/keyboard/gpio_keys_polled.c | 98 ++++++----------------------- 1 file changed, 21 insertions(+), 77 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index e571e19..196b5ec 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -120,12 +120,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct if (nbuttons == 0) return NULL; - pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), - GFP_KERNEL); - if (!pdata) { - error = -ENOMEM; - goto err_out; - } + pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button), + GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); pdata->buttons = (struct gpio_keys_button *)(pdata + 1); pdata->nbuttons = nbuttons; @@ -151,7 +149,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct dev_err(dev, "Failed to get gpio flags, error: %d\n", error); - goto err_free_pdata; + return ERR_PTR(error); } button = &pdata->buttons[i++]; @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct if (of_property_read_u32(pp, "linux,code", &button->code)) { dev_err(dev, "Button without keycode: 0x%x\n", button->gpio); - error = -EINVAL; - goto err_free_pdata; + return ERR_PTR(-EINVAL); } button->desc = of_get_property(pp, "label", NULL); @@ -178,17 +175,10 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct button->debounce_interval = 5; } - if (pdata->nbuttons == 0) { - error = -EINVAL; - goto err_free_pdata; - } + if (pdata->nbuttons == 0) + return ERR_PTR(-EINVAL); return pdata; - -err_free_pdata: - kfree(pdata); -err_out: - return ERR_PTR(error); } static struct of_device_id gpio_keys_polled_of_match[] = { @@ -213,6 +203,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) struct gpio_keys_polled_dev *bdev; struct input_polled_dev *poll_dev; struct input_dev *input; + size_t size; int error; int i; @@ -228,24 +219,21 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (!pdata->poll_interval) { dev_err(dev, "missing poll_interval value\n"); - error = -EINVAL; - goto err_free_pdata; + return -EINVAL; } - bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + - pdata->nbuttons * sizeof(struct gpio_keys_button_data), - GFP_KERNEL); + size = sizeof(struct gpio_keys_polled_dev) + + pdata->nbuttons * sizeof(struct gpio_keys_button_data); + bdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); if (!bdev) { dev_err(dev, "no memory for private data\n"); - error = -ENOMEM; - goto err_free_pdata; + return -ENOMEM; } - poll_dev = input_allocate_polled_device(); + poll_dev = devm_input_allocate_polled_device(&pdev->dev); if (!poll_dev) { dev_err(dev, "no memory for polled device\n"); - error = -ENOMEM; - goto err_free_bdev; + return -ENOMEM; } poll_dev->private = bdev; @@ -258,7 +246,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) input->name = pdev->name; input->phys = DRV_NAME"/input0"; - input->dev.parent = &pdev->dev; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; @@ -277,16 +264,15 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (button->wakeup) { dev_err(dev, DRV_NAME " does not support wakeup\n"); - error = -EINVAL; - goto err_free_gpio; + return -EINVAL; } - error = gpio_request_one(gpio, GPIOF_IN, - button->desc ?: DRV_NAME); + error = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_IN, + button->desc ? : DRV_NAME); if (error) { dev_err(dev, "unable to claim gpio %u, err=%d\n", gpio, error); - goto err_free_gpio; + return error; } bdata->can_sleep = gpio_cansleep(gpio); @@ -306,7 +292,7 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) if (error) { dev_err(dev, "unable to register polled device, err=%d\n", error); - goto err_free_gpio; + return error; } /* report initial state of the buttons */ @@ -315,52 +301,10 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) &bdev->data[i]); return 0; - -err_free_gpio: - while (--i >= 0) - gpio_free(pdata->buttons[i].gpio); - - input_free_polled_device(poll_dev); - -err_free_bdev: - kfree(bdev); - -err_free_pdata: - /* If we have no platform_data, we allocated pdata dynamically. */ - if (!dev_get_platdata(&pdev->dev)) - kfree(pdata); - - return error; -} - -static int gpio_keys_polled_remove(struct platform_device *pdev) -{ - struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); - const struct gpio_keys_platform_data *pdata = bdev->pdata; - int i; - - input_unregister_polled_device(bdev->poll_dev); - - for (i = 0; i < pdata->nbuttons; i++) - gpio_free(pdata->buttons[i].gpio); - - input_free_polled_device(bdev->poll_dev); - - /* - * If we had no platform_data, we allocated pdata dynamically and - * must free it here. - */ - if (!dev_get_platdata(&pdev->dev)) - kfree(pdata); - - kfree(bdev); - - return 0; } static struct platform_driver gpio_keys_polled_driver = { .probe = gpio_keys_polled_probe, - .remove = gpio_keys_polled_remove, .driver = { .name = DRV_NAME, .owner = THIS_MODULE, ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 3:26 ` [PATCH RESEND 1/2] input: gpio_keys_polled: " Dmitry Torokhov @ 2014-04-29 4:43 ` Alexander Shiyan 2014-04-29 15:50 ` Dmitry Torokhov 0 siblings, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-04-29 4:43 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > Hi Alexander, > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > Replace existing resource handling in the driver with managed > > device resource, this ensures more consistent error values and > > simplifies error paths. > > kzalloc -> devm_kzalloc > > gpio_request_one -> devm_gpio_request_one > > > > If we are doing the conversion can we go all the Alexanderway (needs the > other 2 patches I just posted and CCed you)? > > Thanks. > > -- > Dmitry > > Input: gpio_keys_polled - convert to devm-* API > > From: Alexander Shiyan <shc_work@mail.ru> > > Replace existing resource handling in the driver with managed device > resources, this ensures more consistent error values and simplifies error > handling paths: > > kzalloc -> devm_kzalloc > gpio_request_one -> devm_gpio_request_one > input_allocate_polled_device -> devm_input_allocate_polled_device > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> > --- ... > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > if (of_property_read_u32(pp, "linux,code", &button->code)) { > dev_err(dev, "Button without keycode: 0x%x\n", > button->gpio); > - error = -EINVAL; > - goto err_free_pdata; > + return ERR_PTR(-EINVAL); > } We can even use return value from of_property_read_u32() on error. All other looks OK. --- ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 4:43 ` Alexander Shiyan @ 2014-04-29 15:50 ` Dmitry Torokhov 2014-04-29 16:03 ` Alexander Shiyan 0 siblings, 1 reply; 14+ messages in thread From: Dmitry Torokhov @ 2014-04-29 15:50 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input On Tue, Apr 29, 2014 at 08:43:48AM +0400, Alexander Shiyan wrote: > Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > Hi Alexander, > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > Replace existing resource handling in the driver with managed > > > device resource, this ensures more consistent error values and > > > simplifies error paths. > > > kzalloc -> devm_kzalloc > > > gpio_request_one -> devm_gpio_request_one > > > > > > > If we are doing the conversion can we go all the Alexanderway (needs the > > other 2 patches I just posted and CCed you)? > > > > Thanks. > > > > -- > > Dmitry > > > > Input: gpio_keys_polled - convert to devm-* API > > > > From: Alexander Shiyan <shc_work@mail.ru> > > > > Replace existing resource handling in the driver with managed device > > resources, this ensures more consistent error values and simplifies error > > handling paths: > > > > kzalloc -> devm_kzalloc > > gpio_request_one -> devm_gpio_request_one > > input_allocate_polled_device -> devm_input_allocate_polled_device > > > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru> > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> > > --- > ... > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > dev_err(dev, "Button without keycode: 0x%x\n", > > button->gpio); > > - error = -EINVAL; > > - goto err_free_pdata; > > + return ERR_PTR(-EINVAL); > > } > > We can even use return value from of_property_read_u32() on error. > > All other looks OK. Do you have hardware that uses gpio_keys_polled? Thanks. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 15:50 ` Dmitry Torokhov @ 2014-04-29 16:03 ` Alexander Shiyan 2014-04-29 16:19 ` Dmitry Torokhov 0 siblings, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-04-29 16:03 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Tue, 29 Apr 2014 08:50:32 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > On Tue, Apr 29, 2014 at 08:43:48AM +0400, Alexander Shiyan wrote: > > Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > Hi Alexander, > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > Replace existing resource handling in the driver with managed > > > > device resource, this ensures more consistent error values and > > > > simplifies error paths. > > > > kzalloc -> devm_kzalloc > > > > gpio_request_one -> devm_gpio_request_one ... > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > button->gpio); > > > - error = -EINVAL; > > > - goto err_free_pdata; > > > + return ERR_PTR(-EINVAL); > > > } > > > > We can even use return value from of_property_read_u32() on error. > > > > All other looks OK. > > Do you have hardware that uses gpio_keys_polled? Yes. --- ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 16:03 ` Alexander Shiyan @ 2014-04-29 16:19 ` Dmitry Torokhov 2014-04-29 16:24 ` Alexander Shiyan 0 siblings, 1 reply; 14+ messages in thread From: Dmitry Torokhov @ 2014-04-29 16:19 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input On Tue, Apr 29, 2014 at 08:03:40PM +0400, Alexander Shiyan wrote: > Tue, 29 Apr 2014 08:50:32 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > On Tue, Apr 29, 2014 at 08:43:48AM +0400, Alexander Shiyan wrote: > > > Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > > Hi Alexander, > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > Replace existing resource handling in the driver with managed > > > > > device resource, this ensures more consistent error values and > > > > > simplifies error paths. > > > > > kzalloc -> devm_kzalloc > > > > > gpio_request_one -> devm_gpio_request_one > ... > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > button->gpio); > > > > - error = -EINVAL; > > > > - goto err_free_pdata; > > > > + return ERR_PTR(-EINVAL); > > > > } > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > All other looks OK. > > > > Do you have hardware that uses gpio_keys_polled? > > Yes. So did you have a chance to actually try my version(s)? I would feel much better if you had ;) Thanks. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 16:19 ` Dmitry Torokhov @ 2014-04-29 16:24 ` Alexander Shiyan 2014-04-29 16:36 ` Dmitry Torokhov 0 siblings, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-04-29 16:24 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Tue, 29 Apr 2014 09:19:27 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > On Tue, Apr 29, 2014 at 08:03:40PM +0400, Alexander Shiyan wrote: > > Tue, 29 Apr 2014 08:50:32 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > On Tue, Apr 29, 2014 at 08:43:48AM +0400, Alexander Shiyan wrote: > > > > Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > > > Hi Alexander, > > > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > Replace existing resource handling in the driver with managed > > > > > > device resource, this ensures more consistent error values and > > > > > > simplifies error paths. > > > > > > kzalloc -> devm_kzalloc > > > > > > gpio_request_one -> devm_gpio_request_one > > ... > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > button->gpio); > > > > > - error = -EINVAL; > > > > > - goto err_free_pdata; > > > > > + return ERR_PTR(-EINVAL); > > > > > } > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > All other looks OK. > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > Yes. > > So did you have a chance to actually try my version(s)? I would feel > much better if you had ;) Unfortunately, due to the large following weekends, I cannot do it earlier than 2 weeks. --- ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 16:24 ` Alexander Shiyan @ 2014-04-29 16:36 ` Dmitry Torokhov 2014-04-29 16:40 ` Alexander Shiyan 0 siblings, 1 reply; 14+ messages in thread From: Dmitry Torokhov @ 2014-04-29 16:36 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote: > Tue, 29 Apr 2014 09:19:27 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > On Tue, Apr 29, 2014 at 08:03:40PM +0400, Alexander Shiyan wrote: > > > Tue, 29 Apr 2014 08:50:32 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > > On Tue, Apr 29, 2014 at 08:43:48AM +0400, Alexander Shiyan wrote: > > > > > Mon, 28 Apr 2014 20:26:00 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > > > > Hi Alexander, > > > > > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > > Replace existing resource handling in the driver with managed > > > > > > > device resource, this ensures more consistent error values and > > > > > > > simplifies error paths. > > > > > > > kzalloc -> devm_kzalloc > > > > > > > gpio_request_one -> devm_gpio_request_one > > > ... > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > > button->gpio); > > > > > > - error = -EINVAL; > > > > > > - goto err_free_pdata; > > > > > > + return ERR_PTR(-EINVAL); > > > > > > } > > > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > > > All other looks OK. > > > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > > > Yes. > > > > So did you have a chance to actually try my version(s)? I would feel > > much better if you had ;) > > Unfortunately, due to the large following weekends, I cannot do it earlier > than 2 weeks. That is fine, there is no rush. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 16:36 ` Dmitry Torokhov @ 2014-04-29 16:40 ` Alexander Shiyan 2014-05-06 4:18 ` Dmitry Torokhov 0 siblings, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-04-29 16:40 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Tue, 29 Apr 2014 09:36:49 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote: ... > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > > > Replace existing resource handling in the driver with managed > > > > > > > > device resource, this ensures more consistent error values and > > > > > > > > simplifies error paths. > > > > > > > > kzalloc -> devm_kzalloc > > > > > > > > gpio_request_one -> devm_gpio_request_one > > > > ... > > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > > > button->gpio); > > > > > > > - error = -EINVAL; > > > > > > > - goto err_free_pdata; > > > > > > > + return ERR_PTR(-EINVAL); > > > > > > > } > > > > > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > > > > > All other looks OK. > > > > > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > > > > > Yes. > > > > > > So did you have a chance to actually try my version(s)? I would feel > > > much better if you had ;) > > > > Unfortunately, due to the large following weekends, I cannot do it earlier > > than 2 weeks. > > That is fine, there is no rush. OK. In this case it would be nice to have a separate branch with poll-series and this patch. Can you make it? --- ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-04-29 16:40 ` Alexander Shiyan @ 2014-05-06 4:18 ` Dmitry Torokhov 2014-05-12 7:15 ` Alexander Shiyan 0 siblings, 1 reply; 14+ messages in thread From: Dmitry Torokhov @ 2014-05-06 4:18 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input On Tue, Apr 29, 2014 at 08:40:59PM +0400, Alexander Shiyan wrote: > Tue, 29 Apr 2014 09:36:49 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote: > ... > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > > > > Replace existing resource handling in the driver with managed > > > > > > > > > device resource, this ensures more consistent error values and > > > > > > > > > simplifies error paths. > > > > > > > > > kzalloc -> devm_kzalloc > > > > > > > > > gpio_request_one -> devm_gpio_request_one > > > > > ... > > > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > > > > button->gpio); > > > > > > > > - error = -EINVAL; > > > > > > > > - goto err_free_pdata; > > > > > > > > + return ERR_PTR(-EINVAL); > > > > > > > > } > > > > > > > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > > > > > > > All other looks OK. > > > > > > > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > > > > > > > Yes. > > > > > > > > So did you have a chance to actually try my version(s)? I would feel > > > > much better if you had ;) > > > > > > Unfortunately, due to the large following weekends, I cannot do it earlier > > > than 2 weeks. > > > > That is fine, there is no rush. > > OK. In this case it would be nice to have a separate branch with poll-series > and this patch. Can you make it? I just pushed new input-polldev branch containing input polldev changes and your patches to gpio-keys and gpio-keys-polled. It is based on 3.14. Thanks. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-05-06 4:18 ` Dmitry Torokhov @ 2014-05-12 7:15 ` Alexander Shiyan 2014-05-14 18:07 ` Dmitry Torokhov 0 siblings, 1 reply; 14+ messages in thread From: Alexander Shiyan @ 2014-05-12 7:15 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input Mon, 5 May 2014 21:18:18 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > On Tue, Apr 29, 2014 at 08:40:59PM +0400, Alexander Shiyan wrote: > > Tue, 29 Apr 2014 09:36:49 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote: > > ... > > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > > > > > Replace existing resource handling in the driver with managed > > > > > > > > > > device resource, this ensures more consistent error values and > > > > > > > > > > simplifies error paths. > > > > > > > > > > kzalloc -> devm_kzalloc > > > > > > > > > > gpio_request_one -> devm_gpio_request_one > > > > > > ... > > > > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > > > > > button->gpio); > > > > > > > > > - error = -EINVAL; > > > > > > > > > - goto err_free_pdata; > > > > > > > > > + return ERR_PTR(-EINVAL); > > > > > > > > > } > > > > > > > > > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > > > > > > > > > All other looks OK. > > > > > > > > > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > > > > > > > > > Yes. > > > > > > > > > > So did you have a chance to actually try my version(s)? I would feel > > > > > much better if you had ;) > > > > > > > > Unfortunately, due to the large following weekends, I cannot do it earlier > > > > than 2 weeks. > > > > > > That is fine, there is no rush. > > > > OK. In this case it would be nice to have a separate branch with poll-series > > and this patch. Can you make it? > > I just pushed new input-polldev branch containing input polldev changes > and your patches to gpio-keys and gpio-keys-polled. It is based on 3.14. This works for me as expected, so: Tested-by: Alexander Shiyan <shc_work@mail.ru> --- ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API 2014-05-12 7:15 ` Alexander Shiyan @ 2014-05-14 18:07 ` Dmitry Torokhov 0 siblings, 0 replies; 14+ messages in thread From: Dmitry Torokhov @ 2014-05-14 18:07 UTC (permalink / raw) To: Alexander Shiyan; +Cc: linux-input On Mon, May 12, 2014 at 11:15:02AM +0400, Alexander Shiyan wrote: > Mon, 5 May 2014 21:18:18 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > On Tue, Apr 29, 2014 at 08:40:59PM +0400, Alexander Shiyan wrote: > > > Tue, 29 Apr 2014 09:36:49 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>: > > > > On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote: > > > ... > > > > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote: > > > > > > > > > > > Replace existing resource handling in the driver with managed > > > > > > > > > > > device resource, this ensures more consistent error values and > > > > > > > > > > > simplifies error paths. > > > > > > > > > > > kzalloc -> devm_kzalloc > > > > > > > > > > > gpio_request_one -> devm_gpio_request_one > > > > > > > ... > > > > > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct > > > > > > > > > > if (of_property_read_u32(pp, "linux,code", &button->code)) { > > > > > > > > > > dev_err(dev, "Button without keycode: 0x%x\n", > > > > > > > > > > button->gpio); > > > > > > > > > > - error = -EINVAL; > > > > > > > > > > - goto err_free_pdata; > > > > > > > > > > + return ERR_PTR(-EINVAL); > > > > > > > > > > } > > > > > > > > > > > > > > > > > > We can even use return value from of_property_read_u32() on error. > > > > > > > > > > > > > > > > > > All other looks OK. > > > > > > > > > > > > > > > > Do you have hardware that uses gpio_keys_polled? > > > > > > > > > > > > > > Yes. > > > > > > > > > > > > So did you have a chance to actually try my version(s)? I would feel > > > > > > much better if you had ;) > > > > > > > > > > Unfortunately, due to the large following weekends, I cannot do it earlier > > > > > than 2 weeks. > > > > > > > > That is fine, there is no rush. > > > > > > OK. In this case it would be nice to have a separate branch with poll-series > > > and this patch. Can you make it? > > > > I just pushed new input-polldev branch containing input polldev changes > > and your patches to gpio-keys and gpio-keys-polled. It is based on 3.14. > > This works for me as expected, so: > > Tested-by: Alexander Shiyan <shc_work@mail.ru> Thank you Alexander, I queued them all for the next merge window. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-05-14 18:07 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-04-26 5:53 [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API Alexander Shiyan 2014-04-26 5:53 ` [PATCH RESEND 2/2] input: gpio_keys: " Alexander Shiyan 2014-04-29 2:30 ` Dmitry Torokhov 2014-04-29 3:26 ` [PATCH RESEND 1/2] input: gpio_keys_polled: " Dmitry Torokhov 2014-04-29 4:43 ` Alexander Shiyan 2014-04-29 15:50 ` Dmitry Torokhov 2014-04-29 16:03 ` Alexander Shiyan 2014-04-29 16:19 ` Dmitry Torokhov 2014-04-29 16:24 ` Alexander Shiyan 2014-04-29 16:36 ` Dmitry Torokhov 2014-04-29 16:40 ` Alexander Shiyan 2014-05-06 4:18 ` Dmitry Torokhov 2014-05-12 7:15 ` Alexander Shiyan 2014-05-14 18:07 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).