Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1009484ybh; Tue, 10 Mar 2020 12:40:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsB8VW8sgMEbhEIyTXEv/wN4e+J7ixJWvyOzZFqSzFKVqGQ6Q6upwkUOoQ7VfKs+eXqjosg X-Received: by 2002:a9d:d04:: with SMTP id 4mr8209943oti.101.1583869238331; Tue, 10 Mar 2020 12:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583869238; cv=none; d=google.com; s=arc-20160816; b=0V8QvoEnrlVhDvdM9q9pGtjCsaBR2suHZ/CZzupox6CaRtqYNKxFen/uHfS6z5obkX +gVeBOG7EXqY03uOqadq4EoPMeCrUWODhDHFiTQXN54Zabp81ZGHem1TTeKUrnbnw6z6 /LX50wQ1LuWmrZxfZZanURt2ERi4WVjnEJrRT80rDDtgM6gdcNlg2TpuWp24g/m16F0q EgPecjf82LsUSocQdIzDZl163/AkLRyE1kB2VDcQwas9eOaFPi4WeIGtlLhW3XaKxmhJ shyus4B48rhKFCBvu68f9tWquhWp9H0KaamYR57Icp+DgEa8dOqTmijAAIP7gJDDm8Hp 7tXA== 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=glUfBls13RViCLb+lWuhwxLYsmAz3zcGgiiFChpUuDY=; b=fH0OMEB6ACmqDhtosr4P8Rz3DgUVlaJbNJCMN2vmspdBr+2dmMdb0xh1S1On6H2947 eJM409T6a+ojaD+47WToINw759P9eoVIi+EWP9SB2RvIMbCo6Gt8FGhUzbAhkPvhSK8g 33ZPZvfd92ZRdi/k+piES/FBDSr9R+8dhjBXBJDErdQUgMQVm3sX12zXITdmSQQyN5sz 0sQ/5df/rZHYIFPc1JJkzM4cBXtdMExF3bPd8A7gYzG3ZHxwANRkJOgp6sK17EpWvMHE AIbPvrdnn2C76MssoZyflDA0ZloxuFzc3d9odZx1XV5jKyIakF6ehvOg1Vw9vQdwOqDF AtkA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si8276166otc.192.2020.03.10.12.40.23; Tue, 10 Mar 2020 12:40:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727367AbgCJTjk (ORCPT + 99 others); Tue, 10 Mar 2020 15:39:40 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49968 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbgCJTjk (ORCPT ); Tue, 10 Mar 2020 15:39:40 -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 E875429141E; Tue, 10 Mar 2020 19:39:37 +0000 (GMT) Date: Tue, 10 Mar 2020 20:39:30 +0100 From: Boris Brezillon To: Mason Yang Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, frieder.schrempf@kontron.de, tglx@linutronix.de, stefan@agner.ch, juliensu@mxic.com.tw, allison@lohutok.net, linux-kernel@vger.kernel.org, bbrezillon@kernel.org, rfontana@redhat.com, linux-mtd@lists.infradead.org, yuehaibing@huawei.com, s.hauer@pengutronix.de Subject: Re: [PATCH v3 3/4] mtd: rawnand: Add support manufacturer specific suspend/resume operation Message-ID: <20200310203930.2b8c0cfb@collabora.com> In-Reply-To: <1583220084-10890-4-git-send-email-masonccyang@mxic.com.tw> References: <1583220084-10890-1-git-send-email-masonccyang@mxic.com.tw> <1583220084-10890-4-git-send-email-masonccyang@mxic.com.tw> Organization: Collabora X-Mailer: Claws Mail 3.17.5 (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 Tue, 3 Mar 2020 15:21:23 +0800 Mason Yang wrote: > Patch nand_suspend() & nand_resume() for manufacturer specific > suspend/resume operation. > > Signed-off-by: Mason Yang > Reported-by: kbuild test robot > Reviewed-by: Miquel Raynal > --- > drivers/mtd/nand/raw/nand_base.c | 11 ++++++++--- > include/linux/mtd/rawnand.h | 4 ++++ > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index 769be81..b44e460 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -4327,7 +4327,9 @@ static int nand_suspend(struct mtd_info *mtd) > struct nand_chip *chip = mtd_to_nand(mtd); > > mutex_lock(&chip->lock); > - chip->suspended = 1; > + if (chip->_suspend) > + if (!chip->_suspend(chip)) > + chip->suspended = 1; > mutex_unlock(&chip->lock); > > return 0; > @@ -4342,11 +4344,14 @@ static void nand_resume(struct mtd_info *mtd) > struct nand_chip *chip = mtd_to_nand(mtd); > > mutex_lock(&chip->lock); > - if (chip->suspended) > + if (chip->suspended) { > + if (chip->_resume) > + chip->_resume(chip); > chip->suspended = 0; > - else > + } else { > pr_err("%s called for a chip which is not in suspended state\n", > __func__); > + } > mutex_unlock(&chip->lock); > } > > diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h > index bc2fa3c..c0055ed 100644 > --- a/include/linux/mtd/rawnand.h > +++ b/include/linux/mtd/rawnand.h > @@ -1064,6 +1064,8 @@ struct nand_legacy { > * @lock: lock protecting the suspended field. Also used to > * serialize accesses to the NAND device. > * @suspended: set to 1 when the device is suspended, 0 when it's not. > + * @_suspend: [REPLACEABLE] specific NAND device suspend operation > + * @_resume: [REPLACEABLE] specific NAND device resume operation Given you added 4 more methods in this series, I think now would be a good time to introduce a nand_chip_ops struct grouping all ops together. > * @bbt: [INTERN] bad block table pointer > * @bbt_td: [REPLACEABLE] bad block table descriptor for flash > * lookup. > @@ -1119,6 +1121,8 @@ struct nand_chip { > > struct mutex lock; > unsigned int suspended : 1; > + int (*_suspend)(struct nand_chip *chip); > + void (*_resume)(struct nand_chip *chip); > > uint8_t *oob_poi; > struct nand_controller *controller;