Skip to content

Commit a17cb78

Browse files
commodoJonathan Cameron
authored andcommitted
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>
1 parent 2e03680 commit a17cb78

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/iio/industrialio-core.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
17111711
{
17121712
int ret;
17131713

1714+
if (!indio_dev->info)
1715+
return -EINVAL;
1716+
17141717
indio_dev->driver_module = this_mod;
17151718
/* If the calling driver did not initialize of_node, do it here */
17161719
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)
17231726
if (ret < 0)
17241727
return ret;
17251728

1726-
if (!indio_dev->info)
1727-
return -EINVAL;
1728-
17291729
/* configure elements for the chrdev */
17301730
indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
17311731

0 commit comments

Comments
 (0)