Skip to content

Commit 81d92dc

Browse files
committed
Merge tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd
Pull MTD fixes from Brian Norris: "Three main MTD fixes for 3.18: - A regression from 3.16 which was noticed in 3.17. With the restructuring of the m25p80.c driver and the SPI NOR library framework, we omitted proper listing of the SPI device IDs. This means m25p80.c wouldn't auto-load (modprobe) properly when built as a module. For now, we duplicate the device IDs into both modules. - The OMAP / ELM modules were depending on an implicit link ordering. Use deferred probing so that the new link order (in 3.18-rc) can still allow for successful probing. - Fix suspend/resume support for LH28F640BF NOR flash" * tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd: mtd: cfi_cmdset_0001.c: fix resume for LH28F640BF chips mtd: omap: fix mtd devices not showing up mtd: m25p80,spi-nor: Fix module aliases for m25p80 mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id mtd: m25p80: get rid of spi_get_device_id
2 parents ad2be37 + 89cf38d commit 81d92dc

File tree

6 files changed

+73
-39
lines changed

6 files changed

+73
-39
lines changed

drivers/mtd/chips/cfi_cmdset_0001.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,8 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
25902590

25912591
/* Go to known state. Chip may have been power cycled */
25922592
if (chip->state == FL_PM_SUSPENDED) {
2593+
/* Refresh LH28F640BF Partition Config. Register */
2594+
fixup_LH28F640BF(mtd);
25932595
map_write(map, CMD(0xFF), cfi->chips[i].start);
25942596
chip->oldstate = chip->state = FL_READY;
25952597
wake_up(&chip->wq);

drivers/mtd/devices/m25p80.c

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ static int m25p_probe(struct spi_device *spi)
193193
{
194194
struct mtd_part_parser_data ppdata;
195195
struct flash_platform_data *data;
196-
const struct spi_device_id *id = NULL;
197196
struct m25p *flash;
198197
struct spi_nor *nor;
199198
enum read_mode mode = SPI_NOR_NORMAL;
199+
char *flash_name = NULL;
200200
int ret;
201201

202202
data = dev_get_platdata(&spi->dev);
@@ -236,13 +236,11 @@ static int m25p_probe(struct spi_device *spi)
236236
* If that's the case, respect "type" and ignore a "name".
237237
*/
238238
if (data && data->type)
239-
id = spi_nor_match_id(data->type);
239+
flash_name = data->type;
240+
else
241+
flash_name = spi->modalias;
240242

241-
/* If we didn't get name from platform, simply use "modalias". */
242-
if (!id)
243-
id = spi_get_device_id(spi);
244-
245-
ret = spi_nor_scan(nor, id, mode);
243+
ret = spi_nor_scan(nor, flash_name, mode);
246244
if (ret)
247245
return ret;
248246

@@ -263,12 +261,62 @@ static int m25p_remove(struct spi_device *spi)
263261
}
264262

265263

264+
/*
265+
* XXX This needs to be kept in sync with spi_nor_ids. We can't share
266+
* it with spi-nor, because if this is built as a module then modpost
267+
* won't be able to read it and add appropriate aliases.
268+
*/
269+
static const struct spi_device_id m25p_ids[] = {
270+
{"at25fs010"}, {"at25fs040"}, {"at25df041a"}, {"at25df321a"},
271+
{"at25df641"}, {"at26f004"}, {"at26df081a"}, {"at26df161a"},
272+
{"at26df321"}, {"at45db081d"},
273+
{"en25f32"}, {"en25p32"}, {"en25q32b"}, {"en25p64"},
274+
{"en25q64"}, {"en25qh128"}, {"en25qh256"},
275+
{"f25l32pa"},
276+
{"mr25h256"}, {"mr25h10"},
277+
{"gd25q32"}, {"gd25q64"},
278+
{"160s33b"}, {"320s33b"}, {"640s33b"},
279+
{"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"},
280+
{"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"},
281+
{"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
282+
{"mx66l1g55g"},
283+
{"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"},
284+
{"n25q512a"}, {"n25q512ax3"}, {"n25q00"},
285+
{"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},
286+
{"s25sl032p"}, {"s25sl064p"}, {"s25fl256s0"}, {"s25fl256s1"},
287+
{"s25fl512s"}, {"s70fl01gs"}, {"s25sl12800"}, {"s25sl12801"},
288+
{"s25fl129p0"}, {"s25fl129p1"}, {"s25sl004a"}, {"s25sl008a"},
289+
{"s25sl016a"}, {"s25sl032a"}, {"s25sl064a"}, {"s25fl008k"},
290+
{"s25fl016k"}, {"s25fl064k"},
291+
{"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
292+
{"sst25vf064c"},{"sst25wf512"}, {"sst25wf010"}, {"sst25wf020"},
293+
{"sst25wf040"},
294+
{"m25p05"}, {"m25p10"}, {"m25p20"}, {"m25p40"},
295+
{"m25p80"}, {"m25p16"}, {"m25p32"}, {"m25p64"},
296+
{"m25p128"}, {"n25q032"},
297+
{"m25p05-nonjedec"}, {"m25p10-nonjedec"}, {"m25p20-nonjedec"},
298+
{"m25p40-nonjedec"}, {"m25p80-nonjedec"}, {"m25p16-nonjedec"},
299+
{"m25p32-nonjedec"}, {"m25p64-nonjedec"}, {"m25p128-nonjedec"},
300+
{"m45pe10"}, {"m45pe80"}, {"m45pe16"},
301+
{"m25pe20"}, {"m25pe80"}, {"m25pe16"},
302+
{"m25px16"}, {"m25px32"}, {"m25px32-s0"}, {"m25px32-s1"},
303+
{"m25px64"},
304+
{"w25x10"}, {"w25x20"}, {"w25x40"}, {"w25x80"},
305+
{"w25x16"}, {"w25x32"}, {"w25q32"}, {"w25q32dw"},
306+
{"w25x64"}, {"w25q64"}, {"w25q128"}, {"w25q80"},
307+
{"w25q80bl"}, {"w25q128"}, {"w25q256"}, {"cat25c11"},
308+
{"cat25c03"}, {"cat25c09"}, {"cat25c17"}, {"cat25128"},
309+
{ },
310+
};
311+
MODULE_DEVICE_TABLE(spi, m25p_ids);
312+
313+
266314
static struct spi_driver m25p80_driver = {
267315
.driver = {
268316
.name = "m25p80",
269317
.owner = THIS_MODULE,
270318
},
271-
.id_table = spi_nor_ids,
319+
.id_table = m25p_ids,
272320
.probe = m25p_probe,
273321
.remove = m25p_remove,
274322

drivers/mtd/nand/omap_elm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int elm_config(struct device *dev, enum bch_ecc bch_type,
115115

116116
if (!info) {
117117
dev_err(dev, "Unable to configure elm - device not probed?\n");
118-
return -ENODEV;
118+
return -EPROBE_DEFER;
119119
}
120120
/* ELM cannot detect ECC errors for chunks > 1KB */
121121
if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) {

drivers/mtd/spi-nor/fsl-quadspi.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
881881

882882
/* iterate the subnodes. */
883883
for_each_available_child_of_node(dev->of_node, np) {
884-
const struct spi_device_id *id;
885884
char modalias[40];
886885

887886
/* skip the holes */
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
909908
if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
910909
goto map_failed;
911910

912-
id = spi_nor_match_id(modalias);
913-
if (!id)
914-
goto map_failed;
915-
916911
ret = of_property_read_u32(np, "spi-max-frequency",
917912
&q->clk_rate);
918913
if (ret < 0)
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
921916
/* set the chip address for READID */
922917
fsl_qspi_set_base_addr(q, nor);
923918

924-
ret = spi_nor_scan(nor, id, SPI_NOR_QUAD);
919+
ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
925920
if (ret)
926921
goto map_failed;
927922

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
3030

31+
static const struct spi_device_id *spi_nor_match_id(const char *name);
32+
3133
/*
3234
* Read the status register, returning its value in the location
3335
* Return the status register value.
@@ -473,7 +475,7 @@ struct flash_info {
473475
* more nor chips. This current list focusses on newer chips, which
474476
* have been converging on command sets which including JEDEC ID.
475477
*/
476-
const struct spi_device_id spi_nor_ids[] = {
478+
static const struct spi_device_id spi_nor_ids[] = {
477479
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
478480
{ "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) },
479481
{ "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) },
@@ -637,7 +639,6 @@ const struct spi_device_id spi_nor_ids[] = {
637639
{ "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
638640
{ },
639641
};
640-
EXPORT_SYMBOL_GPL(spi_nor_ids);
641642

642643
static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
643644
{
@@ -911,9 +912,9 @@ static int spi_nor_check(struct spi_nor *nor)
911912
return 0;
912913
}
913914

914-
int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
915-
enum read_mode mode)
915+
int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
916916
{
917+
const struct spi_device_id *id = NULL;
917918
struct flash_info *info;
918919
struct device *dev = nor->dev;
919920
struct mtd_info *mtd = nor->mtd;
@@ -925,6 +926,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
925926
if (ret)
926927
return ret;
927928

929+
id = spi_nor_match_id(name);
930+
if (!id)
931+
return -ENOENT;
932+
928933
info = (void *)id->driver_data;
929934

930935
if (info->jedec_id) {
@@ -1113,7 +1118,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
11131118
}
11141119
EXPORT_SYMBOL_GPL(spi_nor_scan);
11151120

1116-
const struct spi_device_id *spi_nor_match_id(char *name)
1121+
static const struct spi_device_id *spi_nor_match_id(const char *name)
11171122
{
11181123
const struct spi_device_id *id = spi_nor_ids;
11191124

@@ -1124,7 +1129,6 @@ const struct spi_device_id *spi_nor_match_id(char *name)
11241129
}
11251130
return NULL;
11261131
}
1127-
EXPORT_SYMBOL_GPL(spi_nor_match_id);
11281132

11291133
MODULE_LICENSE("GPL");
11301134
MODULE_AUTHOR("Huang Shijie <[email protected]>");

include/linux/mtd/spi-nor.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,32 +187,17 @@ struct spi_nor {
187187
/**
188188
* spi_nor_scan() - scan the SPI NOR
189189
* @nor: the spi_nor structure
190-
* @id: the spi_device_id provided by the driver
190+
* @name: the chip type name
191191
* @mode: the read mode supported by the driver
192192
*
193193
* The drivers can use this fuction to scan the SPI NOR.
194194
* In the scanning, it will try to get all the necessary information to
195195
* fill the mtd_info{} and the spi_nor{}.
196196
*
197-
* The board may assigns a spi_device_id with @id which be used to compared with
198-
* the spi_device_id detected by the scanning.
197+
* The chip type name can be provided through the @name parameter.
199198
*
200199
* Return: 0 for success, others for failure.
201200
*/
202-
int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
203-
enum read_mode mode);
204-
extern const struct spi_device_id spi_nor_ids[];
205-
206-
/**
207-
* spi_nor_match_id() - find the spi_device_id by the name
208-
* @name: the name of the spi_device_id
209-
*
210-
* The drivers use this function to find the spi_device_id
211-
* specified by the @name.
212-
*
213-
* Return: returns the right spi_device_id pointer on success,
214-
* and returns NULL on failure.
215-
*/
216-
const struct spi_device_id *spi_nor_match_id(char *name);
201+
int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
217202

218203
#endif

0 commit comments

Comments
 (0)