mfd/abx500-core: Adjustments for eight function implementations
cover mfd/abx500-core: Adjustments for eight function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jan 2018 21:38:42 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation
in abx500_register_ops()
Improve two size determinations in abx500_register_ops() Adjust 14 checks for null pointers
drivers/mfd/abx500-core.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 mfd/abx500-core: Delete an error message for a failed memory allocation in abx500_register_ops()
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jan 2018 21:08:27 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/abx500-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/abx500-core.c +2 -3
@@ -40,10 +40,9 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops) dev_entry =devm_kzalloc (dev,sizeof (struct abx500_device_entry ),GFP_KERNEL ); -if (!dev_entry) { -dev_err (dev,"register_ops kzalloc failed" ); +if (!dev_entry)return -ENOMEM ; - } + dev_entry->dev = dev;memcpy (&dev_entry->ops, ops,sizeof (struct abx500_ops ));
Signature · 1 line
2.15.1
PATCH 2/3 mfd/abx500-core: Improve two size determinations in abx500_register_ops()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 14 Jan 2018 21:19:10 +0100
Replace the specification of two data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/abx500-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/abx500-core.c +2 -4
@@ -37,14 +37,12 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops) {struct abx500_device_entry *dev_entry; - dev_entry =devm_kzalloc (dev, -sizeof (struct abx500_device_entry ), -GFP_KERNEL ); + dev_entry =devm_kzalloc (dev,sizeof (*dev_entry),GFP_KERNEL );if (!dev_entry)return -ENOMEM ; dev_entry->dev = dev; -memcpy (&dev_entry->ops, ops,sizeof (struct abx500_ops )); +memcpy (&dev_entry->ops, ops,sizeof (*ops));list_add_tail (&dev_entry->list, &abx500_list);return 0 ;
Signature · 1 line
2.15.1
PATCH 3/3 mfd/abx500-core: Adjust 14 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 14 Jan 2018 21:31:50 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Thus fix the affected source code places.
--- drivers/mfd/abx500-core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mfd/abx500-core.c +7 -7
@@ -65,7 +65,7 @@ int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->set_register !=NULL )) +if (ops && ops->set_register)return ops->set_register (dev, bank, reg, value);else return -ENOTSUPP ;
@@ -78,7 +78,7 @@ int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->get_register !=NULL )) +if (ops && ops->get_register)return ops->get_register (dev, bank, reg, value);else return -ENOTSUPP ;
@@ -91,7 +91,7 @@ int abx500_get_register_page_interruptible(struct device *dev, u8 bank,struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->get_register_page !=NULL )) +if (ops && ops->get_register_page)return ops->get_register_page (dev, bank, first_reg, regvals, numregs);else
@@ -105,7 +105,7 @@ int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->mask_and_set_register !=NULL )) +if (ops && ops->mask_and_set_register)return ops->mask_and_set_register (dev, bank, reg, bitmask, bitvalues);else
@@ -118,7 +118,7 @@ int abx500_get_chip_id(struct device *dev)struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->get_chip_id !=NULL )) +if (ops && ops->get_chip_id)return ops->get_chip_id (dev);else return -ENOTSUPP ;
@@ -130,7 +130,7 @@ int abx500_event_registers_startup_state_get(struct device *dev, u8 *event)struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->event_registers_startup_state_get !=NULL )) +if (ops && ops->event_registers_startup_state_get)return ops->event_registers_startup_state_get (dev, event);else return -ENOTSUPP ;
@@ -142,7 +142,7 @@ int abx500_startup_irq_enabled(struct device *dev, unsigned int irq)struct abx500_ops *ops;lookup_ops (dev->parent, &ops); -if ((ops !=NULL ) && (ops->startup_irq_enabled !=NULL )) +if (ops && ops->startup_irq_enabled)return ops->startup_irq_enabled (dev, irq);else return -ENOTSUPP ;
Signature · 1 line
2.15.1
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jan 2018 21:38:42 +0100Three update suggestions were taken into account
from static source code analysis.Markus Elfring (3):
Delete an error message for a failed memory allocationin abx500_register_ops()Improve two size determinations in
abx500_register_ops()Adjust 14 checks for null pointers
The series:
Yours,
Linus Walleij