File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -4326,16 +4326,22 @@ static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
4326
4326
/**
4327
4327
* nand_suspend - [MTD Interface] Suspend the NAND flash
4328
4328
* @mtd: MTD device structure
4329
+ *
4330
+ * Returns 0 for success or negative error code otherwise.
4329
4331
*/
4330
4332
static int nand_suspend (struct mtd_info * mtd )
4331
4333
{
4332
4334
struct nand_chip * chip = mtd_to_nand (mtd );
4335
+ int ret = 0 ;
4333
4336
4334
4337
mutex_lock (& chip -> lock );
4335
- chip -> suspended = 1 ;
4338
+ if (chip -> suspend )
4339
+ ret = chip -> suspend (chip );
4340
+ if (!ret )
4341
+ chip -> suspended = 1 ;
4336
4342
mutex_unlock (& chip -> lock );
4337
4343
4338
- return 0 ;
4344
+ return ret ;
4339
4345
}
4340
4346
4341
4347
/**
@@ -4347,11 +4353,14 @@ static void nand_resume(struct mtd_info *mtd)
4347
4353
struct nand_chip * chip = mtd_to_nand (mtd );
4348
4354
4349
4355
mutex_lock (& chip -> lock );
4350
- if (chip -> suspended )
4356
+ if (chip -> suspended ) {
4357
+ if (chip -> resume )
4358
+ chip -> resume (chip );
4351
4359
chip -> suspended = 0 ;
4352
- else
4360
+ } else {
4353
4361
pr_err ("%s called for a chip which is not in suspended state\n" ,
4354
4362
__func__ );
4363
+ }
4355
4364
mutex_unlock (& chip -> lock );
4356
4365
}
4357
4366
Original file line number Diff line number Diff line change @@ -1064,6 +1064,8 @@ struct nand_legacy {
1064
1064
* @lock: lock protecting the suspended field. Also used to
1065
1065
* serialize accesses to the NAND device.
1066
1066
* @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
1067
1069
* @bbt: [INTERN] bad block table pointer
1068
1070
* @bbt_td: [REPLACEABLE] bad block table descriptor for flash
1069
1071
* lookup.
@@ -1119,6 +1121,8 @@ struct nand_chip {
1119
1121
1120
1122
struct mutex lock ;
1121
1123
unsigned int suspended : 1 ;
1124
+ int (* suspend )(struct nand_chip * chip );
1125
+ void (* resume )(struct nand_chip * chip );
1122
1126
1123
1127
uint8_t * oob_poi ;
1124
1128
struct nand_controller * controller ;
You can’t perform that action at this time.
0 commit comments