linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <aardelean@deviqon.com>
To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: bgolaszewski@baylibre.com, linus.walleij@linaro.org,
	sathyanarayanan.kuppuswamy@linux.intel.com, andy@kernel.org,
	Alexandru Ardelean <aardelean@deviqon.com>
Subject: [PATCH] gpio: wcove: remove platform_set_drvdata() + cleanup probe
Date: Wed,  7 Jul 2021 16:52:26 +0300	[thread overview]
Message-ID: <20210707135226.191988-1-aardelean@deviqon.com> (raw)

The platform_set_drvdata() call is only useful if we need to retrieve back
the private information.
Since the driver doesn't do that, it's not useful to have it.

This change also changes the probe order a bit, moving the
devm_gpiochip_add_data() as the last call. This means that when the
gpiochip is registered [and available to consumers], it should be
initialized.

It's still possible that the devm_gpiochip_add_data() call could fail,
leaving the chip in a partially initialized state, but that was possible
even before this change; it was just some other partially initialized
state.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---
 drivers/gpio/gpio-wcove.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index a19eeef6cf1e..2109610f5dad 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -428,8 +428,6 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 
 	wg->regmap_irq_chip = pmic->irq_chip_data;
 
-	platform_set_drvdata(pdev, wg);
-
 	mutex_init(&wg->buslock);
 	wg->chip.label = KBUILD_MODNAME;
 	wg->chip.direction_input = wcove_gpio_dir_in;
@@ -469,12 +467,6 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = devm_gpiochip_add_data(dev, &wg->chip, wg);
-	if (ret) {
-		dev_err(dev, "Failed to add gpiochip: %d\n", ret);
-		return ret;
-	}
-
 	/* Enable GPIO0 interrupts */
 	ret = regmap_clear_bits(wg->regmap, IRQ_MASK_BASE + 0, GPIO_IRQ0_MASK);
 	if (ret)
@@ -485,7 +477,7 @@ static int wcove_gpio_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	return 0;
+	return devm_gpiochip_add_data(dev, &wg->chip, wg);
 }
 
 /*
-- 
2.31.1


             reply	other threads:[~2021-07-07 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 13:52 Alexandru Ardelean [this message]
2021-07-07 14:08 ` Andy Shevchenko
2021-07-08  7:03   ` Alexandru Ardelean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210707135226.191988-1-aardelean@deviqon.com \
    --to=aardelean@deviqon.com \
    --cc=andy@kernel.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --subject='Re: [PATCH] gpio: wcove: remove platform_set_drvdata() + cleanup probe' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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