Skip to content

Commit cd13670

Browse files
Linus Walleijgregkh
authored andcommitted
USB: bcma: Make GPIO explicitly optional
What the code does is to not check the return value from devm_gpiod_get() and then avoid using an erroneous GPIO descriptor with IS_ERR_OR_NULL(). This will miss real errors from the GPIO core that should not be ignored, such as probe deferral. Instead request the GPIO as explicitly optional, which means that if it doesn't exist, the descriptor returned will be NULL. Then we can add error handling and also avoid just doing this on the device tree path, and simplify the site where the optional GPIO descriptor is used. There were some problems with cleaning up this GPIO descriptor use in the past, but this is the proper way to deal with it. Cc: Rafał Miłecki <[email protected]> Cc: Chuhong Yuan <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 30a0b95 commit cd13670

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/usb/host/bcma-hcd.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
285285
{
286286
struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev);
287287

288-
if (IS_ERR_OR_NULL(usb_dev->gpio_desc))
288+
if (!usb_dev->gpio_desc)
289289
return;
290290

291291
gpiod_set_value(usb_dev->gpio_desc, val);
@@ -406,9 +406,11 @@ static int bcma_hcd_probe(struct bcma_device *core)
406406
return -ENOMEM;
407407
usb_dev->core = core;
408408

409-
if (core->dev.of_node)
410-
usb_dev->gpio_desc = devm_gpiod_get(&core->dev, "vcc",
411-
GPIOD_OUT_HIGH);
409+
usb_dev->gpio_desc = devm_gpiod_get_optional(&core->dev, "vcc",
410+
GPIOD_OUT_HIGH);
411+
if (IS_ERR(usb_dev->gpio_desc))
412+
return dev_err_probe(&core->dev, PTR_ERR(usb_dev->gpio_desc),
413+
"error obtaining VCC GPIO");
412414

413415
switch (core->id.id) {
414416
case BCMA_CORE_USB20_HOST:

0 commit comments

Comments
 (0)