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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no 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 CF045CA9EB5 for ; Mon, 21 Oct 2019 07:44:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB66F2086D for ; Mon, 21 Oct 2019 07:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727418AbfJUHom (ORCPT ); Mon, 21 Oct 2019 03:44:42 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59820 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfJUHol (ORCPT ); Mon, 21 Oct 2019 03:44:41 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 8DF67289F08; Mon, 21 Oct 2019 08:44:39 +0100 (BST) Date: Mon, 21 Oct 2019 09:44:35 +0200 From: Boris Brezillon To: masonccyang@mxic.com.tw Cc: bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, frieder.schrempf@kontron.de, gregkh@linuxfoundation.org, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marcel.ziswiler@toradex.com, marek.vasut@gmail.com, "Miquel Raynal" , richard@nod.at, tglx@linutronix.de, vigneshr@ti.com Subject: Re: [PATCH RFC 2/3] mtd: rawnand: Add support Macronix Block Protection function Message-ID: <20191021094435.78f4b16e@collabora.com> In-Reply-To: References: <1568793387-25199-1-git-send-email-masonccyang@mxic.com.tw> <1568793387-25199-2-git-send-email-masonccyang@mxic.com.tw> <20191007104511.5aa7b8f2@xps13> <20191007112442.783e4fbe@xps13> <20191008170249.06bd45ce@xps13> Organization: Collabora 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 On Mon, 21 Oct 2019 15:23:57 +0800 masonccyang@mxic.com.tw wrote: > Hi Miquel, > > > > > > > Then fill-in these two hooks from the manufacturer code, without > the > > > > > postponed init. > > > > > > > > > > > > > But in the final of nand_scan_tail(), mtd->_lock/_unlock will be > > > > filled by NULL, right ? > > > > > > The NAND core should set mtd->_lock/_unlock() to NAND specific hooks > so > > > that the MTD layer is abstracted and and drivers do not see it. Then, > > > in the NAND helper, either there is no specific hook defined by a > > > manufacturer driver and you return -ENOTSUPP, or you execute the > > > defined hook. > > > > okay, patch specific manufacturer _lock/_unlock driver > > in nand_manufacturer_init(); > > > > and in the final of nand_scan_tail() > > if (!mtd->_lock) > > mtd->_lock = NULL; > > if (!mtd->_unlock) > > mtd->_unlock = NULL; > > > I'm still considering of post_init() in nand_scan_tail() for > MTD layer default call-back function replacement because > there would be more call-back functions need it. > i.e., > MTD->_lock/_unlokc > MTD->_suspend/_resume Again, that's something that needs to be abstracted so that both the NAND manufacturer driver and the NAND controller driver can take appropriate actions on suspend/resume operations. > NTD->_point/_unpoint ->_point/_unpoint() are irrelevant for a NAND chip. > ... > > > actually, my patch series are including MTD->_locl/_unlock and > MTD->_suspend/_resume. how do you think ? Miquel was suggesting to add nand_chip->{lock,unlock,is_locked}() methods that would be implemented by the NAND manufacturer drivers, and have generic wrappers implemented in nand_base.c: static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct nand_chip *chip = mtd_to_nand(mtd); if (!chip->lock) return -ENOTSUPP; return chip->lock(chip, ofs, len); } ... If you do that, you won't need this post_init() hook. 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=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no 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 C5E19CA9EB7 for ; Mon, 21 Oct 2019 07:44:50 +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 8F90A2086D for ; Mon, 21 Oct 2019 07:44:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XaPNYU8/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F90A2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.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=1n9OQlv+wm46AGHrVRmkkd0GtSFKz9kUpaSr//mn/S8=; b=XaPNYU8/8QkIEW DyzZ8OfKFvCKtiOooe/qdM5txgXc4u+eVhA4wrrf4xLaWppaZ9IaYjAIYW7/fy4GCTLHD6cuxtcX3 oMvUkAyyc/O240W03L7nnVH+mikVwpyl8/htwo+v702fzrqCyd8iz177AntyPkBUIDXbNhTOYy/Sv R8JrJ5C3oEI7pthC3XeLygvp+CLpyD9UN965ILwycSqGCLtzCRST/+DY+P00BltWE75k0vhhBaGOV D6W4EazLAvZ9Pq9TwxgBtlEPp5gq+Wksy/GqJnmUOkrYeXK4mkZD+35S30rrXxL+CjP8vZAdUNzz0 VvyNHKl/7WgtDMFbYjvQ==; 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 1iMSMy-0008EK-1p; Mon, 21 Oct 2019 07:44:48 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMSMv-0008DX-B1 for linux-mtd@lists.infradead.org; Mon, 21 Oct 2019 07:44:46 +0000 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 8DF67289F08; Mon, 21 Oct 2019 08:44:39 +0100 (BST) Date: Mon, 21 Oct 2019 09:44:35 +0200 From: Boris Brezillon To: masonccyang@mxic.com.tw Subject: Re: [PATCH RFC 2/3] mtd: rawnand: Add support Macronix Block Protection function Message-ID: <20191021094435.78f4b16e@collabora.com> In-Reply-To: References: <1568793387-25199-1-git-send-email-masonccyang@mxic.com.tw> <1568793387-25199-2-git-send-email-masonccyang@mxic.com.tw> <20191007104511.5aa7b8f2@xps13> <20191007112442.783e4fbe@xps13> <20191008170249.06bd45ce@xps13> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_004445_508372_C299A224 X-CRM114-Status: GOOD ( 18.92 ) 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: richard@nod.at, bbrezillon@kernel.org, juliensu@mxic.com.tw, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, frieder.schrempf@kontron.de, marcel.ziswiler@toradex.com, linux-mtd@lists.infradead.org, Miquel Raynal , tglx@linutronix.de, computersforpeace@gmail.com, dwmw2@infradead.org, marek.vasut@gmail.com, vigneshr@ti.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Mon, 21 Oct 2019 15:23:57 +0800 masonccyang@mxic.com.tw wrote: > Hi Miquel, > > > > > > > Then fill-in these two hooks from the manufacturer code, without > the > > > > > postponed init. > > > > > > > > > > > > > But in the final of nand_scan_tail(), mtd->_lock/_unlock will be > > > > filled by NULL, right ? > > > > > > The NAND core should set mtd->_lock/_unlock() to NAND specific hooks > so > > > that the MTD layer is abstracted and and drivers do not see it. Then, > > > in the NAND helper, either there is no specific hook defined by a > > > manufacturer driver and you return -ENOTSUPP, or you execute the > > > defined hook. > > > > okay, patch specific manufacturer _lock/_unlock driver > > in nand_manufacturer_init(); > > > > and in the final of nand_scan_tail() > > if (!mtd->_lock) > > mtd->_lock = NULL; > > if (!mtd->_unlock) > > mtd->_unlock = NULL; > > > I'm still considering of post_init() in nand_scan_tail() for > MTD layer default call-back function replacement because > there would be more call-back functions need it. > i.e., > MTD->_lock/_unlokc > MTD->_suspend/_resume Again, that's something that needs to be abstracted so that both the NAND manufacturer driver and the NAND controller driver can take appropriate actions on suspend/resume operations. > NTD->_point/_unpoint ->_point/_unpoint() are irrelevant for a NAND chip. > ... > > > actually, my patch series are including MTD->_locl/_unlock and > MTD->_suspend/_resume. how do you think ? Miquel was suggesting to add nand_chip->{lock,unlock,is_locked}() methods that would be implemented by the NAND manufacturer drivers, and have generic wrappers implemented in nand_base.c: static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct nand_chip *chip = mtd_to_nand(mtd); if (!chip->lock) return -ENOTSUPP; return chip->lock(chip, ofs, len); } ... If you do that, you won't need this post_init() hook. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/