Skip to contentSkip to conversation

regmap: Adjustments for two function implementations

PATCH In review SF Markus Elfring 2 participants 4 messages May 25, 2017 – Feb 26, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover regmap: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Thu, 25 May 2017 22:02:02 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation in regmap_bulk_write() Adjust five checks for null pointers in __regmap_init()

 drivers/base/regmap/regmap.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/2 regmap: Delete an error message for a failed memory allocation in regmap_bulk_write()

From: Markus Elfring <[email protected]>
Date: Thu, 25 May 2017 21:43:58 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/base/regmap/regmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/base/regmap/regmap.c +2 -3
index b9a779a4a739..096499e1f223 100644
@@ -1945,10 +1945,9 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
 			return -EINVAL;
 
 		wval = kmemdup(val, val_count * val_bytes, map->alloc_flags);
-		if (!wval) {
-			dev_err(map->dev, "Error in memory allocation\n");
+		if (!wval)
 			return -ENOMEM;
-		}
+
 		for (i = 0; i < val_count * val_bytes; i += val_bytes)
 			map->format.parse_inplace(wval + i);
 
Signature · 1 line
2.13.0
#3 lore raw

PATCH 2/2 regmap: Adjust five checks for null pointers in __regmap_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 25 May 2017 21:52:42 +0200
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/base/regmap/regmap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/base/regmap/regmap.c +5 -5
index 096499e1f223..2b1f073b72a6 100644
@@ -618,7 +618,7 @@ struct regmap *__regmap_init(struct device *dev,
 		goto err;
 
 	map = kzalloc(sizeof(*map), GFP_KERNEL);
-	if (map = NULL) {
+	if (!map) {
 		ret = -ENOMEM;
 		goto err;
 	}
@@ -918,7 +918,7 @@ struct regmap *__regmap_init(struct device *dev,
 		goto err_map;
 
 	map->work_buf = kzalloc(map->format.buf_size, GFP_KERNEL);
-	if (map->work_buf = NULL) {
+	if (!map->work_buf) {
 		ret = -ENOMEM;
 		goto err_map;
 	}
@@ -993,7 +993,7 @@ struct regmap *__regmap_init(struct device *dev,
 		}
 
 		new = kzalloc(sizeof(*new), GFP_KERNEL);
-		if (new = NULL) {
+		if (!new) {
 			ret = -ENOMEM;
 			goto err_range;
 		}
@@ -1014,10 +1014,10 @@ struct regmap *__regmap_init(struct device *dev,
 			goto err_range;
 		}
 
-		if (map->selector_work_buf = NULL) {
+		if (!map->selector_work_buf) {
 			map->selector_work_buf  				kzalloc(map->format.buf_size, GFP_KERNEL);
-			if (map->selector_work_buf = NULL) {
+			if (!map->selector_work_buf) {
 				ret = -ENOMEM;
 				goto err_range;
 			}
Signature · 1 line
2.13.0
maintainer
#2 lore raw

Applied "regmap: Remove unnecessary printk for failed allocation" to the regmap tree

In reply to SF Markus Elfring

The patch

regmap: Remove unnecessary printk for failed allocation

has been applied to the regmap tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From b4ecfec5ee3f282a4ac0876de332876fec9b488c Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Thu, 22 Feb 2018 12:59:11 +0000
Subject: [PATCH] regmap: Remove unnecessary printk for failed allocation

---
 drivers/base/regmap/regmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/base/regmap/regmap.c +2 -3
index 8fe6e08fa41e..707b0450ad72 100644
@@ -2050,10 +2050,9 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
 			return -EINVAL;
 
 		wval = kmemdup(val, val_count * val_bytes, map->alloc_flags);
-		if (!wval) {
-			dev_err(map->dev, "Error in memory allocation\n");
+		if (!wval)
 			return -ENOMEM;
-		}
+
 		for (i = 0; i < val_count * val_bytes; i += val_bytes)
 			map->format.parse_inplace(wval + i);
 
Signature · 1 line
2.16.1