iio: core: pass parent device as parameter during allocation
The change passes the parent device to the iio_device_alloc() call. This also updates the devm_iio_device_alloc() call to consider the device object as the parent device by default. Having it passed like this, should ensure that any IIO device object already has a device object as parent, allowing for neater control, like passing the 'indio_dev' object for other stuff [like buffers/triggers/etc], and potentially creating iiom_xxx(indio_dev) functions. With this patch, only the 'drivers/platform/x86/toshiba_acpi.c' needs an update to pass the parent object as a parameter. In the next patch all devm_iio_device_alloc() calls will be handled. Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:

committed by
Jonathan Cameron

parent
9ca39411f9
commit
78289b4a58
@@ -3114,7 +3114,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
|
||||
|
||||
toshiba_accelerometer_available(dev);
|
||||
if (dev->accelerometer_supported) {
|
||||
dev->indio_dev = iio_device_alloc(sizeof(*dev));
|
||||
dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev));
|
||||
if (!dev->indio_dev) {
|
||||
pr_err("Unable to allocate iio device\n");
|
||||
goto iio_error;
|
||||
@@ -3124,7 +3124,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
|
||||
|
||||
dev->indio_dev->info = &toshiba_iio_accel_info;
|
||||
dev->indio_dev->name = "Toshiba accelerometer";
|
||||
dev->indio_dev->dev.parent = &acpi_dev->dev;
|
||||
dev->indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
dev->indio_dev->channels = toshiba_iio_accel_channels;
|
||||
dev->indio_dev->num_channels =
|
||||
|
Reference in New Issue
Block a user