From 7c37de246baab05349b6bc6084d25f40f706fae4 Mon Sep 17 00:00:00 2001 From: elilliebjerg Date: Wed, 24 Jun 2020 05:13:51 -0700 Subject: [PATCH] iio: core: Remove NVS multi-link. - Remove NVS multi-link from IIO now that IIO supports multiple drivers per device. Bug 200622878 Change-Id: I4291c2f478291b65fa30090ee6652224f8e3aef0 Signed-off-by: elilliebjerg --- drivers/iio/industrialio-core.c | 58 +++++++++-------------------------------- include/linux/iio/iio.h | 1 - 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 47b4d27..176ec03 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1,7 +1,7 @@ /* The industrial I/O core * * Copyright (c) 2008 Jonathan Cameron - * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2020, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by @@ -1292,10 +1292,10 @@ struct device_type iio_device_type = { }; /** - * nvs_device_alloc() - allocate an iio_dev from a driver + * iio_device_alloc() - allocate an iio_dev from a driver * @sizeof_priv: Space to allocate for private structure. **/ -struct iio_dev *nvs_device_alloc(int sizeof_priv, bool multi_link) +struct iio_dev *iio_device_alloc(int sizeof_priv) { struct iio_dev *dev; size_t alloc_size; @@ -1311,47 +1311,28 @@ struct iio_dev *nvs_device_alloc(int sizeof_priv, bool multi_link) dev = kzalloc(alloc_size, GFP_KERNEL); if (dev) { - dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); - if (dev->id < 0) { - /* cannot use a dev_err as the name isn't available */ - pr_err("failed to get device id\n"); - kfree(dev); - return NULL; - } - - memcpy(&dev->dev_type, &iio_device_type, - sizeof(dev->dev_type)); - if (multi_link) { - snprintf(dev->link_name, sizeof(dev->link_name), - "iio_device_%d", dev->id); - dev->dev_type.name = dev->link_name; - dev->dev.type = &dev->dev_type; - } else { - dev->dev.type = &iio_device_type; - } dev->dev.groups = dev->groups; + dev->dev.type = &iio_device_type; dev->dev.bus = &iio_bus_type; device_initialize(&dev->dev); dev_set_drvdata(&dev->dev, (void *)dev); mutex_init(&dev->mlock); mutex_init(&dev->info_exist_lock); INIT_LIST_HEAD(&dev->channel_attr_list); + + dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); + if (dev->id < 0) { + /* cannot use a dev_err as the name isn't available */ + pr_err("failed to get device id\n"); + kfree(dev); + return NULL; + } dev_set_name(&dev->dev, "iio:device%d", dev->id); INIT_LIST_HEAD(&dev->buffer_list); } return dev; } -EXPORT_SYMBOL(nvs_device_alloc); - -/** - * iio_device_alloc() - allocate an iio_dev from a driver - * @sizeof_priv: Space to allocate for private structure. - **/ -struct iio_dev *iio_device_alloc(int sizeof_priv) -{ - return nvs_device_alloc(sizeof_priv, false); -} EXPORT_SYMBOL(iio_device_alloc); /** @@ -1594,19 +1575,7 @@ int iio_device_register(struct iio_dev *indio_dev) if (ret < 0) goto error_cdev_del; - ret = sysfs_create_link(&indio_dev->dev.parent->kobj, - &indio_dev->dev.kobj, - indio_dev->dev_type.name); - if (ret) { - dev_err(indio_dev->dev.parent, - "Failed to create link for iio_device %d\n", ret); - goto error_del_device; - } - return 0; - -error_del_device: - device_del(&indio_dev->dev); error_cdev_del: cdev_del(&indio_dev->chrdev); error_unreg_eventset: @@ -1628,8 +1597,7 @@ EXPORT_SYMBOL(iio_device_register); void iio_device_unregister(struct iio_dev *indio_dev) { mutex_lock(&indio_dev->info_exist_lock); - sysfs_delete_link(&indio_dev->dev.parent->kobj, &indio_dev->dev.kobj, - indio_dev->dev_type.name); + device_del(&indio_dev->dev); if (indio_dev->chrdev.dev) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 62dbab6..7e93741 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -641,7 +641,6 @@ static inline void *iio_device_get_drvdata(struct iio_dev *indio_dev) /* Can we make this smaller? */ #define IIO_ALIGN L1_CACHE_BYTES struct iio_dev *iio_device_alloc(int sizeof_priv); -struct iio_dev *nvs_device_alloc(int sizeof_priv, bool multi_link); static inline void *iio_priv(const struct iio_dev *indio_dev) { -- 2.1.4