Message ID | 20200325164653.112079-3-marek.vasut+renesas@gmail.com |
---|---|
State | Accepted |
Commit | 882d5f6983ff23b6f09899bb43d6dfd90ed7492f |
Delegated to: | Joe Hershberger |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Jq38viCu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48nYvf5rtlz9sPk for <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2020 03:47:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDB9181890; Wed, 25 Mar 2020 17:47:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jq38viCu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF88581850; Wed, 25 Mar 2020 17:47:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8EB8D81813 for <u-boot@lists.denx.de>; Wed, 25 Mar 2020 17:47:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x342.google.com with SMTP id d1so3529813wmb.2 for <u-boot@lists.denx.de>; Wed, 25 Mar 2020 09:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=apBIXz91MkT/0G1GbKZMj7sbmh8BKoPZXInMg5YFfpk=; b=Jq38viCu0kzbMDDsuWdl8Db0koH3jcYSRAH/PPAo8EgqIAAg4ZcwBKhr7XIZ2Uamp0 CPXf41MQCcGikuoi7xZMATiaQ0IjhwD0juH8HHD1OVBby8mEPNm0UUlYzAryIx4hG0ei UbwSq0vF7CwEHAcKLGJtd7MKFlaJOob0jDNcnA+f3/YynDKSoJqd0DgpkTnQq7YED7Uz o4cd/xdBvpfhQMrDP8c9jx0V9FR8/O1Yzfl1e2mJVsZSu54Nd7Kx1hJU2rE+eWMAzpIs PcRx7qeL9btE2I4K8MSwdpPxDB9ezCnQVxRnKu/FHmp7o/6WXvpS38OmGlHZO5/bKe6/ au3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=apBIXz91MkT/0G1GbKZMj7sbmh8BKoPZXInMg5YFfpk=; b=O6ESx7zXT6TPak/8Cm6mMzJNuVPEWCcWwUsncEZM/nBBX5QOWV4srHpPdPURBADCNZ tUO8NzyjM7DKYqO1kP3PCOBXSY/WDiwE09Lx463FwOUHeHTlgax9b2V7mVm1bi/ulSzV GnST/jjz4Bz7UA+EZ8o562YB3TQHpRNfK2a4pL35kzQw5juAcqvL9Yolb7Xzz2Dhs3F4 6AeOgrrA3RKQWxbsmDbAyYChmzNTPuQ5SsmydpljDDoeSu+TxodYyLtWuXtcxwlAbCvM SK67JqYse9fMqhXT9uDPxz2zW8Sl5vbA3NXoP/UrxW1dZQUj5+tVcWx4NnX8MI29IyIW 40eA== X-Gm-Message-State: ANhLgQ3TaFf24jWUl9U+UVJrPEXw+mtRisP3JyVZQiPm0OB6vpTrUsap M7HHi9B5AZEDDccmKHy+tWCtcCGo X-Google-Smtp-Source: ADFU+vvucQV02w8Jp5IrD2+C/JRzyNe/7q0yMiFBPB98TDvCCKLEn1V3sQFVv+KaT4vmT9UsOzUrWg== X-Received: by 2002:a1c:1b51:: with SMTP id b78mr4301326wmb.8.1585154835647; Wed, 25 Mar 2020 09:47:15 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id y7sm12631850wrq.54.2020.03.25.09.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 09:47:14 -0700 (PDT) From: Marek Vasut <marek.vasut@gmail.com> X-Google-Original-From: Marek Vasut <marek.vasut+renesas@gmail.com> To: u-boot@lists.denx.de Cc: Marek Vasut <marek.vasut+renesas@gmail.com>, Joe Hershberger <joe.hershberger@ni.com>, Masahiro Yamada <yamada.masahiro@socionext.com> Subject: [PATCH V4 02/13] net: smc911x: Replace malloc()+memset() with calloc() Date: Wed, 25 Mar 2020 17:46:42 +0100 Message-Id: <20200325164653.112079-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200325164653.112079-1-marek.vasut+renesas@gmail.com> References: <20200325164653.112079-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean |
Series |
net: smc911x: Convert to DM
|
expand
|
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 24b4eaeb3f..2c72e3469d 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -242,11 +242,9 @@ int smc911x_initialize(u8 dev_num, int base_addr) unsigned long addrl, addrh; struct eth_device *dev; - dev = malloc(sizeof(*dev)); - if (!dev) { - return -1; - } - memset(dev, 0, sizeof(*dev)); + dev = calloc(1, sizeof(*dev)); + if (!dev) + return -ENOMEM; dev->iobase = base_addr;
Replace combination of malloc()+memset() with calloc() as the behavior is exactly the same and the amount of code is reduced. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Joe Hershberger <joe.hershberger@ni.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> --- V2: - Use kzalloc() - Return -ENOMEM on alloc fail V3: - Switch back to calloc(), it's not worth pulling in all the linux-compatibility complexity V4: No change --- drivers/net/smc911x.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)