Skip to content

Commit adc6162

Browse files
Mason Yangmiquelraynal
authored andcommitted
mtd: rawnand: Add support for manufacturer specific suspend/resume operation
Patch nand_suspend() & nand_resume() to let manufacturers overwrite suspend/resume operations. Signed-off-by: Mason Yang <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 9f9ae0c commit adc6162

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,16 +4326,22 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
43264326
/**
43274327
* nand_suspend - [MTD Interface] Suspend the NAND flash
43284328
* @mtd: MTD device structure
4329+
*
4330+
* Returns 0 for success or negative error code otherwise.
43294331
*/
43304332
static int nand_suspend(struct mtd_info *mtd)
43314333
{
43324334
struct nand_chip *chip = mtd_to_nand(mtd);
4335+
int ret = 0;
43334336

43344337
mutex_lock(&chip->lock);
4335-
chip->suspended = 1;
4338+
if (chip->suspend)
4339+
ret = chip->suspend(chip);
4340+
if (!ret)
4341+
chip->suspended = 1;
43364342
mutex_unlock(&chip->lock);
43374343

4338-
return 0;
4344+
return ret;
43394345
}
43404346

43414347
/**
@@ -4347,11 +4353,14 @@ static void nand_resume(struct mtd_info *mtd)
43474353
struct nand_chip *chip = mtd_to_nand(mtd);
43484354

43494355
mutex_lock(&chip->lock);
4350-
if (chip->suspended)
4356+
if (chip->suspended) {
4357+
if (chip->resume)
4358+
chip->resume(chip);
43514359
chip->suspended = 0;
4352-
else
4360+
} else {
43534361
pr_err("%s called for a chip which is not in suspended state\n",
43544362
__func__);
4363+
}
43554364
mutex_unlock(&chip->lock);
43564365
}
43574366

include/linux/mtd/rawnand.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,8 @@ struct nand_legacy {
10641064
* @lock: lock protecting the suspended field. Also used to
10651065
* serialize accesses to the NAND device.
10661066
* @suspended: set to 1 when the device is suspended, 0 when it's not.
1067+
* @suspend: [REPLACEABLE] specific NAND device suspend operation
1068+
* @resume: [REPLACEABLE] specific NAND device resume operation
10671069
* @bbt: [INTERN] bad block table pointer
10681070
* @bbt_td: [REPLACEABLE] bad block table descriptor for flash
10691071
* lookup.
@@ -1119,6 +1121,8 @@ struct nand_chip {
11191121

11201122
struct mutex lock;
11211123
unsigned int suspended : 1;
1124+
int (*suspend)(struct nand_chip *chip);
1125+
void (*resume)(struct nand_chip *chip);
11221126

11231127
uint8_t *oob_poi;
11241128
struct nand_controller *controller;

0 commit comments

Comments
 (0)