Re: [PATCH 01/10] staging: iio: hmc5843: Use devm_iio_device_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/11/13 10:55, Sachin Kamat wrote:
> devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@xxxxxxxxxx>
> Cc: Shubhrajyoti Datta <shubhrajyoti@xxxxxx>
This one clashes with Peter's more general cleanup of the driver.
> ---
> Series compile tested.
> ---
>  drivers/staging/iio/magnetometer/hmc5843.c |   16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index 67c1ce7..790f456 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)
> +		return -ENOMEM;
>  
>  	/* default settings at probe */
>  	data = iio_priv(indio_dev);
> @@ -665,14 +663,9 @@ 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)
> @@ -682,7 +675,6 @@ static int hmc5843_remove(struct i2c_client *client)
>  	iio_device_unregister(indio_dev);
>  	 /*  sleep mode to save power */
>  	hmc5843_configure(client, HMC5843_MODE_SLEEP);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux