diff options
Diffstat (limited to 'drivers/iio/light')
-rw-r--r-- | drivers/iio/light/cm3605.c | 29 | ||||
-rw-r--r-- | drivers/iio/light/cm36651.c | 7 | ||||
-rw-r--r-- | drivers/iio/light/gp2ap002.c | 24 | ||||
-rw-r--r-- | drivers/iio/light/ltr501.c | 37 | ||||
-rw-r--r-- | drivers/iio/light/max44000.c | 17 | ||||
-rw-r--r-- | drivers/iio/light/noa1305.c | 7 |
6 files changed, 71 insertions, 50 deletions
diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c index 4c83953672be..3e7fb16ab1f6 100644 --- a/drivers/iio/light/cm3605.c +++ b/drivers/iio/light/cm3605.c @@ -159,6 +159,7 @@ static int cm3605_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; enum iio_chan_type ch_type; u32 rset; + int irq; int ret; indio_dev = devm_iio_device_alloc(dev, sizeof(*cm3605)); @@ -195,12 +196,9 @@ static int cm3605_probe(struct platform_device *pdev) cm3605->aout = devm_iio_channel_get(dev, "aout"); if (IS_ERR(cm3605->aout)) { - if (PTR_ERR(cm3605->aout) == -ENODEV) { - dev_err(dev, "no ADC, deferring...\n"); - return -EPROBE_DEFER; - } - dev_err(dev, "failed to get AOUT ADC channel\n"); - return PTR_ERR(cm3605->aout); + ret = PTR_ERR(cm3605->aout); + ret = (ret == -ENODEV) ? -EPROBE_DEFER : ret; + return dev_err_probe(dev, ret, "failed to get AOUT ADC channel\n"); } ret = iio_get_channel_type(cm3605->aout, &ch_type); if (ret < 0) @@ -211,10 +209,10 @@ static int cm3605_probe(struct platform_device *pdev) } cm3605->vdd = devm_regulator_get(dev, "vdd"); - if (IS_ERR(cm3605->vdd)) { - dev_err(dev, "failed to get VDD regulator\n"); - return PTR_ERR(cm3605->vdd); - } + if (IS_ERR(cm3605->vdd)) + return dev_err_probe(dev, PTR_ERR(cm3605->vdd), + "failed to get VDD regulator\n"); + ret = regulator_enable(cm3605->vdd); if (ret) { dev_err(dev, "failed to enable VDD regulator\n"); @@ -223,13 +221,16 @@ static int cm3605_probe(struct platform_device *pdev) cm3605->aset = devm_gpiod_get(dev, "aset", GPIOD_OUT_HIGH); if (IS_ERR(cm3605->aset)) { - dev_err(dev, "no ASET GPIO\n"); - ret = PTR_ERR(cm3605->aset); + ret = dev_err_probe(dev, PTR_ERR(cm3605->aset), "no ASET GPIO\n"); goto out_disable_vdd; } - ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), - cm3605_prox_irq, NULL, 0, "cm3605", indio_dev); + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return dev_err_probe(dev, irq, "failed to get irq\n"); + + ret = devm_request_threaded_irq(dev, irq, cm3605_prox_irq, + NULL, 0, "cm3605", indio_dev); if (ret) { dev_err(dev, "unable to request IRQ\n"); goto out_disable_aset; diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c index fd83a19929bc..89f5e48a6642 100644 --- a/drivers/iio/light/cm36651.c +++ b/drivers/iio/light/cm36651.c @@ -632,10 +632,9 @@ static int cm36651_probe(struct i2c_client *client, cm36651 = iio_priv(indio_dev); cm36651->vled_reg = devm_regulator_get(&client->dev, "vled"); - if (IS_ERR(cm36651->vled_reg)) { - dev_err(&client->dev, "get regulator vled failed\n"); - return PTR_ERR(cm36651->vled_reg); - } + if (IS_ERR(cm36651->vled_reg)) + return dev_err_probe(&client->dev, PTR_ERR(cm36651->vled_reg), + "get regulator vled failed\n"); ret = regulator_enable(cm36651->vled_reg); if (ret) { diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c index f960be7d4001..c6d1d88d3775 100644 --- a/drivers/iio/light/gp2ap002.c +++ b/drivers/iio/light/gp2ap002.c @@ -503,12 +503,9 @@ static int gp2ap002_probe(struct i2c_client *client, if (!gp2ap002->is_gp2ap002s00f) { gp2ap002->alsout = devm_iio_channel_get(dev, "alsout"); if (IS_ERR(gp2ap002->alsout)) { - if (PTR_ERR(gp2ap002->alsout) == -ENODEV) { - dev_err(dev, "no ADC, deferring...\n"); - return -EPROBE_DEFER; - } - dev_err(dev, "failed to get ALSOUT ADC channel\n"); - return PTR_ERR(gp2ap002->alsout); + ret = PTR_ERR(gp2ap002->alsout); + ret = (ret == -ENODEV) ? -EPROBE_DEFER : ret; + return dev_err_probe(dev, ret, "failed to get ALSOUT ADC channel\n"); } ret = iio_get_channel_type(gp2ap002->alsout, &ch_type); if (ret < 0) @@ -521,15 +518,14 @@ static int gp2ap002_probe(struct i2c_client *client, } gp2ap002->vdd = devm_regulator_get(dev, "vdd"); - if (IS_ERR(gp2ap002->vdd)) { - dev_err(dev, "failed to get VDD regulator\n"); - return PTR_ERR(gp2ap002->vdd); - } + if (IS_ERR(gp2ap002->vdd)) + return dev_err_probe(dev, PTR_ERR(gp2ap002->vdd), + "failed to get VDD regulator\n"); + gp2ap002->vio = devm_regulator_get(dev, "vio"); - if (IS_ERR(gp2ap002->vio)) { - dev_err(dev, "failed to get VIO regulator\n"); - return PTR_ERR(gp2ap002->vio); - } + if (IS_ERR(gp2ap002->vio)) + return dev_err_probe(dev, PTR_ERR(gp2ap002->vio), + "failed to get VIO regulator\n"); /* Operating voltage 2.4V .. 3.6V according to datasheet */ ret = regulator_set_voltage(gp2ap002->vdd, 2400000, 3600000); diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 1830221da48d..7e51aaac0bf8 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -15,6 +15,7 @@ #include <linux/delay.h> #include <linux/regmap.h> #include <linux/acpi.h> +#include <linux/regulator/consumer.h> #include <linux/iio/iio.h> #include <linux/iio/events.h> @@ -151,6 +152,7 @@ struct ltr501_chip_info { struct ltr501_data { struct i2c_client *client; + struct regulator_bulk_data regulators[2]; struct mutex lock_als, lock_ps; const struct ltr501_chip_info *chip_info; u8 als_contr, ps_contr; @@ -1379,6 +1381,13 @@ static const struct regmap_config ltr501_regmap_config = { .volatile_reg = ltr501_is_volatile_reg, }; +static void ltr501_disable_regulators(void *d) +{ + struct ltr501_data *data = d; + + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); +} + static int ltr501_powerdown(struct ltr501_data *data) { return ltr501_write_contr(data, data->als_contr & @@ -1423,6 +1432,25 @@ static int ltr501_probe(struct i2c_client *client, mutex_init(&data->lock_als); mutex_init(&data->lock_ps); + data->regulators[0].supply = "vdd"; + data->regulators[1].supply = "vddio"; + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) + return dev_err_probe(&client->dev, ret, + "Failed to get regulators\n"); + + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) + return ret; + + ret = devm_add_action_or_reset(&client->dev, + ltr501_disable_regulators, data); + if (ret) + return ret; + data->reg_it = devm_regmap_field_alloc(&client->dev, regmap, reg_field_it); if (IS_ERR(data->reg_it)) { @@ -1581,9 +1609,18 @@ static const struct i2c_device_id ltr501_id[] = { }; MODULE_DEVICE_TABLE(i2c, ltr501_id); +static const struct of_device_id ltr501_of_match[] = { + { .compatible = "liteon,ltr501", }, + { .compatible = "liteon,ltr559", }, + { .compatible = "liteon,ltr301", }, + {} +}; +MODULE_DEVICE_TABLE(of, ltr501_of_match); + static struct i2c_driver ltr501_driver = { .driver = { .name = LTR501_DRV_NAME, + .of_match_table = ltr501_of_match, .pm = <r501_pm_ops, .acpi_match_table = ACPI_PTR(ltr_acpi_match), }, diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c index b8e721bced5b..85689dffbcbf 100644 --- a/drivers/iio/light/max44000.c +++ b/drivers/iio/light/max44000.c @@ -540,7 +540,6 @@ static int max44000_probe(struct i2c_client *client, return PTR_ERR(data->regmap); } - i2c_set_clientdata(client, indio_dev); mutex_init(&data->lock); indio_dev->info = &max44000_info; indio_dev->name = MAX44000_DRV_NAME; @@ -589,23 +588,14 @@ static int max44000_probe(struct i2c_client *client, return ret; } - ret = iio_triggered_buffer_setup(indio_dev, NULL, max44000_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, NULL, + max44000_trigger_handler, NULL); if (ret < 0) { dev_err(&client->dev, "iio triggered buffer setup failed\n"); return ret; } - return iio_device_register(indio_dev); -} - -static int max44000_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - - return 0; + return devm_iio_device_register(&client->dev, indio_dev); } static const struct i2c_device_id max44000_id[] = { @@ -628,7 +618,6 @@ static struct i2c_driver max44000_driver = { .acpi_match_table = ACPI_PTR(max44000_acpi_match), }, .probe = max44000_probe, - .remove = max44000_remove, .id_table = max44000_id, }; diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c index a308fbc2fc7b..ee81fe083e4c 100644 --- a/drivers/iio/light/noa1305.c +++ b/drivers/iio/light/noa1305.c @@ -217,10 +217,9 @@ static int noa1305_probe(struct i2c_client *client, priv = iio_priv(indio_dev); priv->vin_reg = devm_regulator_get(&client->dev, "vin"); - if (IS_ERR(priv->vin_reg)) { - dev_err(&client->dev, "get regulator vin failed\n"); - return PTR_ERR(priv->vin_reg); - } + if (IS_ERR(priv->vin_reg)) + return dev_err_probe(&client->dev, PTR_ERR(priv->vin_reg), + "get regulator vin failed\n"); ret = regulator_enable(priv->vin_reg); if (ret) { |