linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource()
@ 2023-07-05  5:23 Yangtao Li
  2023-07-05  5:23 ` [PATCH 02/10] Input: lpc32xx-keys " Yangtao Li
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, linux-kernel

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/bcm-keypad.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c
index 56a919ec23b5..92e1fbb092b8 100644
--- a/drivers/input/keyboard/bcm-keypad.c
+++ b/drivers/input/keyboard/bcm-keypad.c
@@ -307,7 +307,6 @@ static int bcm_kp_probe(struct platform_device *pdev)
 {
 	struct bcm_kp *kp;
 	struct input_dev *input_dev;
-	struct resource *res;
 	int error;
 
 	kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
@@ -353,14 +352,7 @@ static int bcm_kp_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	/* Get the KEYPAD base address */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Missing keypad base address resource\n");
-		return -ENODEV;
-	}
-
-	kp->base = devm_ioremap_resource(&pdev->dev, res);
+	kp->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(kp->base))
 		return PTR_ERR(kp->base);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/10] Input: lpc32xx-keys - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-05  5:23 ` [PATCH 03/10] Input: nspire-keypad - Use devm_platform_get_and_ioremap_resource() Yangtao Li
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/10] Input: nspire-keypad - Use devm_platform_get_and_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
  2023-07-05  5:23 ` [PATCH 02/10] Input: lpc32xx-keys " Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-05  5:23 ` [PATCH 04/10] Input: omap4-keyad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, linux-kernel

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/nspire-keypad.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index e9fa1423f136..096c18d7bca1 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -186,8 +186,7 @@ static int nspire_keypad_probe(struct platform_device *pdev)
 		return PTR_ERR(keypad->clk);
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	keypad->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	keypad->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(keypad->reg_base))
 		return PTR_ERR(keypad->reg_base);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/10] Input: omap4-keyad - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
  2023-07-05  5:23 ` [PATCH 02/10] Input: lpc32xx-keys " Yangtao Li
  2023-07-05  5:23 ` [PATCH 03/10] Input: nspire-keypad - Use devm_platform_get_and_ioremap_resource() Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-05  5:23 ` [PATCH 05/10] Input: opencores-kbd " Yangtao Li
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, linux-kernel

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/omap4-keypad.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 9f085d5679db..773e55eed88b 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -341,17 +341,10 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct omap4_keypad *keypad_data;
 	struct input_dev *input_dev;
-	struct resource *res;
 	unsigned int max_keys;
 	int irq;
 	int error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no base address specified\n");
-		return -EINVAL;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -370,7 +363,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
-	keypad_data->base = devm_ioremap_resource(dev, res);
+	keypad_data->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(keypad_data->base))
 		return PTR_ERR(keypad_data->base);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 05/10] Input: opencores-kbd - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (2 preceding siblings ...)
  2023-07-05  5:23 ` [PATCH 04/10] Input: omap4-keyad - Convert to devm_platform_ioremap_resource() Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-05  5:23 ` [PATCH 06/10] Input: pxa27x_keypad " Yangtao Li
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, linux-kernel

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/opencores-kbd.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index b0ea387414c1..7ffe1a70c856 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -39,15 +39,8 @@ static int opencores_kbd_probe(struct platform_device *pdev)
 {
 	struct input_dev *input;
 	struct opencores_kbd *opencores_kbd;
-	struct resource *res;
 	int irq, i, error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "missing board memory resource\n");
-		return -EINVAL;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return -EINVAL;
@@ -65,7 +58,7 @@ static int opencores_kbd_probe(struct platform_device *pdev)
 
 	opencores_kbd->input = input;
 
-	opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res);
+	opencores_kbd->addr = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(opencores_kbd->addr))
 		return PTR_ERR(opencores_kbd->addr);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 06/10] Input: pxa27x_keypad - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (3 preceding siblings ...)
  2023-07-05  5:23 ` [PATCH 05/10] Input: opencores-kbd " Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-05  5:23 ` [PATCH 07/10] Input: sun4i-lradc-keys " Yangtao Li
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, linux-kernel

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/input/keyboard/pxa27x_keypad.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 871f858d0ba7..3724363d140e 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -717,7 +717,6 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct pxa27x_keypad *keypad;
 	struct input_dev *input_dev;
-	struct resource *res;
 	int irq, error;
 
 	/* Driver need build keycode from device tree or pdata */
@@ -728,12 +727,6 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return -ENXIO;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
 	keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad),
 			      GFP_KERNEL);
 	if (!keypad)
@@ -747,7 +740,7 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
 	keypad->input_dev = input_dev;
 	keypad->irq = irq;
 
