linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource
@ 2013-10-31  2:01 Axel Lin
  2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
  2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
  0 siblings, 2 replies; 6+ messages in thread
From: Axel Lin @ 2013-10-31  2:01 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Christian Ruppert, Kumar Gala, Sascha Leuenberger, linux-gpio

Also move platform_get_resource() call close to devm_ioremap_resource().
The implementation of devm_ioremap_resource() will also check mem parameter
and emit proper error.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-tb10x.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index 833d0f4..45bfed1 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -194,23 +194,16 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
 	if (of_property_read_u32(dn, "abilis,ngpio", &ngpio))
 		return -EINVAL;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "No memory resource defined.\n");
-		return -EINVAL;
-	}
-
 	tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL);
 	if (tb10x_gpio == NULL)
 		return -ENOMEM;
 
 	spin_lock_init(&tb10x_gpio->spinlock);
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem);
-	if (!tb10x_gpio->base) {
-		dev_err(&pdev->dev, "Could not remap reg space.\n");
-		goto fail_ioremap;
-	}
+	if (IS_ERR(tb10x_gpio->base))
+		return PTR_ERR(tb10x_gpio->base);
 
 	tb10x_gpio->gc.label		= of_node_full_name(dn);
 	tb10x_gpio->gc.dev		= &pdev->dev;
@@ -285,7 +278,6 @@ fail_request_irq:
 fail_get_irq:
 	gpiochip_remove(&tb10x_gpio->gc);
 fail_gpiochip_registration:
-fail_ioremap:
 	return ret;
 }
 
-- 
1.8.1.2




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

