Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6917e1d9 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron
Browse files

iio: max1363: Use devm_iio_device_alloc



Using devm_iio_device_alloc makes code simpler.

Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent ebeb021a
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client,
	struct iio_dev *indio_dev;
	struct regulator *vref;

	indio_dev = iio_device_alloc(sizeof(struct max1363_state));
	if (indio_dev == NULL) {
		ret = -ENOMEM;
		goto error_out;
	}
	indio_dev = devm_iio_device_alloc(&client->dev,
					  sizeof(struct max1363_state));
	if (!indio_dev)
		return -ENOMEM;

	indio_dev->dev.of_node = client->dev.of_node;
	ret = iio_map_array_register(indio_dev, client->dev.platform_data);
	if (ret < 0)
		goto error_free_device;
		return ret;

	st = iio_priv(indio_dev);

@@ -1590,9 +1589,6 @@ static int max1363_probe(struct i2c_client *client,
	regulator_disable(st->reg);
error_unregister_map:
	iio_map_array_unregister(indio_dev);
error_free_device:
	iio_device_free(indio_dev);
error_out:
	return ret;
}

@@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client)
		regulator_disable(st->vref);
	regulator_disable(st->reg);
	iio_map_array_unregister(indio_dev);
	iio_device_free(indio_dev);

	return 0;
}