Skip to content

Commit

Permalink
Merge tag 'gpiod-flags-for-4.3' of git://git.pengutronix.de/git/ukl/l…
Browse files Browse the repository at this point in the history
…inux into devel

The last patch in this series makes the flags parameter for the various
gpiod_get* functions mandatory and so allows to remove an ugly cpp hack
introduced in commit 39b2bbe (gpio: add flags argument to gpiod_get*()
functions) for v3.17-rc1.

The other nine commits fix the last remaining users of these functions that
don't pass flags yet. (Only etraxfs-uart wasn't fixed; this driver's use of the
gpiod functions needs fixing anyhow.)
  • Loading branch information
Linus Walleij committed Jul 17, 2015
2 parents 0154031 + b17d1bf commit 2563606
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 155 deletions.
18 changes: 9 additions & 9 deletions drivers/gpio/devres.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ static int devm_gpiod_match_array(struct device *dev, void *res, void *data)
* automatically disposed on driver detach. See gpiod_get() for detailed
* information about behavior and return values.
*/
struct gpio_desc *__must_check __devm_gpiod_get(struct device *dev,
struct gpio_desc *__must_check devm_gpiod_get(struct device *dev,
const char *con_id,
enum gpiod_flags flags)
{
return devm_gpiod_get_index(dev, con_id, 0, flags);
}
EXPORT_SYMBOL(__devm_gpiod_get);
EXPORT_SYMBOL(devm_gpiod_get);

/**
* devm_gpiod_get_optional - Resource-managed gpiod_get_optional()
Expand All @@ -77,13 +77,13 @@ EXPORT_SYMBOL(__devm_gpiod_get);
* are automatically disposed on driver detach. See gpiod_get_optional() for
* detailed information about behavior and return values.
*/
struct gpio_desc *__must_check __devm_gpiod_get_optional(struct device *dev,
struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev,
const char *con_id,
enum gpiod_flags flags)
{
return devm_gpiod_get_index_optional(dev, con_id, 0, flags);
}
EXPORT_SYMBOL(__devm_gpiod_get_optional);
EXPORT_SYMBOL(devm_gpiod_get_optional);

/**
* devm_gpiod_get_index - Resource-managed gpiod_get_index()
Expand All @@ -96,7 +96,7 @@ EXPORT_SYMBOL(__devm_gpiod_get_optional);
* automatically disposed on driver detach. See gpiod_get_index() for detailed
* information about behavior and return values.
*/
struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev,
struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
const char *con_id,
unsigned int idx,
enum gpiod_flags flags)
Expand All @@ -120,7 +120,7 @@ struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev,

return desc;
}
EXPORT_SYMBOL(__devm_gpiod_get_index);
EXPORT_SYMBOL(devm_gpiod_get_index);

