All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Wolfram Sang <wsa@kernel.org>, Bartosz Golaszewski <brgl@bgdev.pl>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Andrew Davis <afd@ti.com>
Subject: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()
Date: Mon, 15 May 2023 12:50:42 -0500	[thread overview]
Message-ID: <20230515175042.495377-2-afd@ti.com> (raw)
In-Reply-To: <20230515175042.495377-1-afd@ti.com>

This reduces chance of error if the type of "dev" changes. While here
remove extra error print out, this is not usually done for memory
allocation failures.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/i2c/busses/i2c-davinci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c55bd937def7..135f76593e6f 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -767,12 +767,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
 
-	dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
-			GFP_KERNEL);
-	if (!dev) {
-		dev_err(&pdev->dev, "Memory allocation failed\n");
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+	if (!dev)
 		return -ENOMEM;
-	}
 
 	init_completion(&dev->cmd_complete);
 
-- 
2.39.2


WARNING: multiple messages have this Message-ID (diff)
From: Andrew Davis <afd@ti.com>
To: Wolfram Sang <wsa@kernel.org>, Bartosz Golaszewski <brgl@bgdev.pl>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Andrew Davis <afd@ti.com>
Subject: [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc()
Date: Mon, 15 May 2023 12:50:42 -0500	[thread overview]
Message-ID: <20230515175042.495377-2-afd@ti.com> (raw)
In-Reply-To: <20230515175042.495377-1-afd@ti.com>

This reduces chance of error if the type of "dev" changes. While here
remove extra error print out, this is not usually done for memory
allocation failures.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/i2c/busses/i2c-davinci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c55bd937def7..135f76593e6f 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -767,12 +767,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
 
-	dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
-			GFP_KERNEL);
-	if (!dev) {
-		dev_err(&pdev->dev, "Memory allocation failed\n");
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+	if (!dev)
 		return -ENOMEM;
-	}
 
 	init_completion(&dev->cmd_complete);
 
-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-05-15 19:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 17:50 [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias Andrew Davis
2023-05-15 17:50 ` Andrew Davis
2023-05-15 17:50 ` Andrew Davis [this message]
2023-05-15 17:50   ` [PATCH v2 2/2] i2c: davinci: Use struct name not type with devm_kzalloc() Andrew Davis
2023-05-16 14:45   ` Bartosz Golaszewski
2023-05-16 14:45     ` Bartosz Golaszewski
2023-06-07  9:29   ` Wolfram Sang
2023-06-07  9:29     ` Wolfram Sang
2023-06-08  9:42   ` Markus Elfring
2023-06-08 11:24     ` Wolfram Sang
2023-06-08 11:24       ` Wolfram Sang
2023-06-08 11:30       ` [v2 " Markus Elfring
2023-06-08 13:37         ` Wolfram Sang
2023-06-08 13:37           ` Wolfram Sang
2023-06-08 18:46           ` Markus Elfring
2023-05-16 14:46 ` [PATCH v2 1/2] i2c: davinci: Use platform table macro over module_alias Bartosz Golaszewski
2023-05-16 14:46   ` Bartosz Golaszewski
2023-06-07  9:32 ` Wolfram Sang
2023-06-07  9:32   ` Wolfram Sang
2023-06-23  8:27   ` Wolfram Sang
2023-06-23  8:27     ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230515175042.495377-2-afd@ti.com \
    --to=afd@ti.com \
    --cc=brgl@bgdev.pl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.