aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/max1363.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/adc/max1363.c')
-rw-r--r--drivers/iio/adc/max1363.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index f148d00b83f7..4fb35d1d7494 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client,
1498 struct iio_dev *indio_dev; 1498 struct iio_dev *indio_dev;
1499 struct regulator *vref; 1499 struct regulator *vref;
1500 1500
1501 indio_dev = iio_device_alloc(sizeof(struct max1363_state)); 1501 indio_dev = devm_iio_device_alloc(&client->dev,
1502 if (indio_dev == NULL) { 1502 sizeof(struct max1363_state));
1503 ret = -ENOMEM; 1503 if (!indio_dev)
1504 goto error_out; 1504 return -ENOMEM;
1505 }
1506 1505
1507 indio_dev->dev.of_node = client->dev.of_node; 1506 indio_dev->dev.of_node = client->dev.of_node;
1508 ret = iio_map_array_register(indio_dev, client->dev.platform_data); 1507 ret = iio_map_array_register(indio_dev, client->dev.platform_data);
1509 if (ret < 0) 1508 if (ret < 0)
1510 goto error_free_device; 1509 return ret;
1511 1510
1512 st = iio_priv(indio_dev); 1511 st = iio_priv(indio_dev);
1513 1512
@@ -1590,9 +1589,6 @@ error_disable_reg:
1590 regulator_disable(st->reg); 1589 regulator_disable(st->reg);
1591error_unregister_map: 1590error_unregister_map:
1592 iio_map_array_unregister(indio_dev); 1591 iio_map_array_unregister(indio_dev);
1593error_free_device:
1594 iio_device_free(indio_dev);
1595error_out:
1596 return ret; 1592 return ret;
1597} 1593}
1598 1594
@@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client)
1607 regulator_disable(st->vref); 1603 regulator_disable(st->vref);
1608 regulator_disable(st->reg); 1604 regulator_disable(st->reg);
1609 iio_map_array_unregister(indio_dev); 1605 iio_map_array_unregister(indio_dev);
1610 iio_device_free(indio_dev);
1611 1606
1612 return 0; 1607 return 0;
1613} 1608}