Skip to content

Commit

Permalink
pinctrl: sx150x: Register pinctrl before adding the gpiochip
Browse files Browse the repository at this point in the history
Various gpiolib activity depend on the pinctrl to be up and kicking.
Therefore, register the pinctrl before adding a gpiochip.

Cc: [email protected]
Suggested-by: Linus Walleij <[email protected]>
Signed-off-by: Peter Rosin <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
peda-r authored and linusw committed Jan 18, 2018
1 parent 0657cb5 commit 1a1d39e
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions drivers/pinctrl/pinctrl-sx150x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,27 @@ static int sx150x_probe(struct i2c_client *client,
if (ret)
return ret;

/* Pinctrl_desc */
pctl->pinctrl_desc.name = "sx150x-pinctrl";
pctl->pinctrl_desc.pctlops = &sx150x_pinctrl_ops;
pctl->pinctrl_desc.confops = &sx150x_pinconf_ops;
pctl->pinctrl_desc.pins = pctl->data->pins;
pctl->pinctrl_desc.npins = pctl->data->npins;
pctl->pinctrl_desc.owner = THIS_MODULE;

ret = devm_pinctrl_register_and_init(dev, &pctl->pinctrl_desc,
pctl, &pctl->pctldev);
if (ret) {
dev_err(dev, "Failed to register pinctrl device\n");
return ret;
}

ret = pinctrl_enable(pctl->pctldev);
if (ret) {
dev_err(dev, "Failed to enable pinctrl device\n");
return ret;
}

/* Register GPIO controller */
pctl->gpio.label = devm_kstrdup(dev, client->name, GFP_KERNEL);
pctl->gpio.base = -1;
Expand Down Expand Up @@ -1217,20 +1238,6 @@ static int sx150x_probe(struct i2c_client *client,
client->irq);
}

/* Pinctrl_desc */
pctl->pinctrl_desc.name = "sx150x-pinctrl";
pctl->pinctrl_desc.pctlops = &sx150x_pinctrl_ops;
pctl->pinctrl_desc.confops = &sx150x_pinconf_ops;
pctl->pinctrl_desc.pins = pctl->data->pins;
pctl->pinctrl_desc.npins = pctl->data->npins;
pctl->pinctrl_desc.owner = THIS_MODULE;

pctl->pctldev = devm_pinctrl_register(dev, &pctl->pinctrl_desc, pctl);
if (IS_ERR(pctl->pctldev)) {
dev_err(dev, "Failed to register pinctrl device\n");
return PTR_ERR(pctl->pctldev);
}

return 0;
}

Expand Down

0 comments on commit 1a1d39e

Please sign in to comment.