Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3114650ybf; Mon, 2 Mar 2020 23:22:27 -0800 (PST) X-Google-Smtp-Source: ADFU+vtKtfbFWdnpeUbCMCjPN5L7FYhREuzlxQ5k1UXpbJ87tmP9gxYXvQ9PHmMAVv4LxMUolMwM X-Received: by 2002:a05:6830:147:: with SMTP id j7mr2398264otp.12.1583220146939; Mon, 02 Mar 2020 23:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583220146; cv=none; d=google.com; s=arc-20160816; b=VJ1SICQ7VjNP161cNhhxxu2UE7O2ihGK2kRMB9YUwBKaSetHpGWpJndbKhhWdtnck6 eiIpAX/CFo7ZK7PUPhFpzucKUvV8p/976GlazWRZ1vF6T2X1b8tAZ1a4fysop0XHvzug EJ912fkXAj/pTn+HEiO2SrWvcxaH5XVu/nTQ73XCY2DqBKRH3zY5ojoIVj1hisMygidk PeJC4WTGuJBp0wWBJbITqzkVAwdhlLQwO2a5jo79yfTYzjwva9B1LNcb+up+XJW7lStc zT3p0n/AqR0PfZuDnOA+yb/jOK9zod0+8W9ucJmky6hIVvcnna+JiIwFFsoI2+v5cHzh 64yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Js3kzwZW8hp8795stMSfQG8h/WlsbIdbmqKAkYVDL24=; b=PYfnYX7Wi3KCTR7PXWJDSnuI2emSWlPMqQnn2dpwYo9KDtrgszv+omAomeaTQlt2T4 opdmaSPr8xmCK9wwUpH3IUxlgGcY/+11hT+pbo/5vF+LP1hnwjuZN5KDVxxttjQoSg/b hiENg7KqlwDyFXuix4AVWN1WH0ZCrIODXo7JgmRYSFgw4G/FnNi8Y6RPsPoaLp9Cyu58 DEY7jo1w2Dx9xWxROrFQBPd6uMCOpWSfOaLJ9TM0Ofef/9yzqFvS3uxpAffYIQAZLcuJ 1HaCdLtitNivqauUty1DNqpzb5gHQ804etpizWvP00douHq2MtRI5AjHwI1UW9YohlOI 26ng== 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 l13si209894oil.161.2020.03.02.23.22.15; Mon, 02 Mar 2020 23:22:26 -0800 (PST) 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 S1727635AbgCCHV4 (ORCPT + 99 others); Tue, 3 Mar 2020 02:21:56 -0500 Received: from twhmllg3.macronix.com ([211.75.127.131]:31770 "EHLO TWHMLLG3.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbgCCHVx (ORCPT ); Tue, 3 Mar 2020 02:21:53 -0500 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG3.macronix.com with ESMTP id 0237LRLC023026; Tue, 3 Mar 2020 15:21:31 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: 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, Mason Yang Subject: [PATCH v3 3/4] mtd: rawnand: Add support manufacturer specific suspend/resume operation Date: Tue, 3 Mar 2020 15:21:23 +0800 Message-Id: <1583220084-10890-4-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1583220084-10890-1-git-send-email-masonccyang@mxic.com.tw> References: <1583220084-10890-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG3.macronix.com 0237LRLC023026 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 * @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; -- 1.9.1