/**
* devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node
Expand Down Expand Up @@ -182,10 +182,10 @@ EXPORT_SYMBOL(devm_get_gpiod_from_child);
* gpiod_get_index_optional() for detailed information about behavior and
* return values.
*/
struct gpio_desc *__must_check __devm_gpiod_get_index_optional(struct device *dev,
struct gpio_desc *__must_check devm_gpiod_get_index_optional(struct device *dev,
const char *con_id,
unsigned int index,
enum gpiod_flags flags)
enum gpiod_flags flags)
{
struct gpio_desc *desc;

Expand All @@ -197,7 +197,7 @@ struct gpio_desc *__must_check __devm_gpiod_get_index_optional(struct device *de

return desc;
}
EXPORT_SYMBOL(__devm_gpiod_get_index_optional);
EXPORT_SYMBOL(devm_gpiod_get_index_optional);

/**
* devm_gpiod_get_array - Resource-managed gpiod_get_array()
Expand Down
16 changes: 8 additions & 8 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,12 +1902,12 @@ EXPORT_SYMBOL_GPL(gpiod_count);
* dev, -ENOENT if no GPIO has been assigned to the requested function, or
* another IS_ERR() code if an error occurred while trying to acquire the GPIO.
*/
struct gpio_desc *__must_check __gpiod_get(struct device *dev, const char *con_id,
struct gpio_desc *__must_check gpiod_get(struct device *dev, const char *con_id,
enum gpiod_flags flags)
{
return gpiod_get_index(dev, con_id, 0, flags);
}
EXPORT_SYMBOL_GPL(__gpiod_get);
EXPORT_SYMBOL_GPL(gpiod_get);

/**
* gpiod_get_optional - obtain an optional GPIO for a given GPIO function
Expand All @@ -1919,13 +1919,13 @@ EXPORT_SYMBOL_GPL(__gpiod_get);
* the requested function it will return NULL. This is convenient for drivers
* that need to handle optional GPIOs.
*/
struct gpio_desc *__must_check __gpiod_get_optional(struct device *dev,
struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
const char *con_id,
enum gpiod_flags flags)
{
return gpiod_get_index_optional(dev, con_id, 0, flags);
}
EXPORT_SYMBOL_GPL(__gpiod_get_optional);
EXPORT_SYMBOL_GPL(gpiod_get_optional);


/**
Expand Down Expand Up @@ -1982,7 +1982,7 @@ static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
* requested function and/or index, or another IS_ERR() code if an error
* occurred while trying to acquire the GPIO.
*/
struct gpio_desc *__must_check __gpiod_get_index(struct device *dev,
struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
const char *con_id,
unsigned int idx,
enum gpiod_flags flags)
Expand Down Expand Up @@ -2031,7 +2031,7 @@ struct gpio_desc *__must_check __gpiod_get_index(struct device *dev,

return desc;
}
EXPORT_SYMBOL_GPL(__gpiod_get_index);
EXPORT_SYMBOL_GPL(gpiod_get_index);

/**
* fwnode_get_named_gpiod - obtain a GPIO from firmware node
Expand Down Expand Up @@ -2100,7 +2100,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
* specified index was assigned to the requested function it will return NULL.
* This is convenient for drivers that need to handle optional GPIOs.
*/
struct gpio_desc *__must_check __gpiod_get_index_optional(struct device *dev,
struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev,
const char *con_id,
unsigned int index,
enum gpiod_flags flags)
Expand All @@ -2115,7 +2115,7 @@ struct gpio_desc *__must_check __gpiod_get_index_optional(struct device *dev,

return desc;
}
EXPORT_SYMBOL_GPL(__gpiod_get_index_optional);
EXPORT_SYMBOL_GPL(gpiod_get_index_optional);

/**
* gpiod_hog - Hog the specified GPIO desc given the provided flags
Expand Down
17 changes: 2 additions & 15 deletions drivers/gpu/drm/msm/edp/edp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,35 +373,22 @@ static int edp_gpio_config(struct edp_ctrl *ctrl)
struct device *dev = &ctrl->pdev->dev;
int ret;

ctrl->panel_hpd_gpio = devm_gpiod_get(dev, "panel-hpd");
ctrl->panel_hpd_gpio = devm_gpiod_get(dev, "panel-hpd", GPIOD_IN);
if (IS_ERR(ctrl->panel_hpd_gpio)) {
ret = PTR_ERR(ctrl->panel_hpd_gpio);
ctrl->panel_hpd_gpio = NULL;
pr_err("%s: cannot get panel-hpd-gpios, %d\n", __func__, ret);
return ret;
}

ret = gpiod_direction_input(ctrl->panel_hpd_gpio);
if (ret) {
pr_err("%s: Set direction for hpd failed, %d\n", __func__, ret);
return ret;
}

ctrl->panel_en_gpio = devm_gpiod_get(dev, "panel-en");
ctrl->panel_en_gpio = devm_gpiod_get(dev, "panel-en", GPIOD_OUT_LOW);
if (IS_ERR(ctrl->panel_en_gpio)) {
ret = PTR_ERR(ctrl->panel_en_gpio);
ctrl->panel_en_gpio = NULL;
pr_err("%s: cannot get panel-en-gpios, %d\n", __func__, ret);
return ret;
}

ret = gpiod_direction_output(ctrl->panel_en_gpio, 0);
if (ret) {
pr_err("%s: Set direction for panel_en failed, %d\n",
__func__, ret);
return ret;
}

DBG("gpio on");

return 0;
Expand Down
22 changes: 7 additions & 15 deletions drivers/gpu/drm/tilcdc/tilcdc_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,25 +375,17 @@ static int panel_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "found backlight\n");
}

panel_mod->enable_gpio = devm_gpiod_get(&pdev->dev, "enable");
panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
GPIOD_OUT_LOW);
if (IS_ERR(panel_mod->enable_gpio)) {
ret = PTR_ERR(panel_mod->enable_gpio);
if (ret != -ENOENT) {
dev_err(&pdev->dev, "failed to request enable GPIO\n");
goto fail_backlight;
}

/* Optional GPIO is not here, continue silently. */
panel_mod->enable_gpio = NULL;
} else {
ret = gpiod_direction_output(panel_mod->enable_gpio, 0);
if (ret < 0) {
dev_err(&pdev->dev, "failed to setup GPIO\n");
goto fail_backlight;
}
dev_info(&pdev->dev, "found enable GPIO\n");
dev_err(&pdev->dev, "failed to request enable GPIO\n");
goto fail_backlight;
}

if (panel_mod->enable_gpio)
dev_info(&pdev->dev, "found enable GPIO\n");

mod = &panel_mod->base;
pdev->dev.platform_data = mod;

Expand Down
6 changes: 1 addition & 5 deletions drivers/iio/light/stk3310.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,12 @@ static int stk3310_gpio_probe(struct i2c_client *client)
dev = &client->dev;

/* gpio interrupt pin */
gpio = devm_gpiod_get_index(dev, STK3310_GPIO, 0);
gpio = devm_gpiod_get_index(dev, STK3310_GPIO, 0, GPIOD_IN);
if (IS_ERR(gpio)) {
dev_err(dev, "acpi gpio get index failed\n");
return PTR_ERR(gpio);
}

ret = gpiod_direction_input(gpio);
if (ret)
return ret;

ret = gpiod_to_irq(gpio);
dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);

Expand Down
6 changes: 1 addition & 5 deletions drivers/iio/magnetometer/bmc150_magn.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,12 @@ static int bmc150_magn_gpio_probe(struct i2c_client *client)
dev = &client->dev;

/* data ready GPIO interrupt pin */
gpio = devm_gpiod_get_index(dev, BMC150_MAGN_GPIO_INT, 0);
gpio = devm_gpiod_get_index(dev, BMC150_MAGN_GPIO_INT, 0, GPIOD_IN);
if (IS_ERR(gpio)) {
dev_err(dev, "ACPI GPIO get index failed\n");
return PTR_ERR(gpio);
}

ret = gpiod_direction_input(gpio);
if (ret)
return ret;

ret = gpiod_to_irq(gpio);

dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/adp1653.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static int adp1653_of_init(struct i2c_client *client,

of_node_put(child);

pd->enable_gpio = devm_gpiod_get(&client->dev, "enable");
pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
if (!pd->enable_gpio) {
dev_err(&client->dev, "Error getting GPIO\n");
return -EINVAL;
Expand Down
10 changes: 3 additions & 7 deletions drivers/nfc/nxp-nci/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,15 @@ static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
struct i2c_client *client = phy->i2c_dev;
struct gpio_desc *gpiod_en, *gpiod_fw, *gpiod_irq;

gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2);
gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1);
gpiod_irq = devm_gpiod_get_index(&client->dev, NULL, 0);
gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
gpiod_irq = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);

if (IS_ERR(gpiod_en) || IS_ERR(gpiod_fw) || IS_ERR(gpiod_irq)) {
nfc_err(&client->dev, "No GPIOs\n");
return -EINVAL;
}

gpiod_direction_output(gpiod_en, 0);
gpiod_direction_output(gpiod_fw, 0);
gpiod_direction_input(gpiod_irq);

client->irq = gpiod_to_irq(gpiod_irq);
if (client->irq < 0) {
nfc_err(&client->dev, "No IRQ\n");
Expand Down
30 changes: 12 additions & 18 deletions drivers/phy/phy-tusb1210.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,26 @@ static struct phy_ops phy_ops = {

static int tusb1210_probe(struct ulpi *ulpi)
{
struct gpio_desc *gpio;
struct tusb1210 *tusb;
u8 val, reg;
int ret;

tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
if (!tusb)
return -ENOMEM;

gpio = devm_gpiod_get(&ulpi->dev, "reset");
if (!IS_ERR(gpio)) {
ret = gpiod_direction_output(gpio, 0);
if (ret)
return ret;
gpiod_set_value_cansleep(gpio, 1);
tusb->gpio_reset = gpio;
}
tusb->gpio_reset = devm_gpiod_get_optional(&ulpi->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(tusb->gpio_reset))
return PTR_ERR(tusb->gpio_reset);

gpio = devm_gpiod_get(&ulpi->dev, "cs");
if (!IS_ERR(gpio)) {
ret = gpiod_direction_output(gpio, 0);
if (ret)
return ret;
gpiod_set_value_cansleep(gpio, 1);
tusb->gpio_cs = gpio;
}
gpiod_set_value_cansleep(tusb->gpio_reset, 1);

tusb->gpio_cs = devm_gpiod_get_optional(&ulpi->dev, "cs",
GPIOD_OUT_LOW);
if (IS_ERR(tusb->gpio_cs))
return PTR_ERR(tusb->gpio_cs);

gpiod_set_value_cansleep(tusb->gpio_cs, 1);

/*
* VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye
Expand Down
26 changes: 16 additions & 10 deletions drivers/usb/dwc3/dwc3-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,23 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
acpi_dwc3_byt_gpios);

/* These GPIOs will turn on the USB2 PHY */
gpio = gpiod_get(&pdev->dev, "cs");
if (!IS_ERR(gpio)) {
gpiod_direction_output(gpio, 0);
gpiod_set_value_cansleep(gpio, 1);
gpiod_put(gpio);
}
/*
* These GPIOs will turn on the USB2 PHY. Note that we have to
* put the gpio descriptors again here because the phy driver
* might want to grab them, too.
*/
gpio = gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);

gpiod_set_value_cansleep(gpio, 1);
gpiod_put(gpio);

gpio = gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(gpio))
return PTR_ERR(gpio);

gpio = gpiod_get(&pdev->dev, "reset");
if (!IS_ERR(gpio)) {
gpiod_direction_output(gpio, 0);
if (gpio) {
gpiod_set_value_cansleep(gpio, 1);
gpiod_put(gpio);
usleep_range(10000, 11000);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/udc/pxa27x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@ static int pxa_udc_probe(struct platform_device *pdev)
}
udc->udc_command = mach->udc_command;
} else {
udc->gpiod = devm_gpiod_get(&pdev->dev, NULL);
udc->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS);
}

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Expand Down
6 changes: 4 additions & 2 deletions drivers/usb/phy/phy-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
clk_rate = 0;

needs_vcc = of_property_read_bool(node, "vcc-supply");
nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset");
nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
GPIOD_ASIS);
err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
if (!err) {
nop->gpiod_vbus = devm_gpiod_get_optional(dev,
"vbus-detect");
"vbus-detect",
GPIOD_ASIS);
err = PTR_ERR_OR_ZERO(nop->gpiod_vbus);
}
} else if (pdata) {
Expand Down
Loading

0 comments on commit 2563606

Please sign in to comment.