Skip to content

Commit

Permalink
pinctrl: mcp23s08: simplify i2c pdata handling
Browse files Browse the repository at this point in the history
Simplify i2c pdata handling, so that it uses pdata when available
and falls back to reading device properties otherwise.

Signed-off-by: Sebastian Reichel <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
sre authored and linusw committed May 23, 2017
1 parent d0e49da commit 5f853ac
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions drivers/pinctrl/pinctrl-mcp23s08.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,28 +995,16 @@ static int mcp230xx_probe(struct i2c_client *client,
struct mcp23s08_platform_data *pdata, local_pdata;
struct mcp23s08 *mcp;
int status;
const struct of_device_id *match;

match = of_match_device(of_match_ptr(mcp23s08_i2c_of_match),
&client->dev);
if (match) {
pdata = dev_get_platdata(&client->dev);
if (!pdata) {
pdata = &local_pdata;
pdata->base = -1;
pdata->irq_controller = of_property_read_bool(
client->dev.of_node,
"interrupt-controller");
pdata->mirror = of_property_read_bool(client->dev.of_node,
"microchip,irq-mirror");
} else {
pdata = dev_get_platdata(&client->dev);
if (!pdata) {
pdata = devm_kzalloc(&client->dev,
sizeof(struct mcp23s08_platform_data),
GFP_KERNEL);
if (!pdata)
return -ENOMEM;
pdata->base = -1;
}

pdata->irq_controller = device_property_read_bool(
&client->dev, "interrupt-controller");
pdata->mirror = device_property_read_bool(
&client->dev, "microchip,irq-mirror");
}

mcp = devm_kzalloc(&client->dev, sizeof(*mcp), GFP_KERNEL);
Expand Down

0 comments on commit 5f853ac

Please sign in to comment.