Loading drivers/gpio/gpiolib.c +17 −21 Original line number Original line Diff line number Diff line Loading @@ -255,32 +255,29 @@ int gpiochip_add(struct gpio_chip *chip) } } status = gpiochip_add_to_list(chip); status = gpiochip_add_to_list(chip); if (status) { spin_unlock_irqrestore(&gpio_lock, flags); goto err_free_descs; } if (status == 0) { for (id = 0; id < chip->ngpio; id++) { for (id = 0; id < chip->ngpio; id++) { struct gpio_desc *desc = &descs[id]; struct gpio_desc *desc = &descs[id]; desc->chip = chip; desc->chip = chip; /* REVISIT: most hardware initializes GPIOs as /* REVISIT: most hardware initializes GPIOs as inputs (often * inputs (often with pullups enabled) so power * with pullups enabled) so power usage is minimized. Linux * usage is minimized. Linux code should set the * code should set the gpio direction first thing; but until * gpio direction first thing; but until it does, * it does, and in case chip->get_direction is not set, we may * and in case chip->get_direction is not set, * expose the wrong direction in sysfs. * we may expose the wrong direction in sysfs. */ */ desc->flags = !chip->direction_input desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; ? (1 << FLAG_IS_OUT) : 0; } } } chip->desc = descs; chip->desc = descs; spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags); if (status) goto fail; #ifdef CONFIG_PINCTRL #ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&chip->pin_ranges); INIT_LIST_HEAD(&chip->pin_ranges); #endif #endif Loading @@ -304,10 +301,9 @@ int gpiochip_add(struct gpio_chip *chip) spin_lock_irqsave(&gpio_lock, flags); spin_lock_irqsave(&gpio_lock, flags); list_del(&chip->list); list_del(&chip->list); spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags); fail: chip->desc = NULL; err_free_descs: err_free_descs: kfree(descs); kfree(descs); chip->desc = NULL; /* failures here can mean systems won't boot... */ /* failures here can mean systems won't boot... */ pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, Loading Loading
drivers/gpio/gpiolib.c +17 −21 Original line number Original line Diff line number Diff line Loading @@ -255,32 +255,29 @@ int gpiochip_add(struct gpio_chip *chip) } } status = gpiochip_add_to_list(chip); status = gpiochip_add_to_list(chip); if (status) { spin_unlock_irqrestore(&gpio_lock, flags); goto err_free_descs; } if (status == 0) { for (id = 0; id < chip->ngpio; id++) { for (id = 0; id < chip->ngpio; id++) { struct gpio_desc *desc = &descs[id]; struct gpio_desc *desc = &descs[id]; desc->chip = chip; desc->chip = chip; /* REVISIT: most hardware initializes GPIOs as /* REVISIT: most hardware initializes GPIOs as inputs (often * inputs (often with pullups enabled) so power * with pullups enabled) so power usage is minimized. Linux * usage is minimized. Linux code should set the * code should set the gpio direction first thing; but until * gpio direction first thing; but until it does, * it does, and in case chip->get_direction is not set, we may * and in case chip->get_direction is not set, * expose the wrong direction in sysfs. * we may expose the wrong direction in sysfs. */ */ desc->flags = !chip->direction_input desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; ? (1 << FLAG_IS_OUT) : 0; } } } chip->desc = descs; chip->desc = descs; spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags); if (status) goto fail; #ifdef CONFIG_PINCTRL #ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&chip->pin_ranges); INIT_LIST_HEAD(&chip->pin_ranges); #endif #endif Loading @@ -304,10 +301,9 @@ int gpiochip_add(struct gpio_chip *chip) spin_lock_irqsave(&gpio_lock, flags); spin_lock_irqsave(&gpio_lock, flags); list_del(&chip->list); list_del(&chip->list); spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags); fail: chip->desc = NULL; err_free_descs: err_free_descs: kfree(descs); kfree(descs); chip->desc = NULL; /* failures here can mean systems won't boot... */ /* failures here can mean systems won't boot... */ pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, Loading