G'day Anson, On 10/12/2018 3:17 PM, Anson Huang wrote:
The magnetometer's power supply could be controlled by regulator on some platforms, such as i.MX6Q-SABRESD board, the mag3110's power supply is controlled by a GPIO fixed regulator, need to make sure the regulator is enabled before any communication with mag3110, this patch adds optional vdd/vddio regulator operation support.
[snip]
+ + 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; + } +
IANAE, but normally the return pattern for devm_regulator_get_optional if (!IS_ERR(reg)) { regulator_enable ... } else { ret = PTR_ERR(reg); if (ret != -ENODEV) return ret; } -- Regards Phil