Commit a6dcb71b authored by Peter Meerwald's avatar Peter Meerwald Committed by Jonathan Cameron

staging:iio:hmc5843: Use devm_iio_device_alloc

Signed-off-by: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 030a13d7
...@@ -643,11 +643,9 @@ static int hmc5843_probe(struct i2c_client *client, ...@@ -643,11 +643,9 @@ static int hmc5843_probe(struct i2c_client *client,
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
int err = 0; int err = 0;
indio_dev = iio_device_alloc(sizeof(*data)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (indio_dev == NULL) { if (indio_dev == NULL)
err = -ENOMEM; return -ENOMEM;
goto exit;
}
/* default settings at probe */ /* default settings at probe */
data = iio_priv(indio_dev); data = iio_priv(indio_dev);
...@@ -665,24 +663,16 @@ static int hmc5843_probe(struct i2c_client *client, ...@@ -665,24 +663,16 @@ static int hmc5843_probe(struct i2c_client *client,
err = iio_device_register(indio_dev); err = iio_device_register(indio_dev);
if (err) if (err)
goto exit_free2; return err;
return 0; return 0;
exit_free2:
iio_device_free(indio_dev);
exit:
return err;
} }
static int hmc5843_remove(struct i2c_client *client) static int hmc5843_remove(struct i2c_client *client)
{ {
struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(i2c_get_clientdata(client));
iio_device_unregister(indio_dev);
/* sleep mode to save power */ /* sleep mode to save power */
hmc5843_configure(client, HMC5843_MODE_SLEEP); hmc5843_configure(client, HMC5843_MODE_SLEEP);
iio_device_free(indio_dev);
return 0; return 0;
} }
...@@ -691,14 +681,14 @@ static int hmc5843_remove(struct i2c_client *client) ...@@ -691,14 +681,14 @@ static int hmc5843_remove(struct i2c_client *client)
static int hmc5843_suspend(struct device *dev) static int hmc5843_suspend(struct device *dev)
{ {
hmc5843_configure(to_i2c_client(dev), HMC5843_MODE_SLEEP); hmc5843_configure(to_i2c_client(dev), HMC5843_MODE_SLEEP);
return 0; return 0;
} }
static int hmc5843_resume(struct device *dev) static int hmc5843_resume(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct iio_dev *indio_dev = i2c_get_clientdata(client); struct hmc5843_data *data = iio_priv(i2c_get_clientdata(client));
struct hmc5843_data *data = iio_priv(indio_dev);
hmc5843_configure(client, data->operating_mode); hmc5843_configure(client, data->operating_mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment