diff mbox series

[16/42] drivers: gpio: janz-ttl: drop unneccessary temp variable dev

Message ID 1552330521-4276-16-git-send-email-info@metux.net
State New
Headers show
Series [01/42] drivers: gpio: 74xx-mmio: use devm_platform_ioremap_resource() | expand

Commit Message

Enrico Weigelt, metux IT consult March 11, 2019, 6:54 p.m. UTC
don't need the temporary variable "dev", directly use &pdev->dev

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/gpio/gpio-janz-ttl.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Ben Dooks March 12, 2019, 9:17 a.m. UTC | #1
On 11/03/2019 18:54, Enrico Weigelt, metux IT consult wrote:
> don't need the temporary variable "dev", directly use &pdev->dev
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>

This is quite usual to do, and I like it as it saves typing.
Personally I would say don't bother with this change.

> ---
>   drivers/gpio/gpio-janz-ttl.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c
> index b97a911..91f91f6 100644
> --- a/drivers/gpio/gpio-janz-ttl.c
> +++ b/drivers/gpio/gpio-janz-ttl.c
> @@ -144,18 +144,17 @@ static void ttl_setup_device(struct ttl_module *mod)
>   static int ttl_probe(struct platform_device *pdev)
>   {
>   	struct janz_platform_data *pdata;
> -	struct device *dev = &pdev->dev;
>   	struct ttl_module *mod;
>   	struct gpio_chip *gpio;
>   	int ret;
>   
>   	pdata = dev_get_platdata(&pdev->dev);
>   	if (!pdata) {
> -		dev_err(dev, "no platform data\n");
> +		dev_err(&pdev->dev, "no platform data\n");
>   		return -ENXIO;
>   	}
>   
> -	mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL);
> +	mod = devm_kzalloc(&pdev->dev, sizeof(*mod), GFP_KERNEL);
>   	if (!mod)
>   		return -ENOMEM;
>   
> @@ -181,9 +180,9 @@ static int ttl_probe(struct platform_device *pdev)
>   	gpio->base = -1;
>   	gpio->ngpio = 20;
>   
> -	ret = devm_gpiochip_add_data(dev, gpio, NULL);
> +	ret = devm_gpiochip_add_data(&pdev->dev, gpio, NULL);
>   	if (ret) {
> -		dev_err(dev, "unable to add GPIO chip\n");
> +		dev_err(&pdev->dev, "unable to add GPIO chip\n");
>   		return ret;
>   	}
>   
>
Enrico Weigelt, metux IT consult March 12, 2019, 9:33 a.m. UTC | #2
On 12.03.19 10:17, Ben Dooks wrote:
> On 11/03/2019 18:54, Enrico Weigelt, metux IT consult wrote:
>> don't need the temporary variable "dev", directly use &pdev->dev
>>
>> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> 
> This is quite usual to do, and I like it as it saves typing.
> Personally I would say don't bother with this change.

hmm, both approaches have their valid arguments.

I'm not particularily biased to one or another ay, but I'd prefer
having it consistent  everywhere.


--mtx
Thierry Reding March 12, 2019, 11:26 a.m. UTC | #3
On Tue, Mar 12, 2019 at 10:33:44AM +0100, Enrico Weigelt, metux IT consult wrote:
> On 12.03.19 10:17, Ben Dooks wrote:
> > On 11/03/2019 18:54, Enrico Weigelt, metux IT consult wrote:
> >> don't need the temporary variable "dev", directly use &pdev->dev
> >>
> >> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> > 
> > This is quite usual to do, and I like it as it saves typing.
> > Personally I would say don't bother with this change.
> 
> hmm, both approaches have their valid arguments.
> 
> I'm not particularily biased to one or another ay, but I'd prefer
> having it consistent  everywhere.

You're not consistent within the series itself. In patch 3 you went the
other way and dropped usage of pdev->dev in favour of the local dev
variable.

Thierry
Enrico Weigelt, metux IT consult March 12, 2019, 3 p.m. UTC | #4
On 12.03.19 12:26, Thierry Reding wrote:
> You're not consistent within the series itself. In patch 3 you went the
> other way and dropped usage of pdev->dev in favour of the local dev
> variable.

ups, you got me :O
Linus Walleij April 3, 2019, 2:34 a.m. UTC | #5
On Tue, Mar 12, 2019 at 1:55 AM Enrico Weigelt, metux IT consult
<info@metux.net> wrote:

> don't need the temporary variable "dev", directly use &pdev->dev
>
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>

Dropping this patch following the discussion. I like it better as it is :D

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c
index b97a911..91f91f6 100644
--- a/drivers/gpio/gpio-janz-ttl.c
+++ b/drivers/gpio/gpio-janz-ttl.c
@@ -144,18 +144,17 @@  static void ttl_setup_device(struct ttl_module *mod)
 static int ttl_probe(struct platform_device *pdev)
 {
 	struct janz_platform_data *pdata;
-	struct device *dev = &pdev->dev;
 	struct ttl_module *mod;
 	struct gpio_chip *gpio;
 	int ret;
 
 	pdata = dev_get_platdata(&pdev->dev);
 	if (!pdata) {
-		dev_err(dev, "no platform data\n");
+		dev_err(&pdev->dev, "no platform data\n");
 		return -ENXIO;
 	}
 
-	mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL);
+	mod = devm_kzalloc(&pdev->dev, sizeof(*mod), GFP_KERNEL);
 	if (!mod)
 		return -ENOMEM;
 
@@ -181,9 +180,9 @@  static int ttl_probe(struct platform_device *pdev)
 	gpio->base = -1;
 	gpio->ngpio = 20;
 
-	ret = devm_gpiochip_add_data(dev, gpio, NULL);
+	ret = devm_gpiochip_add_data(&pdev->dev, gpio, NULL);
 	if (ret) {
-		dev_err(dev, "unable to add GPIO chip\n");
+		dev_err(&pdev->dev, "unable to add GPIO chip\n");
 		return ret;
 	}