* [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver
  2013-10-31  2:01 [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Axel Lin
@ 2013-10-31  2:03 ` Axel Lin
  2013-10-31 12:41   ` Christian Ruppert
  2013-11-12 19:36   ` Linus Walleij
  2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
  1 sibling, 2 replies; 6+ messages in thread
From: Axel Lin @ 2013-10-31  2:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Christian Ruppert, Kumar Gala, Sascha Leuenberger, linux-gpio

Use module_platform_driver to simplify the code.
In additional, this is a DT only driver, thus also remove of_match_ptr.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-tb10x.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index 45bfed1..a0391bc 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -311,23 +311,13 @@ static struct platform_driver tb10x_gpio_driver = {
 	.remove		= tb10x_gpio_remove,
 	.driver = {
 		.name	= "tb10x-gpio",
-		.of_match_table = of_match_ptr(tb10x_gpio_dt_ids),
+		.of_match_table = tb10x_gpio_dt_ids,
 		.owner	= THIS_MODULE,
 	}
 };
 
-static int __init ab_gpio_init(void)
-{
-	return platform_driver_register(&tb10x_gpio_driver);
-}
-
-static void __exit ab_gpio_exit(void)
-{
-	platform_driver_unregister(&tb10x_gpio_driver);
-}
+module_platform_driver(tb10x_gpio_driver);
 
-module_init(ab_gpio_init);
-module_exit(ab_gpio_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("tb10x gpio.");
 MODULE_VERSION("0.0.1");
-- 
1.8.1.2




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

* Re: [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource
  2013-10-31  2:01 [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Axel Lin
  2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
@ 2013-10-31 12:40 ` Christian Ruppert
  2013-11-01 13:28   ` Axel Lin
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Ruppert @ 2013-10-31 12:40 UTC (permalink / raw)
  To: Axel Lin; +Cc: Linus Walleij, Kumar Gala, Sascha Leuenberger, linux-gpio

On Thu, Oct 31, 2013 at 10:01:45AM +0800, Axel Lin wrote:
> Also move platform_get_resource() call close to devm_ioremap_resource().
> The implementation of devm_ioremap_resource() will also check mem parameter
> and emit proper error.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Acked-by: Christian Ruppert <christian.ruppert@abilis.com>

> ---
>  drivers/gpio/gpio-tb10x.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
> index 833d0f4..45bfed1 100644
> --- a/drivers/gpio/gpio-tb10x.c
> +++ b/drivers/gpio/gpio-tb10x.c
> @@ -194,23 +194,16 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(dn, "abilis,ngpio", &ngpio))
>  		return -EINVAL;
>  
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!mem) {
> -		dev_err(&pdev->dev, "No memory resource defined.\n");
> -		return -EINVAL;
> -	}
> -
>  	tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL);
>  	if (tb10x_gpio == NULL)
>  		return -ENOMEM;
>  
>  	spin_lock_init(&tb10x_gpio->spinlock);
>  
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem);
> -	if (!tb10x_gpio->base) {
> -		dev_err(&pdev->dev, "Could not remap reg space.\n");
> -		goto fail_ioremap;
> -	}
> +	if (IS_ERR(tb10x_gpio->base))
> +		return PTR_ERR(tb10x_gpio->base);
>  
>  	tb10x_gpio->gc.label		= of_node_full_name(dn);
>  	tb10x_gpio->gc.dev		= &pdev->dev;
> @@ -285,7 +278,6 @@ fail_request_irq:
>  fail_get_irq:
>  	gpiochip_remove(&tb10x_gpio->gc);
>  fail_gpiochip_registration:
> -fail_ioremap:
>  	return ret;
>  }
>  
> -- 
> 1.8.1.2
> 
> 
> 

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

* Re: [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver
  2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
@ 2013-10-31 12:41   ` Christian Ruppert
  2013-11-12 19:36   ` Linus Walleij
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2013-10-31 12:41 UTC (permalink / raw)
  To: Axel Lin; +Cc: Linus Walleij, Kumar Gala, Sascha Leuenberger, linux-gpio

On Thu, Oct 31, 2013 at 10:03:02AM +0800, Axel Lin wrote:
> Use module_platform_driver to simplify the code.
> In additional, this is a DT only driver, thus also remove of_match_ptr.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Acked-by: Christian Ruppert <christian.ruppert@abilis.com>

> ---
>  drivers/gpio/gpio-tb10x.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
> index 45bfed1..a0391bc 100644
> --- a/drivers/gpio/gpio-tb10x.c
> +++ b/drivers/gpio/gpio-tb10x.c
> @@ -311,23 +311,13 @@ static struct platform_driver tb10x_gpio_driver = {
>  	.remove		= tb10x_gpio_remove,
>  	.driver = {
>  		.name	= "tb10x-gpio",
> -		.of_match_table = of_match_ptr(tb10x_gpio_dt_ids),
> +		.of_match_table = tb10x_gpio_dt_ids,
>  		.owner	= THIS_MODULE,
>  	}
>  };
>  
> -static int __init ab_gpio_init(void)
> -{
> -	return platform_driver_register(&tb10x_gpio_driver);
> -}
> -
> -static void __exit ab_gpio_exit(void)
> -{
> -	platform_driver_unregister(&tb10x_gpio_driver);
> -}
> +module_platform_driver(tb10x_gpio_driver);
>  
> -module_init(ab_gpio_init);
> -module_exit(ab_gpio_exit);
>  MODULE_LICENSE("GPL");
>  MODULE_DESCRIPTION("tb10x gpio.");
>  MODULE_VERSION("0.0.1");
> -- 
> 1.8.1.2
> 
> 
> 

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

* Re: [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource
  2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
@ 2013-11-01 13:28   ` Axel Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2013-11-01 13:28 UTC (permalink / raw)
  To: Christian Ruppert
  Cc: Linus Walleij, Kumar Gala, Sascha Leuenberger, linux-gpio

2013/10/31 Christian Ruppert <christian.ruppert@abilis.com>:
> On Thu, Oct 31, 2013 at 10:01:45AM +0800, Axel Lin wrote:
>> Also move platform_get_resource() call close to devm_ioremap_resource().
>> The implementation of devm_ioremap_resource() will also check mem parameter
>> and emit proper error.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Hi Linus,
I just found similar patches already merged in today's linux-next tree.
So you can ignore these 2 patches.

Regards,
Axel

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

* Re: [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver
  2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
  2013-10-31 12:41   ` Christian Ruppert
@ 2013-11-12 19:36   ` Linus Walleij
  1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2013-11-12 19:36 UTC (permalink / raw)
  To: Axel Lin, Wei Yongjun
  Cc: Christian Ruppert, Kumar Gala, Sascha Leuenberger,
	linux-gpio@vger.kernel.org

On Thu, Oct 31, 2013 at 3:03 AM, Axel Lin <axel.lin@ingics.com> wrote:

> Use module_platform_driver to simplify the code.
> In additional, this is a DT only driver, thus also remove of_match_ptr.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

I've already merged a patch like this from Wei Yongjun, but
thanks anyway!

Yours,
Linus Walleij

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

end of thread, other threads:[~2013-11-12 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31  2:01 [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Axel Lin
2013-10-31  2:03 ` [PATCH 2/2] gpio: tb10x: Convert to use module_platform_driver Axel Lin
2013-10-31 12:41   ` Christian Ruppert
2013-11-12 19:36   ` Linus Walleij
2013-10-31 12:40 ` [PATCH 1/2] gpio: tb10x: Fix checking return value of devm_ioremap_resource Christian Ruppert
2013-11-01 13:28   ` Axel Lin

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