mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] regmap: Adjustments for two function implementations
@ 2017-05-25 20:05 SF Markus Elfring
  2017-05-25 20:07 ` [PATCH 1/2] regmap: Delete an error message for a failed memory allocation in regmap_bulk_write() SF Markus Elfring
  2017-05-25 20:08 ` [PATCH 2/2] regmap: Adjust five checks for null pointers in __regmap_init() SF Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-25 20:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mark Brown, kernel-janitors; +Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.13.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] regmap: Delete an error message for a failed memory allocation in regmap_bulk_write()
  2017-05-25 20:05 [PATCH 0/2] regmap: Adjustments for two function implementations SF Markus Elfring
@ 2017-05-25 20:07 ` SF Markus Elfring
  2018-02-26 11:18   ` Applied "regmap: Remove unnecessary printk for failed allocation" to the regmap tree Mark Brown
  2017-05-25 20:08 ` [PATCH 2/2] regmap: Adjust five checks for null pointers in __regmap_init() SF Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-25 20:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mark Brown, kernel-janitors; +Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/regmap/regmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index b9a779a4a739..096499e1f223 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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);
 
-- 
2.13.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] regmap: Adjust five checks for null pointers in __regmap_init()
  2017-05-25 20:05 [PATCH 0/2] regmap: Adjustments for two function implementations SF Markus Elfring
  2017-05-25 20:07 ` [PATCH 1/2] regmap: Delete an error message for a failed memory allocation in regmap_bulk_write() SF Markus Elfring
@ 2017-05-25 20:08 ` SF Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-25 20:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mark Brown, kernel-janitors; +Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/base/regmap/regmap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 096499e1f223..2b1f073b72a6 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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;
 			}
-- 
2.13.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Applied "regmap: Remove unnecessary printk for failed allocation" to the regmap tree
  2017-05-25 20:07 ` [PATCH 1/2] regmap: Delete an error message for a failed memory allocation in regmap_bulk_write() SF Markus Elfring
@ 2018-02-26 11:18   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2018-02-26 11:18 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Mark Brown, Greg Kroah-Hartman, Mark Brown, kernel-janitors,
	LKML, linux-kernel

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 <ckeepax@opensource.cirrus.com>
Date: Thu, 22 Feb 2018 12:59:11 +0000
Subject: [PATCH] regmap: Remove unnecessary printk for failed allocation

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 8fe6e08fa41e..707b0450ad72 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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);
 
-- 
2.16.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-26 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-25 20:05 [PATCH 0/2] regmap: Adjustments for two function implementations SF Markus Elfring
2017-05-25 20:07 ` [PATCH 1/2] regmap: Delete an error message for a failed memory allocation in regmap_bulk_write() SF Markus Elfring
2018-02-26 11:18   ` Applied "regmap: Remove unnecessary printk for failed allocation" to the regmap tree Mark Brown
2017-05-25 20:08 ` [PATCH 2/2] regmap: Adjust five checks for null pointers in __regmap_init() SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome