diff mbox

[2/3] gpio: tegra: Remove the need of keeping device handle for gpio driver

Message ID 1460969178-20914-2-git-send-email-ldewangan@nvidia.com
State New
Headers show

Commit Message

Laxman Dewangan April 18, 2016, 8:46 a.m. UTC
Remove the file static device handle variable as this is just
required for prints. The required handle can be stored in
tegra_gpio_chip and hence it become redundancy.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/gpio/gpio-tegra.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stephen Warren April 18, 2016, 4:29 p.m. UTC | #1
On 04/18/2016 02:46 AM, Laxman Dewangan wrote:
> Remove the file static device handle variable as this is just
> required for prints. The required handle can be stored in
> tegra_gpio_chip and hence it become redundancy.

This seems fine as far as it goes, but if it's worth doing this, please 
move all the globals into the GPIO chip rather than just one of the 7 
globals.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laxman Dewangan April 18, 2016, 5 p.m. UTC | #2
On Monday 18 April 2016 09:59 PM, Stephen Warren wrote:
> On 04/18/2016 02:46 AM, Laxman Dewangan wrote:
>> Remove the file static device handle variable as this is just
>> required for prints. The required handle can be stored in
>> tegra_gpio_chip and hence it become redundancy.
>
> This seems fine as far as it goes, but if it's worth doing this, 
> please move all the globals into the GPIO chip rather than just one of 
> the 7 globals.

the device pointer is part of the gpiochip and so it is better to use 
gpiochip parent member instead of locally duplicating.

However, moving to other global variables needs some major changes and I 
think it should be treated as independent of this patch.
This patch just utilizes the gpiochip.parent here.

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Warren April 19, 2016, 3:58 p.m. UTC | #3
On 04/18/2016 11:00 AM, Laxman Dewangan wrote:
>
> On Monday 18 April 2016 09:59 PM, Stephen Warren wrote:
>> On 04/18/2016 02:46 AM, Laxman Dewangan wrote:
>>> Remove the file static device handle variable as this is just
>>> required for prints. The required handle can be stored in
>>> tegra_gpio_chip and hence it become redundancy.
>>
>> This seems fine as far as it goes, but if it's worth doing this,
>> please move all the globals into the GPIO chip rather than just one of
>> the 7 globals.
>
> the device pointer is part of the gpiochip and so it is better to use
> gpiochip parent member instead of locally duplicating.
>
> However, moving to other global variables needs some major changes and I
> think it should be treated as independent of this patch.
> This patch just utilizes the gpiochip.parent here.

Looking at the patch this just trades using one global (dev) for another 
(tegra_gpio_chip), so when the other globals are removed, you'll need to 
go back and change tegra_gpio_irq_set_type() again to remove use of the 
global tegra_gpio_chip.

Still, this /does/ remove one global so I guess it's OK. I don't feel 
terribly strongly, especially if you're going to send more patches soon 
to remove the other globals. I'll leave the call to Linus.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Courbot April 20, 2016, 1:16 a.m. UTC | #4
On Mon, Apr 18, 2016 at 5:46 PM, Laxman Dewangan <ldewangan@nvidia.com> wrote:
> Remove the file static device handle variable as this is just
> required for prints. The required handle can be stored in
> tegra_gpio_chip and hence it become redundancy.

Small but still worthy change. "dev" in the file's global namespace is
scary and prone to conflict with local variables declarations.

Acked-by: Alexandre Courbot <acourbot@nvidia.com>

Now I hope you will take care of "regs" and the other static variables
as Stephen rightfully suggested. :)
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 1b0c497..de022a9 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -80,7 +80,6 @@  struct tegra_gpio_soc_config {
 	u32 upper_offset;
 };
 
-static struct device *dev;
 static struct irq_domain *irq_domain;
 static void __iomem *regs;
 static u32 tegra_gpio_bank_count;
@@ -240,7 +239,8 @@  static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 
 	ret = gpiochip_lock_as_irq(&tegra_gpio_chip, gpio);
 	if (ret) {
-		dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio);
+		dev_err(tegra_gpio_chip.parent,
+			"unable to lock Tegra GPIO %d as IRQ\n", gpio);
 		return ret;
 	}
 
@@ -465,8 +465,6 @@  static int tegra_gpio_probe(struct platform_device *pdev)
 	int i;
 	int j;
 
-	dev = &pdev->dev;
-
 	config = of_device_get_match_data(&pdev->dev);
 	if (!config) {
 		dev_err(&pdev->dev, "Error: No device match found\n");
@@ -488,6 +486,8 @@  static int tegra_gpio_probe(struct platform_device *pdev)
 	}
 
 	tegra_gpio_chip.ngpio = tegra_gpio_bank_count * 32;
+	tegra_gpio_chip.parent = &pdev->dev;
+
 
 	tegra_gpio_banks = devm_kzalloc(&pdev->dev,
 			tegra_gpio_bank_count * sizeof(*tegra_gpio_banks),