From patchwork Thu May 2 03:45:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 240890 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 E13F42C00CD for ; Thu, 2 May 2013 13:47:08 +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 1UXkTO-0004AY-1D; Thu, 02 May 2013 03:46:22 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXkTM-0000eJ-5f; Thu, 02 May 2013 03:46:20 +0000 Received: from mail-qe0-f51.google.com ([209.85.128.51]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UXkTJ-0000dv-9u for linux-mtd@lists.infradead.org; Thu, 02 May 2013 03:46:18 +0000 Received: by mail-qe0-f51.google.com with SMTP id x7so107384qeu.24 for ; Wed, 01 May 2013 20:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=XMfnHDbwFGPzHu/nwpwArI84tCLGomOYXThyxb/W5YA=; b=FUdYpLxUqf3sjqWuF8fupleP8/BNXKiHHPPHASPH/o5Jydv01eHbaullAAi9LCIfoY CTJMF1T6xQAgeB6hRaGfOLtYolENn3tc3Wj4Plqs8kZMXHuDgRMCBLUEFIsdQzeytMQC E4sb0/4/HJo7Ehjxky6qJa6OPyswyzFX0BvMP9ZFQxeXiyQECcuRcni/BNqLki+SteLB 3jyhT5pb6cY4ZHj0aJDEPy9gmtjiyMQr570L7uVS1onl1EMTjbFczf4YV8OJXA9c/kbJ ozf8SKFz88pJO5nUCdVg6i7yiHiHFYG16J2Fu9nmJPDIb+iU7HVgVZt5L+IuJviXXlSc zkYw== MIME-Version: 1.0 X-Received: by 10.224.33.148 with SMTP id h20mr6306914qad.45.1367466355878; Wed, 01 May 2013 20:45:55 -0700 (PDT) Received: by 10.49.71.112 with HTTP; Wed, 1 May 2013 20:45:55 -0700 (PDT) In-Reply-To: <5181D25C.2080001@freescale.com> References: <5181CF32.1090502@freescale.com> <5181D25C.2080001@freescale.com> Date: Wed, 1 May 2013 21:45:55 -0600 Message-ID: Subject: Re: nand_base: fix for ONFI chips that do not support GET/SET FEATURES From: David Mosberger-Tang To: Huang Shijie X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130501_234617_387110_D7315DE7 X-CRM114-Status: GOOD ( 14.26 ) 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.51 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: Artem Bityutskiy , Brian Norris , "linux-mtd@lists.infradead.org" , David Woodhouse 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 Fine by me. --david On Wed, May 1, 2013 at 8:41 PM, Huang Shijie wrote: > 于 2013年05月02日 10:34, David Mosberger-Tang 写道: >> + !(le16_to_cpu(chip->onfi_params.opt_cmd) & 4)) > it's better to add a macro to replace the hardcore '4', such as > > #define ONFI_OPT_CMD_SET_GET_FEAT (1 << 2) > > Just a suggestion. :) > > thanks > Huang Shijie > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index dfcd0a5..db31357 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2720,7 +2720,8 @@ static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, { int status; - if (!chip->onfi_version) + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) & ONFI_OPT_CMD_SET_GET_FEATURES)) return -EINVAL; chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); @@ -2741,7 +2742,8 @@ 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 || + !(le16_to_cpu(chip->onfi_params.opt_cmd) & ONFI_OPT_CMD_SET_GET_FEATURES)) return -EINVAL; /* clear the sub feature parameters */ diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index ab63634..9b98af8 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -217,6 +217,9 @@ struct nand_chip; /* ONFI subfeature parameters length */ #define ONFI_SUBFEATURE_PARAM_LEN 4 +/* ONFI optional commands SET/GET FEATURES supported? */ +#define ONFI_OPT_CMD_SET_GET_FEATURES (1 << 2) + struct nand_onfi_params { /* rev info and features block */ /* 'O' 'N' 'F' 'I' */