From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AF8FC54E4B for ; Mon, 11 May 2020 11:59:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FA1420746 for ; Mon, 11 May 2020 11:59:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K6QwQ8MH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FA1420746 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org 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:References:In-Reply-To: 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: List-Owner; bh=FjlYSq6kxbiNNGWey1cuuR+jM80/8IVJwAYWVjKhHa4=; b=K6QwQ8MH6LBqmj 6NpFl48HlVf82HPhv0as4zrUx3oKhHdXzzrNZy6BFCJMFMLiGQfHA1a9xWdFbINRDDLs0v5QkTvdY aMoBJ5w4SkfdqQqf9awdaA/O/2eRA6cDg67YM+4cdqQHG2dfjdjYsTGdUG3UIRCZaNMmVM4k2gC44 DMFjHBJDIx2aj9d9El6sHbv4K6QFMh1mv2ssI0yM3ikeOYO0Gtfe0Qrl1x6ROUehLlGoKMiPydpUb vrwmB7QXzalrLtr4qi2m0n9Shj3+N7c2nmg7IXJ4sQ6JgyVw0BPaHOL2wQP+z6ftsTNeWsShfgOkU inZAIXc0Ehum5vB0jEBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY75r-0007rU-Hd; Mon, 11 May 2020 11:59:35 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY75o-0007ZM-IC for linux-mtd@lists.infradead.org; Mon, 11 May 2020 11:59:34 +0000 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 50DF220006; Mon, 11 May 2020 11:59:28 +0000 (UTC) Date: Mon, 11 May 2020 13:59:26 +0200 From: Miquel Raynal To: Christophe Kerello Subject: Re: [PATCH v4 10/10] mtd: rawnand: stm32_fmc2: get resources from parent node Message-ID: <20200511135926.3e5c622d@xps13> In-Reply-To: <3377adc6-3e5e-b9b7-12be-c7aa44bfac82@st.com> References: <1588756279-17289-1-git-send-email-christophe.kerello@st.com> <1588756279-17289-11-git-send-email-christophe.kerello@st.com> <20200511111855.48216940@xps13> <3377adc6-3e5e-b9b7-12be-c7aa44bfac82@st.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_045932_743501_CB598C6F X-CRM114-Status: GOOD ( 16.49 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, marex@denx.de, vigneshr@ti.com, gregkh@linuxfoundation.org, richard@nod.at, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-mtd@lists.infradead.org, boris.brezillon@collabora.com, linux-stm32@st-md-mailman.stormreply.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org SGkgQ2hyaXN0b3BoZSwKCkNocmlzdG9waGUgS2VyZWxsbyA8Y2hyaXN0b3BoZS5rZXJlbGxvQHN0 LmNvbT4gd3JvdGUgb24gTW9uLCAxMSBNYXkKMjAyMCAxMjoyMTowMyArMDIwMDoKCj4gSGkgTWlx dWVsLAo+IAo+IE9uIDUvMTEvMjAgMTE6MTggQU0sIE1pcXVlbCBSYXluYWwgd3JvdGU6Cj4gPiBI aSBDaHJpc3RvcGhlLAo+ID4gCj4gPiBDaHJpc3RvcGhlIEtlcmVsbG8gPGNocmlzdG9waGUua2Vy ZWxsb0BzdC5jb20+IHdyb3RlIG9uIFdlZCwgNiBNYXkgMjAyMAo+ID4gMTE6MTE6MTkgKzAyMDA6 Cj4gPiAgIAo+ID4+IEZNQzIgRUJJIHN1cHBvcnQgaGFzIGJlZW4gYWRkZWQuIENvbW1vbiByZXNv dXJjZXMgKHJlZ2lzdGVycyBiYXNlCj4gPj4gYW5kIGNsb2NrKSBhcmUgbm93IHNoYXJlZCBiZXR3 ZWVuIHRoZSAyIGRyaXZlcnMuIEl0IG1lYW5z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wZWN0LCB0aGVuIHlvdSBjYW4gc3RvcmUgdGhlIGRldi0+b2Zfbm9kZS0+cGFy ZW50LT5kZXYgc29tZXdoZXJlIGluCnlvdXIgY29udHJvbGxlcidzIHN0cnVjdHVyZSBhbmQgdGhl biB1c2UgaXQgdG8gaW5pdGlhbGl6ZSB0aGUgY2xvY2sgYW5kCnJlZ21hcC4gVGhpcyB3YXkgeW91 IGRvbid0IGhhdmUgdG8gbW92ZSBhbnl0aGluZyBlbHNlIGluIHRoZSBwcm9iZSBwYXRoLgoKClRo YW5rcywKTWlxdcOobAoKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fCkxpbnV4IE1URCBkaXNjdXNzaW9uIG1haWxpbmcgbGlzdApodHRwOi8vbGlz dHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LW10ZC8K From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49216C54E8D for ; Mon, 11 May 2020 11:59:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29137208DB for ; Mon, 11 May 2020 11:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729905AbgEKL7c convert rfc822-to-8bit (ORCPT ); Mon, 11 May 2020 07:59:32 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:39149 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729929AbgEKL7b (ORCPT ); Mon, 11 May 2020 07:59:31 -0400 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 50DF220006; Mon, 11 May 2020 11:59:28 +0000 (UTC) Date: Mon, 11 May 2020 13:59:26 +0200 From: Miquel Raynal To: Christophe Kerello Cc: , , , , , , , , , , Subject: Re: [PATCH v4 10/10] mtd: rawnand: stm32_fmc2: get resources from parent node Message-ID: <20200511135926.3e5c622d@xps13> In-Reply-To: <3377adc6-3e5e-b9b7-12be-c7aa44bfac82@st.com> References: <1588756279-17289-1-git-send-email-christophe.kerello@st.com> <1588756279-17289-11-git-send-email-christophe.kerello@st.com> <20200511111855.48216940@xps13> <3377adc6-3e5e-b9b7-12be-c7aa44bfac82@st.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Christophe, Christophe Kerello wrote on Mon, 11 May 2020 12:21:03 +0200: > Hi Miquel, > > On 5/11/20 11:18 AM, Miquel Raynal wrote: > > Hi Christophe, > > > > Christophe Kerello wrote on Wed, 6 May 2020 > > 11:11:19 +0200: > > > >> FMC2 EBI support has been added. Common resources (registers base > >> and clock) are now shared between the 2 drivers. It means that the > >> common resources should now be found in the parent device when EBI > >> node is available. > >> > >> Signed-off-by: Christophe Kerello > >> --- > > > > [...] > > > >> + > >> +static bool stm32_fmc2_nfc_check_for_parent(struct platform_device *pdev) > >> +{ > >> + u32 i; > >> + int nb_resources = 0; > >> + > >> + /* Count the number of resources in reg property */ > >> + for (i = 0; i < pdev->num_resources; i++) { > >> + struct resource *res = &pdev->resource[i]; > >> + > >> + if (resource_type(res) == IORESOURCE_MEM) > >> + nb_resources++; > >> + } > >> + > >> + /* Each CS needs 3 resources defined (data, cmd and addr) */ > >> + if (nb_resources % 3) > >> + return false; > >> + > >> + return true; > >> +} > > > > This function looks fragile. Why not just checking the compatible > > string of the parent node? > > > > Yes, it is another way to check that we have an EBI parent node. > > In this implementation, I was checking the number of reg tuples. > In case we have 6, it means that the register base address is defined in the parent node (EBI node). > In case we have 7, it means that the register base address is defined in the current node (NFC node). Yes, I understand what you are doing, but I kind of dislike the logic. Relying on the number of reg tuples is something that can be done (I used it myself one time), but I think this is more a hack that you do when you have no other way to differentiate. I guess the proper way would be to look at the parent's compatible. If it matches what you expect, then you can store the dev->of_node->parent->dev somewhere in your controller's structure and then use it to initialize the clock and regmap. This way you don't have to move anything else in the probe path. Thanks, Miquèl