Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: max1363: use devm_regulator_get_enable_read_voltage()

Use devm_regulator_get_enable_read_voltage() to simplify the code.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240621-iio-regulator-refactor-round-2-v1-6-49e50cd0b99a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
0817c954 890582c2

+4 -24
+4 -24
drivers/iio/adc/max1363.c
··· 1561 1561 }; 1562 1562 MODULE_DEVICE_TABLE(of, max1363_of_match); 1563 1563 1564 - static void max1363_reg_disable(void *reg) 1565 - { 1566 - regulator_disable(reg); 1567 - } 1568 - 1569 1564 static int max1363_probe(struct i2c_client *client) 1570 1565 { 1571 1566 const struct i2c_device_id *id = i2c_client_get_device_id(client); 1572 1567 int ret; 1573 1568 struct max1363_state *st; 1574 1569 struct iio_dev *indio_dev; 1575 - struct regulator *vref; 1576 1570 1577 1571 indio_dev = devm_iio_device_alloc(&client->dev, 1578 1572 sizeof(struct max1363_state)); ··· 1583 1589 st->chip_info = i2c_get_match_data(client); 1584 1590 st->client = client; 1585 1591 1586 - st->vref_uv = st->chip_info->int_vref_mv * 1000; 1587 - vref = devm_regulator_get_optional(&client->dev, "vref"); 1588 - if (!IS_ERR(vref)) { 1589 - int vref_uv; 1592 + ret = devm_regulator_get_enable_read_voltage(&client->dev, "vref"); 1593 + if (ret < 0 && ret != -ENODEV) 1594 + return ret; 1590 1595 1591 - ret = regulator_enable(vref); 1592 - if (ret) 1593 - return ret; 1594 1596 1595 - ret = devm_add_action_or_reset(&client->dev, max1363_reg_disable, vref); 1596 - if (ret) 1597 - return ret; 1598 - 1599 - st->vref = vref; 1600 - vref_uv = regulator_get_voltage(vref); 1601 - if (vref_uv <= 0) 1602 - return -EINVAL; 1603 - 1604 - st->vref_uv = vref_uv; 1605 - } 1597 + st->vref_uv = ret == -ENODEV ? st->chip_info->int_vref_mv * 1000 : ret; 1606 1598 1607 1599 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 1608 1600 st->send = i2c_master_send;