summaryrefslogtreecommitdiff
path: root/drivers/iio/industrialio-core.c
diff options
context:
space:
mode:
authorAlexandru Ardelean <alexandru.ardelean@analog.com>2020-04-07 18:07:43 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-04-19 18:56:34 +0300
commita17cb784fcd7d54b8bca9792d83e5a7516d73d4e (patch)
treefcff5b45ac7531920360618637f6288c5395f77f /drivers/iio/industrialio-core.c
parent2e036804d773e00ea19c6f6b8b7a4b8232c77da1 (diff)
downloadlinux-a17cb784fcd7d54b8bca9792d83e5a7516d73d4e.tar.xz
iio: move 'indio_dev->info' null check first in __iio_device_register()
Moves this to be the first check, as it's very simple and fails the registration earlier, instead of potentially initializing the 'indio_dev->label' and checking for duplicate indexes, and then failing with this simple-check. This is a minor optimization, since '__iio_device_register()' will waste fewer validation cycles in case 'indio_dev->info' is NULL. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/industrialio-core.c')
-rw-r--r--drivers/iio/industrialio-core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 157d95a24faa..56ff24d7a174 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1711,6 +1711,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
{
int ret;
+ if (!indio_dev->info)
+ return -EINVAL;
+
indio_dev->driver_module = this_mod;
/* If the calling driver did not initialize of_node, do it here */
if (!indio_dev->dev.of_node && indio_dev->dev.parent)
@@ -1723,9 +1726,6 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (ret < 0)
return ret;
- if (!indio_dev->info)
- return -EINVAL;
-
/* configure elements for the chrdev */
indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);