Skip to content

Commit

Permalink
i2c: mux: pca954x: Use the descriptor-based GPIO API
Browse files Browse the repository at this point in the history
The ID-based GPIO API pushes handling of GPIO polarity to drivers.
Simplify the driver by switching to the descriptor-based GPIO API.

This also fixes a mismatch between the pca954x DT bindings that document
a "reset-gpios" property and the driver that requests a "reset-gpio"
property.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Laurent Pinchart authored and Wolfram Sang committed Jun 3, 2014
1 parent d49019a commit 4807e84
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions drivers/i2c/muxes/i2c-mux-pca954x.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int pca954x_probe(struct i2c_client *client,
{
struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct gpio_desc *gpio;
int num, force, class;
struct pca954x *data;
int ret;
Expand All @@ -200,21 +200,10 @@ static int pca954x_probe(struct i2c_client *client,

i2c_set_clientdata(client, data);

if (IS_ENABLED(CONFIG_OF) && np) {
enum of_gpio_flags flags;
int gpio;

/* Get the mux out of reset if a reset GPIO is specified. */
gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
if (gpio_is_valid(gpio)) {
ret = devm_gpio_request_one(&client->dev, gpio,
flags & OF_GPIO_ACTIVE_LOW ?
GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
"pca954x reset");
if (ret < 0)
return ret;
}
}
/* Get the mux out of reset if a reset GPIO is specified. */
gpio = devm_gpiod_get(&client->dev, "reset");
if (!IS_ERR(gpio))
gpiod_direction_output(gpio, 0);

/* Write the mux register at addr to verify
* that the mux is in fact present. This also
Expand Down

0 comments on commit 4807e84

Please sign in to comment.