Re: [PATCH v4 3/3] gpio: lp873x: Add support for General Purpose Outputs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Keerthy

Some minor comment

> +static int lp873x_gpio_direction_output(struct gpio_chip *chip,
> +                                       unsigned int offset, int value)
> +{
> +       struct lp873x_gpio *gpio = gpiochip_get_data(chip);
> +
> +       /* Set the initial value */
> +       regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
> +                          BIT(offset * 4), value ? BIT(offset * 4) : 0);
> +
> +       return 0;
> +}

Error needs to be return, this function always return 0.

> +
> +static int lp873x_gpio_get(struct gpio_chip *chip, unsigned int offset)
> +{
> +       struct lp873x_gpio *gpio = gpiochip_get_data(chip);
> +       int ret, val;
> +
> +       ret = regmap_read(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, &val);
> +       if (ret < 0)
> +               return ret;
> +
> +       return val & BIT(offset * 4);
> +}
> +
> +static void lp873x_gpio_set(struct gpio_chip *chip, unsigned int offset,
> +                           int value)
> +{
> +       struct lp873x_gpio *gpio = gpiochip_get_data(chip);
> +
> +       regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL,
> +                          BIT(offset * 4), value ? BIT(offset * 4) : 0);
> +}
> +
> +static int lp873x_gpio_request(struct gpio_chip *gc, unsigned int offset)
> +{
> +       struct lp873x_gpio *gpio = gpiochip_get_data(gc);
> +       int ret;
> +
> +       switch (offset) {
> +       case 0:
> +               /* No MUX Set up Needed for GPO */
> +               break;
> +       case 1:
> +               /* Setup the CLKIN_PIN_SEL MUX to GPO2 */
> +               ret = regmap_update_bits(gpio->lp873->regmap, LP873X_REG_CONFIG,
> +                                        LP873X_CONFIG_CLKIN_PIN_SEL, 0);
> +               if (ret)
> +                       return ret;
> +
> +               break;
> +       default:
> +               return -EINVAL;
> +       }
> +
> +       return 0;
> +}

Error needs to be return, this function always return 0. Only default
returns error here which is unlikely condition.

> +
> +
> +static int lp873x_gpio_set_single_ended(struct gpio_chip *gc,
> +                                       unsigned int offset,
> +                                       enum single_ended_mode mode)
> +{
> +       struct lp873x_gpio *gpio = gpiochip_get_data(gc);
> +
> +       switch (mode) {
> +       case LINE_MODE_OPEN_DRAIN:
> +               return regmap_update_bits(gpio->lp873->regmap,
> +                                         LP873X_REG_GPO_CTRL,
> +                                         BIT(offset * 4 + 2),
> +                                         BIT(offset * 4 + 2));
> +       case LINE_MODE_PUSH_PULL:
> +               return regmap_update_bits(gpio->lp873->regmap,
> +                                         LP873X_REG_GPO_CTRL,
> +                                         BIT(offset * 4 + 2), 0);
> +       default:
> +               return -ENOTSUPP;
> +       }
> +}

Error needs to be return, this function always return 0. Only default
returns error here which is unlikely condition.

Regards
Manish Badarkhe
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux