History

pinctrl: mcp23s08: Get rid of legacy platform data

Platform data is a legacy interface to supply device properties to the driver. In this case we even don't have in-kernel users for it. Just remove it for good.

Andy Shevchenko committed 6 years ago

Commit 6aba6ed1 parent f9a87442 files · +12 −48Browse files

Unified · Split

2 files
  1. drivers/pinctrl/pinctrl-mcp23s08.c +12 −30
  2. include/linux/spi/mcp23s08.h +0 −18
drivers/pinctrl/pinctrl-mcp23s08.c+12−30
@@ -8,7 +8,6 @@ · 7 unmodified lines
8#include <linux/gpio/driver.h>8#include <linux/gpio/driver.h>
9#include <linux/i2c.h>9#include <linux/i2c.h>
10#include <linux/spi/spi.h>10#include <linux/spi/spi.h>
11#include <linux/spi/mcp23s08.h>
12#include <linux/slab.h>11#include <linux/slab.h>
13#include <asm/byteorder.h>12#include <asm/byteorder.h>
14#include <linux/interrupt.h>13#include <linux/interrupt.h>
@@ -914,16 +913,9 @@ MODULE_DEVICE_TABLE(of, mcp23s08_i2c_of_match); · 899 unmodified lines
914static int mcp230xx_probe(struct i2c_client *client,913static int mcp230xx_probe(struct i2c_client *client,
915 const struct i2c_device_id *id)914 const struct i2c_device_id *id)
916{915{
917 struct mcp23s08_platform_data *pdata, local_pdata;
918 struct mcp23s08 *mcp;916 struct mcp23s08 *mcp;
919 int status;917 int status;
920 918
921 pdata = dev_get_platdata(&client->dev);
922 if (!pdata) {
923 pdata = &local_pdata;
924 pdata->base = -1;
925 }
926
927 mcp = devm_kzalloc(&client->dev, sizeof(*mcp), GFP_KERNEL);919 mcp = devm_kzalloc(&client->dev, sizeof(*mcp), GFP_KERNEL);
928 if (!mcp)920 if (!mcp)
929 return -ENOMEM;921 return -ENOMEM;
@@ -937,7 +929,7 @@ static int mcp230xx_probe(struct i2c_client *client, · 7 unmodified lines
937 mcp->irq_chip.irq_bus_sync_unlock = mcp23s08_irq_bus_unlock;929 mcp->irq_chip.irq_bus_sync_unlock = mcp23s08_irq_bus_unlock;
938 930
939 status = mcp23s08_probe_one(mcp, &client->dev, client, client->addr,931 status = mcp23s08_probe_one(mcp, &client->dev, client, client->addr,
940 id->driver_data, pdata->base, 0);932 id->driver_data, -1, 0);
941 if (status)933 if (status)
942 return status;934 return status;
943 935
@@ -986,13 +978,13 @@ static void mcp23s08_i2c_exit(void) { } · 42 unmodified lines
986 978
987static int mcp23s08_probe(struct spi_device *spi)979static int mcp23s08_probe(struct spi_device *spi)
988{980{
989 struct mcp23s08_platform_data *pdata, local_pdata;
990 unsigned addr;981 unsigned addr;
991 int chips = 0;982 int chips = 0;
992 struct mcp23s08_driver_data *data;983 struct mcp23s08_driver_data *data;
993 int status, type;984 int status, type;
994 unsigned ngpio = 0;985 unsigned ngpio = 0;
995 const struct of_device_id *match;986 const struct of_device_id *match;
987 u32 spi_present_mask;
996 988
997 match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev);989 match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev);
998 if (match)990 if (match)
@@ -1000,32 +992,24 @@ static int mcp23s08_probe(struct spi_device *spi) · 1 unmodified line
1000 else992 else
1001 type = spi_get_device_id(spi)->driver_data;993 type = spi_get_device_id(spi)->driver_data;
1002 994
1003 pdata = dev_get_platdata(&spi->dev);995 status = device_property_read_u32(&spi->dev,
1004 if (!pdata) {996 "microchip,spi-present-mask", &spi_present_mask);
1005 pdata = &local_pdata;997 if (status) {
1006 pdata->base = -1;
1007
1008 status = device_property_read_u32(&spi->dev,998 status = device_property_read_u32(&spi->dev,
1009 "microchip,spi-present-mask", &pdata->spi_present_mask);999 "mcp,spi-present-mask", &spi_present_mask);
1010 if (status) {1000 if (status) {
1011 status = device_property_read_u32(&spi->dev,1001 dev_err(&spi->dev, "missing spi-present-mask");
1012 "mcp,spi-present-mask",1002 return -ENODEV;
1013 &pdata->spi_present_mask);
1014
1015 if (status) {
1016 dev_err(&spi->dev, "missing spi-present-mask");
1017 return -ENODEV;
1018 }
1019 }1003 }
1020 }1004 }
1021 1005
1022 if (!pdata->spi_present_mask || pdata->spi_present_mask > 0xff) {1006 if (!spi_present_mask || spi_present_mask > 0xff) {
1023 dev_err(&spi->dev, "invalid spi-present-mask");1007 dev_err(&spi->dev, "invalid spi-present-mask");
1024 return -ENODEV;1008 return -ENODEV;
1025 }1009 }
1026 1010
1027 for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) {1011 for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) {
1028 if (pdata->spi_present_mask & BIT(addr))1012 if (spi_present_mask & BIT(addr))
1029 chips++;1013 chips++;
1030 }1014 }
1031 1015
@@ -1040,7 +1024,7 @@ static int mcp23s08_probe(struct spi_device *spi) · 8 unmodified lines
1040 spi_set_drvdata(spi, data);1024 spi_set_drvdata(spi, data);
1041 1025
1042 for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) {1026 for (addr = 0; addr < MCP_MAX_DEV_PER_CS; addr++) {
1043 if (!(pdata->spi_present_mask & BIT(addr)))1027 if (!(spi_present_mask & BIT(addr)))
1044 continue;1028 continue;
1045 chips--;1029 chips--;
1046 data->mcp[addr] = &data->chip[chips];1030 data->mcp[addr] = &data->chip[chips];
@@ -1054,12 +1038,10 @@ static int mcp23s08_probe(struct spi_device *spi) · 7 unmodified lines
1054 mcp23s08_irq_bus_unlock;1038 mcp23s08_irq_bus_unlock;
1055 status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi,1039 status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi,
1056 0x40 | (addr << 1), type,1040 0x40 | (addr << 1), type,
1057 pdata->base, addr);1041 -1, addr);
1058 if (status < 0)1042 if (status < 0)
1059 return status;1043 return status;
1060 1044
1061 if (pdata->base != -1)
1062 pdata->base += data->mcp[addr]->chip.ngpio;
1063 ngpio += data->mcp[addr]->chip.ngpio;1045 ngpio += data->mcp[addr]->chip.ngpio;
1064 }1046 }
1065 data->ngpio = ngpio;1047 data->ngpio = ngpio;
include/linux/spi/mcp23s08.h+0−18
@@ -1,18 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2struct mcp23s08_platform_data {
3 /* For mcp23s08, up to 4 slaves (numbered 0..3) can share one SPI
4 * chipselect, each providing 1 gpio_chip instance with 8 gpios.
5 * For mpc23s17, up to 8 slaves (numbered 0..7) can share one SPI
6 * chipselect, each providing 1 gpio_chip (port A + port B) with
7 * 16 gpios.
8 */
9 u32 spi_present_mask;
10
11 /* "base" is the number of the first GPIO or -1 for dynamic
12 * assignment. If there are gaps in chip addressing the GPIO
13 * numbers are sequential .. so for example if only slaves 0
14 * and 3 are present, their GPIOs range from base to base+15
15 * (or base+31 for s17 variant).
16 */
17 unsigned base;
18};