From patchwork Wed May 30 06:36:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 922564 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DvcTXUSi"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bNrTyODX"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40wgsX0vzkz9s0q for ; Wed, 30 May 2018 16:38:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9A4AUNrHoNoFUzxoAi4kIpVkqXEjy0bhtyQKDeNZVEE=; b=DvcTXUSiRZeJQZReqRUAPpAOJc IKYHex+sbqc8fyeLCa2yTKg9vBUauAHviN5qo44EPgJTKXiwzl3jk3OuL0wLO3eHKyMIFrrlZmGj9 rGF3q0TXmoQvKCdJJdBr7duNSAGdHNqE5Y/YwmE9mI05WPWg3EjXmflfow8jTkH4g8PjG7nSnvqhh 1/Azwe+azjt5+3Zg9phW4/7bKCOYCWqUar5fa3MnNDSp7l+iSragOq2bAQn2HjtbSMNeXf02zuYc1 SEDmt0Ht2/z7eeCfczB7d3HXUR3z0GW0Bt8vFmBAAu4retv/aH8H7eLb3GHLkjI3zSY2VTJqO2edf 5AfL6HZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNukd-0006fr-VT; Wed, 30 May 2018 06:38:27 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNuj9-0005h9-A0 for lede-dev@lists.infradead.org; Wed, 30 May 2018 06:36:57 +0000 Received: by mail-pf0-x244.google.com with SMTP id q22-v6so8497522pff.11 for ; Tue, 29 May 2018 23:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=VFmlBrl2vzCE512SXyeGnM07oXesZZFs3bA8YyeBvaY=; b=bNrTyODXIr8PE6xD/R2lG+zZrZImpo2cPNhWX1BNfCopLo5R8P5c6cFPo4Vy3UoJ8h HxDDh+A6SWRp49aPquA9tsz2uR52TmXYtsBrz/BZpBbrgeHBghfg4TDGPaNjEqu5nmFa iCXCn1E4YoRXxGvKrKzOwji46m153yuAzzEmzas7nCUXXD4RM966t/oGSV02Q71yGFsu TPSpdVV88XUsc8AqWJ72Txs8nmm/zb3z2ujy7SEeZHhgjD0DULI16mtzvWzWV88HgDku nl7mcxuu4yIYAPvyj+sf1plxgzf2R5MaLSbZLqLnncp6mzBUs2owcUWiIC14LdD8siFy xnZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=VFmlBrl2vzCE512SXyeGnM07oXesZZFs3bA8YyeBvaY=; b=pYF5D+ulf3aTgh9IlZdIp1U6Bp0P1fqtJE9/ZlY2p2SAoihuGkCgH8eErAt4IO4NZt 9ZCR2Y8GWWZ64RhfR6V/sk7w6SPhoapZqGBddp4bVJ9oCgwxfbZ9Hwy5vdQGccCgMpZ8 XXYtjzpMDerfiKhqn4hXCuOofbDa1vzRDmEQOt2yThySt070/zrbqPE8ScN5sR4I5y2f 6Po3n50gkAfbcLyzNvrESwhp0eOq129IqNTkbcjOhi4gm6rY7aqx68p0iCDgLT9vxQWw rCkpzcUtVzaSuaJlATqN6TL+OXkJxrj+p+BuueBeiSaA47Lx7Wc9mD940iSPc2axzqHc CJgQ== X-Gm-Message-State: ALKqPwejKn6rd2Xlt8mLhLPXowQAWSJrMhod39JSrBr1NI3rLF83La+2 anbRlBKH6mg4el0HB3Mw/G/FPUnJ X-Google-Smtp-Source: ADUXVKIeUqQ7jwQNvxtJ7ByC07zxqaVWJbRcfC3o8j3OZzjuJNdRcl7AT7Y0+vrPsOI63JDJmMnsuw== X-Received: by 2002:a62:211c:: with SMTP id h28-v6mr1493753pfh.249.1527662204221; Tue, 29 May 2018 23:36:44 -0700 (PDT) Received: from clevo-mangix.lan (astound-69-42-5-101.ca.astound.net. [69.42.5.101]) by smtp.gmail.com with ESMTPSA id h8-v6sm44886654pgq.56.2018.05.29.23.36.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 23:36:43 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Date: Tue, 29 May 2018 23:36:36 -0700 Message-Id: <20180530063639.31017-5-rosenp@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530063639.31017-1-rosenp@gmail.com> References: <20180530063639.31017-1-rosenp@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180529_233655_372070_90672868 X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:244 listed in] [list.dnswl.org] 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Subject: [OpenWrt-Devel] [PATCH 5/8] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations and refactor function a bit X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Sergio Paracuellos Driver probe function includes an allocation using devm_kzalloc which is "hidden" a bit inside the declarations. Extract this to a better place to increase readability. Also because we are allocating zeroed memory 'memset' statement is not needed at all. Condition for checking for a valid gpio id is wrong and it should be greater or equal instead of only greater so update to be the good one. Signed-off-by: Sergio Paracuellos Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- .../ramips/files-4.14/drivers/gpio/gpio-mt7621.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/linux/ramips/files-4.14/drivers/gpio/gpio-mt7621.c b/target/linux/ramips/files-4.14/drivers/gpio/gpio-mt7621.c index 077a7c24df..bbe6cce56d 100644 --- a/target/linux/ramips/files-4.14/drivers/gpio/gpio-mt7621.c +++ b/target/linux/ramips/files-4.14/drivers/gpio/gpio-mt7621.c @@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) { struct mtk_data *gpio_data = dev_get_drvdata(&pdev->dev); const __be32 *id = of_get_property(bank, "reg", NULL); - struct mtk_gc *rg = devm_kzalloc(&pdev->dev, - sizeof(struct mtk_gc), GFP_KERNEL); + struct mtk_gc *rg; int ret; - if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK) + if (!id || be32_to_cpu(*id) >= MTK_MAX_BANK) + return -EINVAL; + + rg = devm_kzalloc(&pdev->dev, sizeof(struct mtk_gc), GFP_KERNEL); + if (!rg) return -ENOMEM; gpio_data->gc_map[be32_to_cpu(*id)] = rg; - memset(rg, 0, sizeof(struct mtk_gc)); - spin_lock_init(&rg->lock); rg->chip.parent = &pdev->dev;