staging:iio:hmc5843: Use devm_iio_device_alloc
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
030a13d709
commit
a6dcb71b0d
1 changed files with 7 additions and 17 deletions
|
@ -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,
|
||||||
|
|
||||||
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)
|
||||||
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);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue