Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp344726ybh; Wed, 18 Mar 2020 00:44:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuNvKTzWO1BYIFdJiY0LGlmRcLnIM6hwWm6iGvqyO4J/UUStA3up9ACg2DtPso/DYe8mDBN X-Received: by 2002:a9d:7359:: with SMTP id l25mr2869904otk.18.1584517469225; Wed, 18 Mar 2020 00:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584517469; cv=none; d=google.com; s=arc-20160816; b=N4T+n68ye4YQsj+ur9eEa7ACMrW7NxLPdjgZb4w+ho4O/tu+Ly3TPbjgXvQPbSSw0l +WLtTol2lqiBXBUnoLlfYOoH3QD7oTorn7jmVKqKj39onblq7TORuQRIlo4yf1t+XYdk JRh6UNArWFSPlTnhdgCfoQFemmy1Swhx5NbwHeFq3GRiRGO1vbM5OlZhjZmxG+DxUzT5 o+MvuJcaS6Zk9b3upcNU68lw86P3EGUWg2rVyubtdOzpmvbDx54uT6H2vl4whskjZMV9 flbocZ2JgX6sb7qBGnPYqwcoZna7TaJqKUeAjUuWCAxnb3ubER3KCLGBz2nqbmjhQlbc +6LQ== 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=oMLnjkzvE91gZ7tURxopdQ2cM2tA666bHAy9oEPMIXs=; b=dXrFtY9cba8+kg+Xgd3fzH+pWp18wNCQotZEtuCIyAruc4Kx+3JJiP8sqI+/tARzSf ksWaf983yFhLtpxXhpVA4DR96hDS3yZ39JhjkxTh0vTtx8tf7c6g8JxDtfs0G1bsmqRT smE20CRkxYW5T+XA+KrLjZ3KLw+63djAv0Msk7wXpts15LnPOm9cF+diixH2c/FlEPdK MYicQP4AIx7Touu66Iz3ry+YiY3cUqeOVmtpRSh/xgx0NRUygAgm1jPHoUQJoe4qqsRb r6Ac3p3SxduvSWShFQLQqHpuFVtTsNoGqora8U/RTzRAKEdhyI8Zg6UIHoknMPPZjZhZ RLTQ== 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 v4si3102612otp.206.2020.03.18.00.44.18; Wed, 18 Mar 2020 00:44:29 -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 S1727177AbgCRHmm (ORCPT + 99 others); Wed, 18 Mar 2020 03:42:42 -0400 Received: from twhmllg4.macronix.com ([211.75.127.132]:57380 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgCRHmm (ORCPT ); Wed, 18 Mar 2020 03:42:42 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id 02I7gTOA041137; Wed, 18 Mar 2020 15:42:30 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, bbrezillon@kernel.org Cc: frieder.schrempf@kontron.de, tglx@linutronix.de, stefan@agner.ch, juliensu@mxic.com.tw, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, allison@lohutok.net, linux-mtd@lists.infradead.org, yuehaibing@huawei.com, Mason Yang Subject: [PATCH v4 1/2] mtd: rawnand: Add support for manufacturer specific suspend/resume operation Date: Wed, 18 Mar 2020 15:42:27 +0800 Message-Id: <1584517348-14486-2-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1584517348-14486-1-git-send-email-masonccyang@mxic.com.tw> References: <1584517348-14486-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com 02I7gTOA041137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Patch nand_suspend() & nand_resume() to let manufacturers overwrite suspend/resume operations. Signed-off-by: Mason Yang Reviewed-by: Miquel Raynal --- drivers/mtd/nand/raw/nand_base.c | 17 +++++++++++++---- include/linux/mtd/rawnand.h | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index f64e3b6..bde17a3 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -4321,16 +4321,22 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) /** * nand_suspend - [MTD Interface] Suspend the NAND flash * @mtd: MTD device structure + * + * Returns 0 for success or negative error code otherwise. */ static int nand_suspend(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); + int ret = 0; mutex_lock(&chip->lock); - chip->suspended = 1; + if (chip->suspend) + ret = chip->suspend(chip); + if (!ret) + chip->suspended = 1; mutex_unlock(&chip->lock); - return 0; + return ret; } /** @@ -4342,11 +4348,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 4ab9bcc..b3dccb9 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. @@ -1117,6 +1119,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