mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-gpio@vger.kernel.org,
	Chris Packham <chris.packham@alliedtelesis.co.nz>,
	Kalyan Kinthada <kalyan.kinthada@alliedtelesis.co.nz>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Rob Herring <robh@kernel.org>,
	Russell King <rmk+kernel@armlinux.org.uk>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] pinctrl-armada-xp: Use devm_kmalloc_array() in armada_xp_pinctrl_probe()
Date: Fri, 14 Apr 2017 18:58:25 +0200	[thread overview]
Message-ID: <d109d375-6e91-420d-eb9a-fcaea4fbc5f7@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 14 Apr 2017 18:48:15 +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_kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "nregs" which became unnecessary with
  this refactoring.

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

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c
index b854f1ee5de5..457c54c8fed3 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c
@@ -574,7 +574,6 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev)
 	struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info;
 	const struct of_device_id *match =
 		of_match_device(armada_xp_pinctrl_of_match, &pdev->dev);
-	int nregs;
 
 	if (!match)
 		return -ENODEV;
@@ -628,10 +627,11 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev)
 		break;
 	}
 
-	nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
-
-	mpp_saved_regs = devm_kmalloc(&pdev->dev, nregs * sizeof(u32),
-				      GFP_KERNEL);
+	mpp_saved_regs = devm_kmalloc_array(&pdev->dev,
+					    DIV_ROUND_UP(soc->nmodes,
+							 MVEBU_MPPS_PER_REG),
+					    sizeof(*mpp_saved_regs),
+					    GFP_KERNEL);
 	if (!mpp_saved_regs)
 		return -ENOMEM;
 
-- 
2.12.2

             reply	other threads:[~2017-04-14 16:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14 16:58 SF Markus Elfring [this message]
2017-04-21 19:22 ` Chris Packham

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=d109d375-6e91-420d-eb9a-fcaea4fbc5f7@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=kalyan.kinthada@alliedtelesis.co.nz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=ldewangan@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®