From: Markus Elfring <[email protected]>
Date: Mon, 24 Apr 2017 14:26:54 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Use devm_kcalloc() in extcon_dev_register()
Fix a typo in three comment lines
Use devm_kcalloc() in arizona_extcon_get_micd_configs()
drivers/extcon/extcon-arizona.c | 4 +---
drivers/extcon/extcon.c | 11 +++++------
2 files changed, 6 insertions(+), 9 deletions(-)
--
2.12.2
From: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 20:54:11 +0200
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/extcon/extcon.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index f422a78ba342..acb847bc1619 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1252,9 +1252,8 @@ int extcon_dev_register(struct extcon_dev *edev)
}
spin_lock_init(&edev->lock);
-
- edev->nh = devm_kzalloc(&edev->dev,
- sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
+ edev->nh = devm_kcalloc(&edev->dev, edev->max_supported,
+ sizeof(*edev->nh), GFP_KERNEL);
if (!edev->nh) {
ret = -ENOMEM;
goto err_dev;
--
2.12.2
From: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 22:15:20 +0200
Adjust three words in this description for a function.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/extcon/extcon.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index acb847bc1619..8eccf7b14937 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -964,12 +964,12 @@ EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
/**
* extcon_register_notifier_all() - Register a notifier block for all connectors
- * @edev: the extcon device that has the external connecotr.
+ * @edev: the extcon device that has the external connector.
* @nb: a notifier block to be registered.
*
- * This fucntion registers a notifier block in order to receive the state
+ * This function registers a notifier block in order to receive the state
* change of all supported external connectors from extcon device.
- * And The second parameter given to the callback of nb (val) is
+ * And the second parameter given to the callback of nb (val) is
* the current state and third parameter is the edev pointer.
*
* Returns 0 if success or error number if fail
--
2.12.2
From: Markus Elfring <[email protected]>
Date: Sun, 23 Apr 2017 22:44:19 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/extcon/extcon-arizona.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index e2d78cd7030d..f84da4a17724 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1271,9 +1271,7 @@ static int arizona_extcon_get_micd_configs(struct device *dev,
goto out;
nconfs /= entries_per_config;
-
- micd_configs = devm_kzalloc(dev,
- nconfs * sizeof(struct arizona_micd_range),
+ micd_configs = devm_kcalloc(dev, nconfs, sizeof(*micd_configs),
GFP_KERNEL);
if (!micd_configs) {
ret = -ENOMEM;
--
2.12.2
On Mon, Apr 24, 2017 at 02:43:55PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Sun, 23 Apr 2017 22:44:19 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "devm_kcalloc".
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
Reviewed-by: Charles Keepax <[email protected]>
Actually fixes a bug on the alloc as well looks like the type was
wrong before.
Thanks,
Charles
> Actually fixes a bug on the alloc as well looks like the type was
> wrong before.
Does your feedback mean that the tag “Fixes” should be added
to this update suggestion?
Regards,
Markus
On Mon, Apr 24, 2017 at 03:34:07PM +0200, SF Markus Elfring wrote:
> > Actually fixes a bug on the alloc as well looks like the type was
> > wrong before.
>
> Does your feedback mean that the tag “Fixes” should be added
> to this update suggestion?
>
I am happy with it as is, but there would certainly be nothing
wrong with a fixes tag.
Thanks,
Charles