Re: [PATCH V2] iio: magnetometer: mag3110: add optional vdd/vddio regulator operation support

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

 



Hi Anson,

On Mon, Dec 10, 2018 at 5:17 AM Anson Huang <anson.huang@xxxxxxx> wrote:

> +       data->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd");
> +       if (!IS_ERR(data->vdd_reg)) {
> +               ret = regulator_enable(data->vdd_reg);
> +               if (ret) {
> +                       dev_err(&client->dev, "failed to enable VDD regulator\n");
> +                       return ret;
> +               }
> +       } else if (data->vdd_reg == ERR_PTR(-EPROBE_DEFER)) {
> +               return -EPROBE_DEFER;
> +       }
> +
> +       data->vddio_reg = devm_regulator_get_optional(&client->dev, "vddio");
> +       if (!IS_ERR(data->vddio_reg)) {
> +               ret = regulator_enable(data->vddio_reg);
> +               if (ret) {
> +                       dev_err(&client->dev, "failed to enable VDDIO regulator\n");
> +                       return ret;

In the case of error you should disable the vdd_reg regulator.

> +               }
> +       } else if (data->vddio_reg == ERR_PTR(-EPROBE_DEFER)) {
> +               return -EPROBE_DEFER;
> +       }
> +
>         ret = i2c_smbus_read_byte_data(client, MAG3110_WHO_AM_I);
>         if (ret < 0)
>                 return ret;

and here you should disable vddio_reg.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux