Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6064196yba; Tue, 14 May 2019 00:42:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUL1o8UlA6W6mvzy1N2kg/CevMOEAehGNb6BoNGkf2m0kkSTg5oBsTcg+lxXdiFj/bkf2d X-Received: by 2002:aa7:93bb:: with SMTP id x27mr38474842pff.104.1557819734580; Tue, 14 May 2019 00:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557819734; cv=none; d=google.com; s=arc-20160816; b=mtg6Qls+V4hU1NzL2Q2UA3AXXA7UHTlUBRw2mDuP9ndWdH8t/Sqzj+XGBVl2jozw4M SuYdlbDPl7zBBQwUy/ezao80XK2D53sfySDJ+6Z4hAjE1UQvkGZjKJLk1/7dkmOcvb2p LFjVI3kkLw0bLMwNVBuEYqItQeVTp+1ZP0FbTCCBH5JfTooQDh+2/6XunmTcHEzR83l5 f5iEewTkfajJn24tfl0kYMDxo0zTvPyYMg5nNgxbbSVzkNgfEIa4qYU3qY+Rm8N0/mA/ 9K6Pb5cBNvmIIiLdRs/JfhnMwADBr/KPXmVrX9m1XspW3h7aPjyml/NC83+K8okcHXYX 0s2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=XuFhFWlSEq2msrellZUJcgRvlaAP2u5Llrx7xoamUJ0=; b=uK1lSinxYcXMQNAAwv7Flu/XumczcSqtikM/M1slk4Y62h6ZmOf0tqKQRS03U6KX1h mYjU5qwQRwlPs+fFqTfivFM9D7BOm1NLy6gI6gm3j4f86jrRG9/7GHopimeAAxQL6HST IWQOq16qJBy8FBkFQy7fmmAi4y1yFXZxNIKnvGGiQVTPCQ2WMIqfyFSCsZnh/jGZWXqT XA2S/F3PG0esnR5YNOawiGy/KA2dRoPF5E+MbikDpUMjETHovfuw176zBNJEXv+36KnZ 3bZW+h1GSa48ZPgqKLWtZhM0tifdhOLNLC6l4MSFx436clFXDJ/HvEbCaU617kFmawJu KtAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si18869196pfi.193.2019.05.14.00.41.59; Tue, 14 May 2019 00:42:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbfENHlL (ORCPT + 99 others); Tue, 14 May 2019 03:41:11 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:35255 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfENHlL (ORCPT ); Tue, 14 May 2019 03:41:11 -0400 X-Originating-IP: 80.12.43.150 Received: from windsurf.home (unknown [80.12.43.150]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 6019D4000C; Tue, 14 May 2019 07:41:01 +0000 (UTC) Date: Tue, 14 May 2019 09:41:00 +0200 From: Thomas Petazzoni To: masonccyang@mxic.com.tw Cc: bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marek.vasut@gmail.com, miquel.raynal@bootlin.com, richard@nod.at Subject: Re: [PATCH v1] mtd: rawnand: Add Macronix NAND read retry support Message-ID: <20190514094100.34d2a6ba@windsurf.home> In-Reply-To: References: <1557474062-4949-1-git-send-email-masonccyang@mxic.com.tw> <20190510153704.33de9568@windsurf.home> <20190513114059.3934b0bb@windsurf.home> Organization: Bootlin X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, 14 May 2019 09:53:16 +0800 masonccyang@mxic.com.tw wrote: > > > ------------------------------------------------------------------- > > > static void macronix_nand_onfi_init(struct nand_chip *chip) > > > { > > > struct nand_parameters *p = &chip->parameters; > > > struct nand_onfi_vendor_macronix *mxic = (void > > > *)p->onfi->vendor; > > > > Why cast to void*, instead of casting directly to struct > > nand_onfi_vendor_macronix * ? > > Due to got a warning: > > warning: initialization from incompatible pointer type > struct nand_onfi_vendor_macronix *mxic = p->onfi->vendor; You didn't look at my code, I suggested: mxic = (struct nand_onfi_vendor_macronix *) p->info->vendor; I.e, you indeed still need a cast, because p->info->vendor is a u8[]. But instead of casting to void*, and then implicitly casting to struct nand_onfi_vendor_macronix *, I suggest to cast directly to struct nand_onfi_vendor_macronix *. > > > if (!p->onfi || > > > ((mxic->reliability_func & MACRONIX_READ_RETRY_BIT) == > 0)) > > > return; > > > > So, the code should be: > > > > struct nand_onfi_vendor_macronix *mxic; > > > > if (!p->onfi) > > return; > > > > mxic = (struct nand_onfi_vendor_macronix *) p->info->vendor; > > > > if ((mxic->reliability_func & MACRONIX_READ_RETRY_BIT) == 0) > > return; > > Also got a warning: > > warning: ISO C90 forbids mixed declarations and code > [-Wdeclaration-after-statement] No, you don't get this warning if you use my code. You get this warning if you declare and initialized the "mxic" variable at the same location. > static void macronix_nand_onfi_init(struct nand_chip *chip) > { > struct nand_parameters *p = &chip->parameters; > struct nand_onfi_vendor_macronix *mxic = (void *)p->onfi->vendor; You are dereferencing p->info... > > if (!p->onfi) > return; ... before you check it is NULL. This is wrong. Please check again the code I sent in my previous e-mail: struct nand_onfi_vendor_macronix *mxic; if (!p->onfi) return; mxic = (struct nand_onfi_vendor_macronix *) p->info->vendor; if ((mxic->reliability_func & MACRONIX_READ_RETRY_BIT) == 0) return; Best regards, Thomas Petazzoni -- Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com