Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1641474

[PATCHv3 08/14] pinctrl: mcp23s08: switch to devm_gpiochip_add_data

From Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Newsgroups linux.kernel
Subject [PATCHv3 08/14] pinctrl: mcp23s08: switch to devm_gpiochip_add_data
Date 2017-05-15 11:30 +0200
Message-ID <tHkuf-6eH-33@gated-at.bofh.it> (permalink)
References <tHkud-6eH-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Switching to devm_gpiochip_add_data simplifies the driver's
cleanup routine and safes a few loc.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 40 ++------------------------------------
 1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 4d2e1c3c0e87..3fc4195ad415 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -898,7 +898,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 			goto fail;
 	}
 
-	ret = gpiochip_add_data(&mcp->chip, mcp);
+	ret = devm_gpiochip_add_data(dev, &mcp->chip, mcp);
 	if (ret < 0)
 		goto fail;
 
@@ -1034,15 +1034,6 @@ static int mcp230xx_probe(struct i2c_client *client,
 	return 0;
 }
 
-static int mcp230xx_remove(struct i2c_client *client)
-{
-	struct mcp23s08 *mcp = i2c_get_clientdata(client);
-
-	gpiochip_remove(&mcp->chip);
-
-	return 0;
-}
-
 static const struct i2c_device_id mcp230xx_id[] = {
 	{ "mcp23008", MCP_TYPE_008 },
 	{ "mcp23017", MCP_TYPE_017 },
@@ -1056,7 +1047,6 @@ static struct i2c_driver mcp230xx_driver = {
 		.of_match_table = of_match_ptr(mcp23s08_i2c_of_match),
 	},
 	.probe		= mcp230xx_probe,
-	.remove		= mcp230xx_remove,
 	.id_table	= mcp230xx_id,
 };
 
@@ -1166,7 +1156,7 @@ static int mcp23s08_probe(struct spi_device *spi)
 					    0x40 | (addr << 1), type, pdata,
 					    addr);
 		if (status < 0)
-			goto fail;
+			return status;
 
 		if (pdata->base != -1)
 			pdata->base += data->mcp[addr]->chip.ngpio;
@@ -1180,31 +1170,6 @@ static int mcp23s08_probe(struct spi_device *spi)
 	 */
 
 	return 0;
-
-fail:
-	for (addr = 0; addr < ARRAY_SIZE(data->mcp); addr++) {
-
-		if (!data->mcp[addr])
-			continue;
-		gpiochip_remove(&data->mcp[addr]->chip);
-	}
-	return status;
-}
-
-static int mcp23s08_remove(struct spi_device *spi)
-{
-	struct mcp23s08_driver_data	*data = spi_get_drvdata(spi);
-	unsigned			addr;
-
-	for (addr = 0; addr < ARRAY_SIZE(data->mcp); addr++) {
-
-		if (!data->mcp[addr])
-			continue;
-
-		gpiochip_remove(&data->mcp[addr]->chip);
-	}
-
-	return 0;
 }
 
 static const struct spi_device_id mcp23s08_ids[] = {
@@ -1217,7 +1182,6 @@ MODULE_DEVICE_TABLE(spi, mcp23s08_ids);
 
 static struct spi_driver mcp23s08_driver = {
 	.probe		= mcp23s08_probe,
-	.remove		= mcp23s08_remove,
 	.id_table	= mcp23s08_ids,
 	.driver = {
 		.name	= "mcp23s08",
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv3 00/14] mcp23s08 pinconf & cleanup Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 09/14] pinctrl: mcp23s08: simplify i2c pdata handling Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 13/14] pinctrl: mcp23s08: drop comment about missing irq support Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 03/14] pinctrl: mcp23s08: drop pullup config from pdata Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 07/14] pinctrl: mcp23s08: use managed kzalloc for mcp Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 12/14] pinctrl: mcp23s08: simplify spi_present_mask handling Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 08/14] pinctrl: mcp23s08: switch to devm_gpiochip_add_data Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 10/14] pinctrl: mcp23s08: simplify spi pdata handling Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 02/14] pinctrl: mcp23s08: add pinconf support Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
    Re: [PATCHv3 02/14] pinctrl: mcp23s08: add pinconf support Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 14:40 +0200
  [PATCHv3 05/14] pinctrl: mcp23s08: drop OF_GPIO dependency Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  [PATCHv3 01/14] gpio: mcp23s08: move to pinctrl Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
    Re: [PATCHv3 01/14] gpio: mcp23s08: move to pinctrl Sylvain Lemieux <slemieux.tyco@gmail.com> - 2017-05-16 21:50 +0200
  [PATCHv3 11/14] pinctrl: mcp23s08: generalize irq property handling Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-05-15 11:30 +0200
  Re: [PATCHv3 00/14] mcp23s08 pinconf & cleanup Linus Walleij <linus.walleij@linaro.org> - 2017-05-23 10:00 +0200

csiph-web