Skip to content

Commit

Permalink
fbdev: omap2: improve usage of gpiod API
Browse files Browse the repository at this point in the history
Since 39b2bbe (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Also make use of gpiod_get*_optional where applicable.

Apart from simplification of the affected drivers this is another step
towards making the flags argument to gpiod_get*() mandatory.

Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Tomi Valkeinen <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and tomba committed Jun 3, 2015
1 parent 9ccfc4a commit ca8c67d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
12 changes: 3 additions & 9 deletions drivers/video/fbdev/omap2/displays-new/encoder-opa362.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,9 @@ static int opa362_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, ddata);

gpio = devm_gpiod_get(&pdev->dev, "enable");
if (IS_ERR(gpio)) {
if (PTR_ERR(gpio) != -ENOENT)
return PTR_ERR(gpio);

gpio = NULL;
} else {
gpiod_direction_output(gpio, 0);
}
gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);

ddata->enable_gpio = gpio;

Expand Down
13 changes: 3 additions & 10 deletions drivers/video/fbdev/omap2/displays-new/panel-dpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,9 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
struct videomode vm;
struct gpio_desc *gpio;

gpio = devm_gpiod_get(&pdev->dev, "enable");

if (IS_ERR(gpio)) {
if (PTR_ERR(gpio) != -ENOENT)
return PTR_ERR(gpio);
else
gpio = NULL;
} else {
gpiod_direction_output(gpio, 0);
}
gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);

ddata->enable_gpio = gpio;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,14 @@ static int lb035q02_probe_of(struct spi_device *spi)
struct omap_dss_device *in;
struct gpio_desc *gpio;

gpio = devm_gpiod_get(&spi->dev, "enable");
gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(gpio)) {
dev_err(&spi->dev, "failed to parse enable gpio\n");
return PTR_ERR(gpio);
} else {
gpiod_direction_output(gpio, 0);
ddata->enable_gpio = gpio;
}

ddata->enable_gpio = gpio;

ddata->backlight_gpio = -ENOENT;

in = omapdss_of_find_source_for_first_ep(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,12 @@ static int sharp_ls_get_gpio_of(struct device *dev, int index, int val,
const char *desc, struct gpio_desc **gpiod)
{
struct gpio_desc *gd;
int r;

*gpiod = NULL;

gd = devm_gpiod_get_index(dev, desc, index);
gd = devm_gpiod_get_index(dev, desc, index, GPIOD_OUT_LOW);
if (IS_ERR(gd))
return PTR_ERR(gd) == -ENOENT ? 0 : PTR_ERR(gd);

r = gpiod_direction_output(gd, val);
if (r)
return r;
return PTR_ERR(gd);

*gpiod = gd;
return 0;
Expand Down

0 comments on commit ca8c67d

Please sign in to comment.