mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] net: phy: Use xzalloc for small allocations
Date: Thu, 18 Sep 2014 09:11:13 +0200	[thread overview]
Message-ID: <1411024275-31766-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1411024275-31766-1-git-send-email-s.hauer@pengutronix.de>

No need to call kzalloc for small allocations, xzalloc will do without
the need for an additional check.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/phy/phy.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7604e1d..7813c49 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -86,9 +86,7 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
 {
 	struct phy_fixup *fixup;
 
-	fixup = kzalloc(sizeof(struct phy_fixup), GFP_KERNEL);
-	if (!fixup)
-		return -ENOMEM;
+	fixup = xzalloc(sizeof(struct phy_fixup));
 
 	strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
 	fixup->phy_uid = phy_uid;
@@ -157,10 +155,7 @@ static struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int p
 
 	/* We allocate the device, and initialize the
 	 * default values */
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-
-	if (NULL == dev)
-		return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
+	dev = xzalloc(sizeof(*dev));
 
 	dev->speed = 0;
 	dev->duplex = -1;
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-09-18  7:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18  7:11 net: phy updates Sascha Hauer
2014-09-18  7:11 ` [PATCH 1/4] net: phy: introduce phy_aneg_done Sascha Hauer
2014-09-18  7:11 ` Sascha Hauer [this message]
2014-09-18  7:11 ` [PATCH 3/4] net: phy: don't use 'dev' as name for variables of type struct phy_device Sascha Hauer
2014-09-18  7:11 ` [PATCH 4/4] net: phy: Use poller for periodic link check Sascha Hauer
2014-09-24  5:09   ` Sascha Hauer

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=1411024275-31766-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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