From patchwork Fri Feb 1 08:29:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10792019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25FFD746 for ; Fri, 1 Feb 2019 08:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14D3030EF0 for ; Fri, 1 Feb 2019 08:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 092A630EF3; Fri, 1 Feb 2019 08:30:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEF0930EF0 for ; Fri, 1 Feb 2019 08:30:13 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tM1caZygXFHlKFo4N6eMZ0Uiy6n9WriWJp7qMMUfvD4=; b=jZrO/dvkCWSODZ U50ifjWVGAoSkbTssbzskXJ7CHIu2G+Q4mglUHIO3l+OpY7+A4raW45NFK3EXE0vxRyyVeUVJ8bRi rvGZCLHbQWirNnLglCpuFHJb9Q/bnfEnPHhw34ziM+r5c/oGPHujCh58VeYB5+l81YIeYjsChVDrr H82UAJ2MIrQnUHElBq82typNf2RAalwJeACWQMBhHwFTZ3c9JdWOOENOHjTixS6Os3Fxfg72WpgkQ U9YJVaQkok1QmRyxZBv/nNXrUZ+4dWYDDtotw2R03PlZ9G8P44TiG7FOlwAgBMxy0aCyHw2sN9ish 8IX3tzMRPY2t+VTvwj5g==; 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 1gpUDE-0006Cx-4x; Fri, 01 Feb 2019 08:30:12 +0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUCy-0005j5-S1; Fri, 01 Feb 2019 08:29:58 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x118TIAG012377; Fri, 1 Feb 2019 08:29:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=plq37cZSpTau/SpWlOV3RG9OD/Q93HdOlf0gJx+xkPo=; b=SvZlCHlYqmFIV+kKne8Cd74CV//mtCm2LK3bgWXsZ2EoHFN9fHYMi6RBHlCsU+PWbCi3 +s1ff+Ku3kb+ycu4V4/xeUJozxkJjHfelHh3AK4LVfFh2K2VnfQy8Eew6hpDRczKT1bq gTYzq6QiyfbQ+4Elni6ndeXJMbWC9XvoM7iC2X1X1JBiKpS9q0dPFM14JNrdX+zkVFvO qTok1zu6NhS9ONlxz/ZFOA3iDXczZZjskS3fdbqnSN7iY+S845BWamuW5V4fvV4qZMY1 piPsL36ujbWhhSG+7r60NzLSerI0DXYQHpHWlmJgyCbWoHkjbzINvlbBza6ME+ak/1u/ 5g== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2q8d2enc19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 08:29:41 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x118TZIY014193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 08:29:35 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x118TX1J009720; Fri, 1 Feb 2019 08:29:34 GMT Received: from kadam (/197.157.0.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 00:29:33 -0800 Date: Fri, 1 Feb 2019 11:29:22 +0300 From: Dan Carpenter To: Liang Yang Subject: [PATCH 1/3] mtd: rawnand: meson: Fix a limit test in meson_nfc_select_chip() Message-ID: <20190201082922.GC8459@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9153 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=998 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010064 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190201_002956_988467_8CA0708E X-CRM114-Status: GOOD ( 16.61 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Richard Weinberger , kernel-janitors@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Kevin Hilman , Miquel Raynal , linux-amlogic@lists.infradead.org, Brian Norris , David Woodhouse Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This test is off by one because the > should be >= and it's also testing against the wrong limit. The MAX_CE_NUM is the maximum size that meson_chip->sels[] is allowed to be but meson_chip->nsels is the actual size. Fixes: 2d570b34b41a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller ") Signed-off-by: Dan Carpenter Acked-by: Liang Yang --- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index e858d58d97b0..94c90be7e1e0 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -225,7 +225,7 @@ static void meson_nfc_select_chip(struct nand_chip *nand, int chip) struct meson_nfc *nfc = nand_get_controller_data(nand); int ret, value; - if (chip < 0 || WARN_ON_ONCE(chip > MAX_CE_NUM)) + if (chip < 0 || WARN_ON_ONCE(chip >= meson_chip->nsels)) return; nfc->param.chip_select = meson_chip->sels[chip] ? NAND_CE1 : NAND_CE0; From patchwork Fri Feb 1 08:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10792099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91A2D746 for ; Fri, 1 Feb 2019 08:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80050316EC for ; Fri, 1 Feb 2019 08:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7398C318BE; Fri, 1 Feb 2019 08:41:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23028316EC for ; Fri, 1 Feb 2019 08:41:09 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mZBlIiaGARLWUs9XQZbt6GUsDJmk87dniUlW7iYvBJ8=; b=D68BxOs8KVKypn Gy25DYw8KZDzK2VbNUnKT5ODpj5eGzIp/VxdoMTLaO0ZnrmiYv9HBb4alX4Jh4kfsY7J5y+SHq5wo 9+p9REvDfRJ3q216quQ5jv7Sa+fCt0bIvpOdDMPfjwvskLuh1Hho7NRleSTSnCoQoRBdHReo3vGpK tn5MXuOcKEIttCnGsh9KFmYkR9jnts4pyG8uxNGGH3RMg7W6lIYOgVlheuW0qA0Gtj6+BhYas/ZxZ hywas9uQ+7PPZp1sSWu9rA3Wpv4DZ23aGWuq5NmYWvhOjjRupLGNgy2jkhE3z8mts9FLf18o/u+gh TXuPDE3L3D0mx85FFXwg==; 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 1gpUNn-00065R-IN; Fri, 01 Feb 2019 08:41:07 +0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUDd-0007Jz-9V; Fri, 01 Feb 2019 08:30:43 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x118T9OI012326; Fri, 1 Feb 2019 08:30:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=HCum4K7ZUvsoHUvCAzo1KmFyr6s8MzfLBOatROUJGak=; b=wuY/+Gn4DLdSNdyZT192+3ax0oX2zUCj4SET9UFfCubIQBfpHXX9uZO5vjq0wwTW+hVY iQNufPC6J/2R8lQTSqp+KQquayltFKXIKPjYvNOi7R3lSTQ9shqidEKDvFr44jMnC/tx 9MOPco9SgusU6ykIrnGcb5M3oSZQWFF3BVrX3Ns9+zWalnrF2J4r+XTRHGRyOlmhvTqO U+KHwF2QYVXmMoF+PL3mif7Tge1wsePUvVL57ofP4z6mVvXRoMXtxe0SsQKy2kzA/C4x ZgptqGogdEsjGCSobxY6Nv1ZIdcGrQ3zXy31Jp+TbawpB1Yec1cbLeyOrVNTlpeO9r0Q tg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2q8d2enc5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 08:30:26 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x118UKsq017133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 08:30:20 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x118UJEA015750; Fri, 1 Feb 2019 08:30:19 GMT Received: from kadam (/197.157.0.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 00:30:18 -0800 Date: Fri, 1 Feb 2019 11:30:09 +0300 From: Dan Carpenter To: Liang Yang Subject: [PATCH 2/3] mtd: rawnand: meson: fix a loop in meson_nand_bch_mode() Message-ID: <20190201083009.GD8459@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9153 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=676 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010064 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190201_003038_021302_82C5274D X-CRM114-Status: GOOD ( 18.09 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Richard Weinberger , kernel-janitors@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Kevin Hilman , Miquel Raynal , linux-amlogic@lists.infradead.org, Brian Norris , David Woodhouse Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There is a sizeof() vs ARRAY_SIZE() bug here. We want the number of elements in the array, not the number of bytes. It means we potentially read beyond the end of the array. Fixes: 2d570b34b41a ("mtd: rawnand: meson: add support for Amlogic NAND flash controller") Signed-off-by: Dan Carpenter Acked-by: Liang Yang --- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 94c90be7e1e0..0d93d0b9c1af 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -1143,7 +1143,7 @@ static int meson_nand_bch_mode(struct nand_chip *nand) if (nand->ecc.strength > 60 || nand->ecc.strength < 8) return -EINVAL; - for (i = 0; i < sizeof(meson_ecc); i++) { + for (i = 0; i < ARRAY_SIZE(meson_ecc); i++) { if (meson_ecc[i].strength == nand->ecc.strength) { meson_chip->bch_mode = meson_ecc[i].bch; return 0; From patchwork Fri Feb 1 08:30:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10792077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04702746 for ; Fri, 1 Feb 2019 08:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62A83123E for ; Fri, 1 Feb 2019 08:33:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D776431244; Fri, 1 Feb 2019 08:33:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC44F3123E for ; Fri, 1 Feb 2019 08:33:45 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lARmlrqh4rJn2Tuyw59Thxh+LOQ1J98zRiwaGDqWEe0=; b=nJ3uF0bJhq4lnu AqMev53S2lBKJiEBKy+3t/HenGX4VGc0Hy97wHmTea02jAQM0XQhfM3dAyI3nVkNCvbIN2K/wAE4L fCefS9zhckqB0AZgMaVDJWC3LOTWHvPRgQ6LdUFvowz8mfasN8LHIkGkWjUZ0c7cEzT0cYAWPZVIm PitaGCGj5t3H8G8U6bU+uJfEoukYkzOJlTc3RkTQ+rnoCUaibtN0iW+lVLSp+JE/KP2ACvVeWw+Af 7RLCEmEQaol79Sb3/3k4VlRPRqXmiFXdeeVjAT5cUcZizERDZGB43Fl/hn8tUDBHb+wKj7tv9VV2S nIMghKlF/zJTf/RQ8ETA==; 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 1gpUGe-0002Ck-M9; Fri, 01 Feb 2019 08:33:44 +0000 Received: from userp2130.oracle.com ([156.151.31.86]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUEK-00085z-VY; Fri, 01 Feb 2019 08:32:10 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x118TLxS069482; Fri, 1 Feb 2019 08:31:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=DN6YjrqGD9WGGIq5sK+IVn2gG382L07u55L+DF6Grwc=; b=d5W2pZ9G95Xw8fAa83VQmLYH6Sv9bDAnwydw70F1Onnj7JbqqruV0UtCK5kb4DqjAltI 5Vz7wvmcMcDeDQxOgWFEuRDYWgDxHjllTPyidxkpizxlLmgFo8idmalEy7LSXTqgWK4p 0RTdqNULGYnnWpj5v3X6uibt7rLp7Dx+l/LRFBvLimgzTwgOsR0iW4NgWkv8XPaad8NX PSzokeGg1oztcnGU5Pr6cTFp3p/ABJt+utYhRGCtdlVS5/9DRb9yc1ACnbomur60LUhD 0M6KGJuGTXEJn7oWiJPF53ypk1BBO0DaZbkKM8kel3eHJ5KDUeTyeebsOcqY1+PKdK+I Sg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2q8eyuw637-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 08:31:06 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x118V5vB021126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 08:31:05 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x118V5YP016104; Fri, 1 Feb 2019 08:31:05 GMT Received: from kadam (/197.157.0.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 00:31:04 -0800 Date: Fri, 1 Feb 2019 11:30:54 +0300 From: Dan Carpenter To: Liang Yang Subject: [PATCH 3/3] mtd: rawnand: meson: remove unnecessary condition in meson_nfc_select_chip() Message-ID: <20190201083053.GE8459@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9153 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010064 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190201_003122_177633_88BCC49B X-CRM114-Status: GOOD ( 15.96 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Richard Weinberger , kernel-janitors@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Kevin Hilman , Miquel Raynal , linux-amlogic@lists.infradead.org, Brian Norris , David Woodhouse Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If chip is negative then we return at the very start of the function. Removing the check lets us pull everything in one indent level. Signed-off-by: Dan Carpenter Acked-by: Liang Yang --- drivers/mtd/nand/raw/meson_nand.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 0d93d0b9c1af..105d12103ca6 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -234,23 +234,19 @@ static void meson_nfc_select_chip(struct nand_chip *nand, int chip) nfc->timing.tadl = meson_chip->tadl; nfc->timing.tbers_max = meson_chip->tbers_max; - if (chip >= 0) { - if (nfc->clk_rate != meson_chip->clk_rate) { - ret = clk_set_rate(nfc->device_clk, - meson_chip->clk_rate); - if (ret) { - dev_err(nfc->dev, "failed to set clock rate\n"); - return; - } - nfc->clk_rate = meson_chip->clk_rate; - } - if (nfc->bus_timing != meson_chip->bus_timing) { - value = (NFC_CLK_CYCLE - 1) - | (meson_chip->bus_timing << 5); - writel(value, nfc->reg_base + NFC_REG_CFG); - writel((1 << 31), nfc->reg_base + NFC_REG_CMD); - nfc->bus_timing = meson_chip->bus_timing; + if (nfc->clk_rate != meson_chip->clk_rate) { + ret = clk_set_rate(nfc->device_clk, meson_chip->clk_rate); + if (ret) { + dev_err(nfc->dev, "failed to set clock rate\n"); + return; } + nfc->clk_rate = meson_chip->clk_rate; + } + if (nfc->bus_timing != meson_chip->bus_timing) { + value = (NFC_CLK_CYCLE - 1) | (meson_chip->bus_timing << 5); + writel(value, nfc->reg_base + NFC_REG_CFG); + writel((1 << 31), nfc->reg_base + NFC_REG_CMD); + nfc->bus_timing = meson_chip->bus_timing; } }