* [PATCH 02/10] Input: lpc32xx-keys - Convert to devm_platform_ioremap_resource()
[not found] <20230705052346.39337-1-frank.li@vivo.com>
@ 2023-07-05 5:23 ` Yangtao Li
2023-07-05 5:23 ` [PATCH 07/10] Input: sun4i-lradc-keys " Yangtao Li
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Yangtao Li @ 2023-07-05 5:23 UTC (permalink / raw)
To: Dmitry Torokhov, Vladimir Zapolskiy
Cc: Yangtao Li, linux-input, linux-arm-kernel, linux-kernel
Use devm_platform_ioremap_resource() to simplify code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/input/keyboard/lpc32xx-keys.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
index 911e1181cd6f..322a87807159 100644
--- a/drivers/input/keyboard/lpc32xx-keys.c
+++ b/drivers/input/keyboard/lpc32xx-keys.c
@@ -160,17 +160,10 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
{
struct lpc32xx_kscan_drv *kscandat;
struct input_dev *input;
- struct resource *res;
size_t keymap_size;
int error;
int irq;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "failed to get platform I/O memory\n");
- return -EINVAL;
- }
-
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return -EINVAL;
@@ -221,7 +214,7 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
input_set_drvdata(kscandat->input, kscandat);
- kscandat->kscan_base = devm_ioremap_resource(&pdev->dev, res);
+ kscandat->kscan_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(kscandat->kscan_base))
return PTR_ERR(kscandat->kscan_base);
--
2.39.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 07/10] Input: sun4i-lradc-keys - Convert to devm_platform_ioremap_resource()
[not found] <20230705052346.39337-1-frank.li@vivo.com>
2023-07-05 5:23 ` [PATCH 02/10] Input: lpc32xx-keys - Convert to devm_platform_ioremap_resource() Yangtao Li
@ 2023-07-05 5:23 ` Yangtao Li
2023-07-11 18:27 ` Jernej Škrabec
2023-07-05 5:23 ` [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove Yangtao Li
2023-07-05 5:23 ` [PATCH 10/10] Input: lpc32xx_ts - Convert to use devm_* api Yangtao Li
3 siblings, 1 reply; 6+ messages in thread
From: Yangtao Li @ 2023-07-05 5:23 UTC (permalink / raw)
To: Hans de Goede, Dmitry Torokhov, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland
Cc: Yangtao Li, linux-input, linux-arm-kernel, linux-sunxi,
linux-kernel
Use devm_platform_ioremap_resource() to simplify code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/input/keyboard/sun4i-lradc-keys.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
index 15c15c0958b0..95d927cc8b7e 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -307,8 +307,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
input_set_drvdata(lradc->input, lradc);
- lradc->base = devm_ioremap_resource(dev,
- platform_get_resource(pdev, IORESOURCE_MEM, 0));
+ lradc->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(lradc->base))
return PTR_ERR(lradc->base);
--
2.39.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove
[not found] <20230705052346.39337-1-frank.li@vivo.com>
2023-07-05 5:23 ` [PATCH 02/10] Input: lpc32xx-keys - Convert to devm_platform_ioremap_resource() Yangtao Li
2023-07-05 5:23 ` [PATCH 07/10] Input: sun4i-lradc-keys " Yangtao Li
@ 2023-07-05 5:23 ` Yangtao Li
2023-07-11 0:40 ` Dmitry Torokhov
2023-07-05 5:23 ` [PATCH 10/10] Input: lpc32xx_ts - Convert to use devm_* api Yangtao Li
3 siblings, 1 reply; 6+ messages in thread
From: Yangtao Li @ 2023-07-05 5:23 UTC (permalink / raw)
To: Dmitry Torokhov, Vladimir Zapolskiy, Kevin Wells,
Durgesh Pattamatta
Cc: Yangtao Li, Dmitry Torokhov, linux-input, linux-arm-kernel,
linux-kernel
When the driver is removed, we need to close the device.
Fixes: 3045a5f5202a ("Input: add LPC32xx touchscreen controller driver")
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/input/touchscreen/lpc32xx_ts.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index 15b5cb763526..ffdd748a9992 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -305,6 +305,8 @@ static int lpc32xx_ts_remove(struct platform_device *pdev)
struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev);
struct resource *res;
+ lpc32xx_stop_tsc(tsc);
+
free_irq(tsc->irq, tsc);
input_unregister_device(tsc->dev);
--
2.39.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 10/10] Input: lpc32xx_ts - Convert to use devm_* api
[not found] <20230705052346.39337-1-frank.li@vivo.com>
` (2 preceding siblings ...)
2023-07-05 5:23 ` [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove Yangtao Li
@ 2023-07-05 5:23 ` Yangtao Li
3 siblings, 0 replies; 6+ messages in thread
From: Yangtao Li @ 2023-07-05 5:23 UTC (permalink / raw)
To: Dmitry Torokhov, Vladimir Zapolskiy
Cc: Yangtao Li, linux-input, linux-arm-kernel, linux-kernel
Use devm_* api to simplify code, this makes it unnecessary to explicitly
release resources.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/input/touchscreen/lpc32xx_ts.c | 75 +++++---------------------
1 file changed, 14 insertions(+), 61 deletions(-)
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index ffdd748a9992..d30ce1380f72 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -198,54 +198,34 @@ static void lpc32xx_ts_close(struct input_dev *dev)
static int lpc32xx_ts_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct lpc32xx_tsc *tsc;
struct input_dev *input;
- struct resource *res;
- resource_size_t size;
int irq;
int error;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "Can't get memory resource\n");
- return -ENOENT;
- }
-
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
- tsc = kzalloc(sizeof(*tsc), GFP_KERNEL);
- input = input_allocate_device();
+ tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL);
+ input = devm_input_allocate_device(dev);
if (!tsc || !input) {
dev_err(&pdev->dev, "failed allocating memory\n");
- error = -ENOMEM;
- goto err_free_mem;
+ return -ENOMEM;
}
tsc->dev = input;
tsc->irq = irq;
- size = resource_size(res);
-
- if (!request_mem_region(res->start, size, pdev->name)) {
- dev_err(&pdev->dev, "TSC registers are not free\n");
- error = -EBUSY;
- goto err_free_mem;
- }
-
- tsc->tsc_base = ioremap(res->start, size);
- if (!tsc->tsc_base) {
- dev_err(&pdev->dev, "Can't map memory\n");
- error = -ENOMEM;
- goto err_release_mem;
- }
+ tsc->tsc_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(tsc->tsc_base))
+ return PTR_ERR(tsc->tsc_base);
- tsc->clk = clk_get(&pdev->dev, NULL);
+ tsc->clk = devm_clk_get(dev, NULL);
if (IS_ERR(tsc->clk)) {
dev_err(&pdev->dev, "failed getting clock\n");
- error = PTR_ERR(tsc->clk);
- goto err_unmap;
+ return PTR_ERR(tsc->clk);
}
input->name = MOD_NAME;
@@ -267,58 +247,31 @@ static int lpc32xx_ts_probe(struct platform_device *pdev)
input_set_drvdata(input, tsc);
- error = request_irq(tsc->irq, lpc32xx_ts_interrupt,
- 0, pdev->name, tsc);
+ error = devm_request_irq(dev, tsc->irq, lpc32xx_ts_interrupt,
+ 0, pdev->name, tsc);
if (error) {
dev_err(&pdev->dev, "failed requesting interrupt\n");
- goto err_put_clock;
+ return error;
}
error = input_register_device(input);
if (error) {
dev_err(&pdev->dev, "failed registering input device\n");
- goto err_free_irq;
+ return error;
}
platform_set_drvdata(pdev, tsc);
- device_init_wakeup(&pdev->dev, 1);
+ device_init_wakeup(&pdev->dev, true);
return 0;
-
-err_free_irq:
- free_irq(tsc->irq, tsc);
-err_put_clock:
- clk_put(tsc->clk);
-err_unmap:
- iounmap(tsc->tsc_base);
-err_release_mem:
- release_mem_region(res->start, size);
-err_free_mem:
- input_free_device(input);
- kfree(tsc);
-
- return error;
}
static int lpc32xx_ts_remove(struct platform_device *pdev)
{
struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev);
- struct resource *res;
lpc32xx_stop_tsc(tsc);
- free_irq(tsc->irq, tsc);
-
- input_unregister_device(tsc->dev);
-
- clk_put(tsc->clk);
-
- iounmap(tsc->tsc_base);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
- kfree(tsc);
-
return 0;
}
--
2.39.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread