Hi Anson, On Mon, Dec 10, 2018 at 5:17 AM Anson Huang <anson.hu...@nxp.com> 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.