* [PATCH] iio: core: move 'indio_dev->info' null check first
@ 2020-04-06 12:32 Alexandru Ardelean
2020-04-07 6:21 ` [PATCH v2] " Alexandru Ardelean
2020-04-07 15:07 ` [PATCH v3] iio: move 'indio_dev->info' null check first in __iio_device_register() Alexandru Ardelean
0 siblings, 2 replies; 3+ messages in thread
From: Alexandru Ardelean @ 2020-04-06 12:32 UTC (permalink / raw)
To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Ardelean
Doesn't fix anything. Just moves this to be the first check, as it's very
simple and fails the regitration earlier, instead of potentially
initializing the 'indio_dev->label' and checking for duplicate indexes, and
then failing with this simple-check.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
drivers/iio/industrialio-core.c | 6 +++---
1 file 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] iio: core: move 'indio_dev->info' null check first
2020-04-06 12:32 [PATCH] iio: core: move 'indio_dev->info' null check first Alexandru Ardelean
@ 2020-04-07 6:21 ` Alexandru Ardelean
2020-04-07 15:07 ` [PATCH v3] iio: move 'indio_dev->info' null check first in __iio_device_register() Alexandru Ardelean
1 sibling, 0 replies; 3+ messages in thread
From: Alexandru Ardelean @ 2020-04-07 6:21 UTC (permalink / raw)
To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Ardelean
Doesn't fix anything. Just 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.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
Changelog v1 -> v2:
* fix typo 'regitration' 'registration'
drivers/iio/industrialio-core.c | 6 +++---
1 file 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3] iio: move 'indio_dev->info' null check first in __iio_device_register()
2020-04-06 12:32 [PATCH] iio: core: move 'indio_dev->info' null check first Alexandru Ardelean
2020-04-07 6:21 ` [PATCH v2] " Alexandru Ardelean
@ 2020-04-07 15:07 ` Alexandru Ardelean
1 sibling, 0 replies; 3+ messages in thread
From: Alexandru Ardelean @ 2020-04-07 15:07 UTC (permalink / raw)
To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Ardelean
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>
---
Changelog v1 -> v2:
* fixed typo 'regitration' -> 'registration'
Changelog v2 -> v3:
* title update to include __iio_device_register()
* dropped 'Doesn't fix anything.'
* added sentence about the minor optimization
drivers/iio/industrialio-core.c | 6 +++---
1 file 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);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-07 15:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 12:32 [PATCH] iio: core: move 'indio_dev->info' null check first Alexandru Ardelean
2020-04-07 6:21 ` [PATCH v2] " Alexandru Ardelean
2020-04-07 15:07 ` [PATCH v3] iio: move 'indio_dev->info' null check first in __iio_device_register() Alexandru Ardelean
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).