diff mbox

spi: clps711x: Convert to devm_gpio_request()

Message ID 1389512019.13361.6.camel@phoenix (mailing list archive)
State Not Applicable
Headers show

Commit Message

Axel Lin Jan. 12, 2014, 7:33 a.m. UTC
Also drop unneeded gpio_is_valid() call, the checking is done in the
implementation of gpio_request().
With this conversion, then we can also remove spi_clps711x_remove().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/spi-clps711x.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

Comments

Alexander Shiyan Jan. 12, 2014, 7:37 a.m. UTC | #1
0JLQvtGB0LrRgNC10YHQtdC90YzQtSwgMTIg0Y/QvdCy0LDRgNGPIDIwMTQsIDE1OjMzICswODow
MCDQvtGCIEF4ZWwgTGluIDxheGVsLmxpbkBpbmdpY3MuY29tPjoKPiBBbHNvIGRyb3AgdW5uZWVk
ZWQgZ3Bpb19pc192YWxpZCgpIGNhbGwsIHRoZSBjaGVja2luZyBpcyBkb25lIGluIHRoZQo+IGlt
cGxlbWVudGF0aW9uIG9mIGdwaW9fcmVxdWVzdCgpLgo+IFdpdGggdGhpcyBjb252ZXJzaW9uLCB0
aGVuIHdlIGNhbiBhbHNvIHJlbW92ZSBzcGlfY2xwczcxMXhfcmVtb3ZlKCkuCj4gCj4gU2lnbmVk
LW9mZi1ieTogQXhlbCBMaW4gPGF4ZWwubGluQGluZ2ljcy5jb20+Cj4gLS0tCgpodHRwczovL2dp
dC5rZXJuZWwub3JnL2NnaXQvbGludXgva2VybmVsL2dpdC9icm9vbmllL3NwaS5naXQvY29tbWl0
Lz9oPXRvcGljL2NscHM3MTF4CgotLS0K
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Jan. 13, 2014, 10:17 a.m. UTC | #2
On Sun, Jan 12, 2014 at 03:33:39PM +0800, Axel Lin wrote:
> Also drop unneeded gpio_is_valid() call, the checking is done in the
> implementation of gpio_request().
> With this conversion, then we can also remove spi_clps711x_remove().

This is a duplicate of a patch Alexander sent the other day.
diff mbox

Patch

diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index 6f03d7e..45a7619 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -193,12 +193,8 @@  static int spi_clps711x_probe(struct platform_device *pdev)
 
 	for (i = 0; i < master->num_chipselect; i++) {
 		hw->chipselect[i] = pdata->chipselect[i];
-		if (!gpio_is_valid(hw->chipselect[i])) {
-			dev_err(&pdev->dev, "Invalid CS GPIO %i\n", i);
-			ret = -EINVAL;
-			goto err_out;
-		}
-		if (gpio_request(hw->chipselect[i], DRIVER_NAME)) {
+		if (devm_gpio_request(&pdev->dev, hw->chipselect[i],
+				      DRIVER_NAME)) {
 			dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i);
 			ret = -EINVAL;
 			goto err_out;
@@ -240,35 +236,17 @@  static int spi_clps711x_probe(struct platform_device *pdev)
 	dev_err(&pdev->dev, "Failed to register master\n");
 
 err_out:
-	while (--i >= 0)
-		if (gpio_is_valid(hw->chipselect[i]))
-			gpio_free(hw->chipselect[i]);
-
 	spi_master_put(master);
 
 	return ret;
 }
 
-static int spi_clps711x_remove(struct platform_device *pdev)
-{
-	int i;
-	struct spi_master *master = platform_get_drvdata(pdev);
-	struct spi_clps711x_data *hw = spi_master_get_devdata(master);
-
-	for (i = 0; i < master->num_chipselect; i++)
-		if (gpio_is_valid(hw->chipselect[i]))
-			gpio_free(hw->chipselect[i]);
-
-	return 0;
-}
-
 static struct platform_driver clps711x_spi_driver = {
 	.driver	= {
 		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
 	},
 	.probe	= spi_clps711x_probe,
-	.remove	= spi_clps711x_remove,
 };
 module_platform_driver(clps711x_spi_driver);