From patchwork Tue Apr 30 23:39:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 240704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7CE512C00BD for ; Wed, 1 May 2013 09:40:14 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXK9G-0001vQ-MT; Tue, 30 Apr 2013 23:39:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXK9E-0004EL-Of; Tue, 30 Apr 2013 23:39:48 +0000 Received: from mail-qe0-f53.google.com ([209.85.128.53]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXK9C-0004Dy-R7 for linux-mtd@lists.infradead.org; Tue, 30 Apr 2013 23:39:47 +0000 Received: by mail-qe0-f53.google.com with SMTP id i11so648714qej.12 for ; Tue, 30 Apr 2013 16:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to:cc :content-type; bh=rlwpgTCRlqvMq06CxAvNrato//hBI8ieWkY0hfk2TGQ=; b=qrenvo0LCOk1rvMGeWrolvvpKWZPVJ9nGiyDCWWc4DvDEBwGI+Rauj6b5yO4EcHJ7e YBzKc7elohedBjjVPGfDxwNi7iR6MZy3Ma8pXhHKrqf1ylV7M1G3jdIKz2eWcrmzPnpu W0tT0U3oSSFRnhSny+ASRv+DfS8lxA5La03zU57pso1KtnGnKP+w9XIuJ5i/29KB8qjN /OY5q0e/bsaD4kMHk4BdnwVBgYOWdl59ka+utrJcLSxwtep1KT9b7GdPrwuSM4ew+ZwA cj4V0X79EKahiZ/GW/POGYXd2o+h5fm8U//H3qS6qxxUAZscD10wPqQoBTbv7u1cQMpw Qyhw== MIME-Version: 1.0 X-Received: by 10.49.38.169 with SMTP id h9mr471659qek.54.1367365162738; Tue, 30 Apr 2013 16:39:22 -0700 (PDT) Received: by 10.49.71.112 with HTTP; Tue, 30 Apr 2013 16:39:22 -0700 (PDT) Date: Tue, 30 Apr 2013 17:39:22 -0600 Message-ID: Subject: nand_base: fix for ONFI chips that do not support GET/SET FEATURES From: David Mosberger-Tang To: David Woodhouse , Artem Bityutskiy , Brian Norris X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130430_193946_932709_B193F66E X-CRM114-Status: GOOD ( 10.68 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dmosberger[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.128.53 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: "linux-mtd@lists.infradead.org" X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The attached patch is relative to linux-mtd. It fixes a problem with NAND-chips that are ONFI-compliant but don't support the SET/GET FEATURES commands (such as Spansion S34Mx). --david diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index dfcd0a5..13c8043 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2720,7 +2720,9 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, { int status; - if (!chip->onfi_version) + if (!chip->onfi_version || + // supports GET/SET FEATURES? + !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4)) return -EINVAL; chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); @@ -2741,7 +2743,9 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip, int addr, uint8_t *subfeature_param) { - if (!chip->onfi_version) + if (!chip->onfi_version || + // supports GET/SET FEATURES? + !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4)) return -EINVAL; /* clear the sub feature parameters */