diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2013-09-03 01:05:00 (GMT) |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-09-11 22:01:10 (GMT) |
commit | a6dcb71b0d9d3ad68f63e8653aed07daa6265441 (patch) | |
tree | 9d67ace661997c82dee51e26c1b028e490973f94 /drivers/staging/iio/magnetometer | |
parent | 030a13d7099e95122d8b79fce602f9727c81a839 (diff) | |
download | linux-a6dcb71b0d9d3ad68f63e8653aed07daa6265441.tar.xz |
staging:iio:hmc5843: Use devm_iio_device_alloc
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio/magnetometer')
-rw-r--r-- | drivers/staging/iio/magnetometer/hmc5843.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 67c1ce7..c7c5e82 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -643,11 +643,9 @@ static int hmc5843_probe(struct i2c_client *client, struct iio_dev *indio_dev; int err = 0; - indio_dev = iio_device_alloc(sizeof(*data)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto exit; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (indio_dev == NULL) + return -ENOMEM; /* default settings at probe */ data = iio_priv(indio_dev); @@ -665,24 +663,16 @@ static int hmc5843_probe(struct i2c_client *client, err = iio_device_register(indio_dev); if (err) - goto exit_free2; + return err; return 0; - -exit_free2: - iio_device_free(indio_dev); -exit: - return err; } static int hmc5843_remove(struct i2c_client *client) { - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); + iio_device_unregister(i2c_get_clientdata(client)); /* sleep mode to save power */ hmc5843_configure(client, HMC5843_MODE_SLEEP); - iio_device_free(indio_dev); return 0; } @@ -691,14 +681,14 @@ static int hmc5843_remove(struct i2c_client *client) static int hmc5843_suspend(struct device *dev) { hmc5843_configure(to_i2c_client(dev), HMC5843_MODE_SLEEP); + return 0; } static int hmc5843_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct hmc5843_data *data = iio_priv(indio_dev); + struct hmc5843_data *data = iio_priv(i2c_get_clientdata(client)); hmc5843_configure(client, data->operating_mode); |