-	keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
+	keypad->mmio_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(keypad->mmio_base))
 		return PTR_ERR(keypad->mmio_base);
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/10] Input: sun4i-lradc-keys - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (4 preceding siblings ...)
  2023-07-05  5:23 ` [PATCH 06/10] Input: pxa27x_keypad " Yangtao Li
@ 2023-07-05  5:23 ` Yangtao Li
  2023-07-11 18:27   ` Jernej Škrabec
  2023-07-05  5:23 ` [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api Yangtao Li
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 14+ 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (5 preceding siblings ...)
  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:42   ` Dmitry Torokhov
  2023-07-05  5:23 ` [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove Yangtao Li
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 14+ messages in thread
From: Yangtao Li @ 2023-07-05  5:23 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Yangtao Li, linux-input, 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/keyboard/nomadik-ske-keypad.c | 76 +++++----------------
 1 file changed, 18 insertions(+), 58 deletions(-)

diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 970f2a671c2e..93318324e9e0 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -225,9 +225,9 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 {
 	const struct ske_keypad_platform_data *plat =
 			dev_get_platdata(&pdev->dev);
+	struct device *dev = &pdev->dev;
 	struct ske_keypad *keypad;
 	struct input_dev *input;
-	struct resource *res;
 	int irq;
 	int error;
 
@@ -238,20 +238,14 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
-		return -EINVAL;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "missing platform resources\n");
-		return -EINVAL;
-	}
+		return irq;
 
-	keypad = kzalloc(sizeof(struct ske_keypad), GFP_KERNEL);
-	input = input_allocate_device();
+	keypad = devm_kzalloc(dev, sizeof(struct ske_keypad),
+			      GFP_KERNEL);
+	input = devm_input_allocate_device(dev);
 	if (!keypad || !input) {
 		dev_err(&pdev->dev, "failed to allocate keypad memory\n");
-		error = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	keypad->irq = irq;
@@ -259,31 +253,20 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 	keypad->input = input;
 	spin_lock_init(&keypad->ske_keypad_lock);
 
-	if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
-		dev_err(&pdev->dev, "failed to request I/O memory\n");
-		error = -EBUSY;
-		goto err_free_mem;
-	}
-
-	keypad->reg_base = ioremap(res->start, resource_size(res));
-	if (!keypad->reg_base) {
-		dev_err(&pdev->dev, "failed to remap I/O memory\n");
-		error = -ENXIO;
-		goto err_free_mem_region;
-	}
+	keypad->reg_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(keypad->reg_base))
+		return PTR_ERR(keypad->reg_base);
 
-	keypad->pclk = clk_get(&pdev->dev, "apb_pclk");
+	keypad->pclk = devm_clk_get(dev, "apb_pclk");
 	if (IS_ERR(keypad->pclk)) {
 		dev_err(&pdev->dev, "failed to get pclk\n");
-		error = PTR_ERR(keypad->pclk);
-		goto err_iounmap;
+		return PTR_ERR(keypad->pclk);
 	}
 
-	keypad->clk = clk_get(&pdev->dev, NULL);
+	keypad->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(keypad->clk)) {
 		dev_err(&pdev->dev, "failed to get clk\n");
-		error = PTR_ERR(keypad->clk);
-		goto err_pclk;
+		return PTR_ERR(keypad->clk);
 	}
 
 	input->id.bustype = BUS_HOST;
@@ -295,7 +278,7 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 					   keypad->keymap, input);
 	if (error) {
 		dev_err(&pdev->dev, "Failed to build keymap\n");
-		goto err_clk;
+		return error;
 	}
 
 	input_set_capability(input, EV_MSC, MSC_SCAN);
@@ -305,7 +288,7 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 	error = clk_prepare_enable(keypad->pclk);
 	if (error) {
 		dev_err(&pdev->dev, "Failed to prepare/enable pclk\n");
-		goto err_clk;
+		return error;
 	}
 
 	error = clk_prepare_enable(keypad->clk);
@@ -314,7 +297,6 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 		goto err_pclk_disable;
 	}
 
-
 	/* go through board initialization helpers */
 	if (keypad->board->init)
 		keypad->board->init();
@@ -325,8 +307,8 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 		goto err_clk_disable;
 	}
 
-	error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq,
-				     IRQF_ONESHOT, "ske-keypad", keypad);
+	error = devm_request_threaded_irq(dev, keypad->irq, NULL, ske_keypad_irq,
+					  IRQF_ONESHOT, "ske-keypad", keypad);
 	if (error) {
 		dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq);
 		goto err_clk_disable;
@@ -336,7 +318,7 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 	if (error) {
 		dev_err(&pdev->dev,
 				"unable to register input device: %d\n", error);
-		goto err_free_irq;
+		goto err_clk_disable;
 	}
 
 	if (plat->wakeup_enable)
@@ -346,34 +328,16 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_free_irq:
-	free_irq(keypad->irq, keypad);
 err_clk_disable:
 	clk_disable_unprepare(keypad->clk);
 err_pclk_disable:
 	clk_disable_unprepare(keypad->pclk);
-err_clk:
-	clk_put(keypad->clk);
-err_pclk:
-	clk_put(keypad->pclk);
-err_iounmap:
-	iounmap(keypad->reg_base);
-err_free_mem_region:
-	release_mem_region(res->start, resource_size(res));
-err_free_mem:
-	input_free_device(input);
-	kfree(keypad);
 	return error;
 }
 
 static int ske_keypad_remove(struct platform_device *pdev)
 {
 	struct ske_keypad *keypad = platform_get_drvdata(pdev);
-	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	free_irq(keypad->irq, keypad);
-
-	input_unregister_device(keypad->input);
 
 	clk_disable_unprepare(keypad->clk);
 	clk_put(keypad->clk);
@@ -381,10 +345,6 @@ static int ske_keypad_remove(struct platform_device *pdev)
 	if (keypad->board->exit)
 		keypad->board->exit();
 
-	iounmap(keypad->reg_base);
-	release_mem_region(res->start, resource_size(res));
-	kfree(keypad);
-
 	return 0;
 }
 
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (6 preceding siblings ...)
  2023-07-05  5:23 ` [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api 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
  2023-07-11  0:43 ` [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Dmitry Torokhov
  9 siblings, 1 reply; 14+ 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/10] Input: lpc32xx_ts - Convert to use devm_* api
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (7 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
  2023-07-11  0:43 ` [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Dmitry Torokhov
  9 siblings, 0 replies; 14+ 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove
  2023-07-05  5:23 ` [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove Yangtao Li
@ 2023-07-11  0:40   ` Dmitry Torokhov
  0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Torokhov @ 2023-07-11  0:40 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Vladimir Zapolskiy, Kevin Wells, Durgesh Pattamatta, linux-input,
	linux-arm-kernel, linux-kernel

Hi,

On Wed, Jul 05, 2023 at 01:23:45PM +0800, Yangtao Li wrote:
> 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);
> +

This change is not needed because lpc32xx_stop_tsc() is already being
called from lpc32xx_ts_close() which is called when we unregister input
device (provided that open() was called earlier).

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api
  2023-07-05  5:23 ` [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api Yangtao Li
@ 2023-07-11  0:42   ` Dmitry Torokhov
  0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Torokhov @ 2023-07-11  0:42 UTC (permalink / raw)
  To: Yangtao Li; +Cc: linux-input, linux-kernel

Hi,

On Wed, Jul 05, 2023 at 01:23:44PM +0800, Yangtao Li wrote:
> @@ -305,7 +288,7 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
>  	error = clk_prepare_enable(keypad->pclk);
>  	if (error) {
>  		dev_err(&pdev->dev, "Failed to prepare/enable pclk\n");
> -		goto err_clk;
> +		return error;
>  	}
>  
>  	error = clk_prepare_enable(keypad->clk);

We should not mix managed (devm) and normal resources, because doing so
wrecks the order of resource unwinding. Lucklily we have
devm_clk_get_enabled() now, so I switched the driver to use it and
applied the patch.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
                   ` (8 preceding siblings ...)
  2023-07-05  5:23 ` [PATCH 10/10] Input: lpc32xx_ts - Convert to use devm_* api Yangtao Li
@ 2023-07-11  0:43 ` Dmitry Torokhov
  9 siblings, 0 replies; 14+ messages in thread
From: Dmitry Torokhov @ 2023-07-11  0:43 UTC (permalink / raw)
  To: Yangtao Li; +Cc: linux-input, linux-kernel

On Wed, Jul 05, 2023 at 01:23:37PM +0800, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

I applied the lot with the exception of patch #9 which is not needed,
with minor edits in patches #8 and #10.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 07/10] Input: sun4i-lradc-keys - Convert to devm_platform_ioremap_resource()
  2023-07-05  5:23 ` [PATCH 07/10] Input: sun4i-lradc-keys " Yangtao Li
@ 2023-07-11 18:27   ` Jernej Škrabec
  0 siblings, 0 replies; 14+ messages in thread
From: Jernej Škrabec @ 2023-07-11 18:27 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov, Chen-Yu Tsai, Samuel Holland,
	Yangtao Li
  Cc: Yangtao Li, linux-input, linux-arm-kernel, linux-sunxi,
	linux-kernel

Dne sreda, 05. julij 2023 ob 07:23:43 CEST je Yangtao Li napisal(a):
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> ---
>  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);





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-07-11 18:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05  5:23 [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() Yangtao Li
2023-07-05  5:23 ` [PATCH 02/10] Input: lpc32xx-keys " Yangtao Li
2023-07-05  5:23 ` [PATCH 03/10] Input: nspire-keypad - Use devm_platform_get_and_ioremap_resource() Yangtao Li
2023-07-05  5:23 ` [PATCH 04/10] Input: omap4-keyad - Convert to devm_platform_ioremap_resource() Yangtao Li
2023-07-05  5:23 ` [PATCH 05/10] Input: opencores-kbd " Yangtao Li
2023-07-05  5:23 ` [PATCH 06/10] Input: pxa27x_keypad " Yangtao Li
2023-07-05  5:23 ` [PATCH 07/10] Input: sun4i-lradc-keys " Yangtao Li
2023-07-11 18:27   ` Jernej Škrabec
2023-07-05  5:23 ` [PATCH 08/10] Input: nomadik-ske-keypad - Convert to use devm_* api Yangtao Li
2023-07-11  0:42   ` Dmitry Torokhov
2023-07-05  5:23 ` [PATCH 09/10] Input: lpc32xx_ts - stop_tsc when driver remove 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
2023-07-11  0:43 ` [PATCH 01/10] Input: bcm-keypad - Convert to devm_platform_ioremap_resource() 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).