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.
+IANAE, but normally the return pattern for devm_regulator_get_optional
+ 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;
+ }
+