v1.5 branch refresh based upon upstream master @ c8677ca89e53e3be7988d54280fce166cc894a7e
[librecmc/librecmc.git] / target / linux / generic / pending-3.18 / 044-backport-m25p80-jedec-probe.patch
1 --- a/drivers/mtd/devices/m25p80.c
2 +++ b/drivers/mtd/devices/m25p80.c
3 @@ -310,11 +310,21 @@ static const struct spi_device_id m25p_i
4  };
5  MODULE_DEVICE_TABLE(spi, m25p_ids);
6  
7 +static const struct of_device_id m25p_of_table[] = {
8 +       /*
9 +        * Generic compatibility for SPI NOR that can be identified by the
10 +        * JEDEC READ ID opcode (0x9F). Use this, if possible.
11 +        */
12 +       { .compatible = "jedec,spi-nor" },
13 +       {}
14 +};
15 +MODULE_DEVICE_TABLE(of, m25p_of_table);
16  
17  static struct spi_driver m25p80_driver = {
18         .driver = {
19                 .name   = "m25p80",
20                 .owner  = THIS_MODULE,
21 +               .of_match_table = m25p_of_table,
22         },
23         .id_table       = m25p_ids,
24         .probe  = m25p_probe,
25 --- a/drivers/mtd/spi-nor/spi-nor.c
26 +++ b/drivers/mtd/spi-nor/spi-nor.c
27 @@ -934,8 +934,11 @@ int spi_nor_scan(struct spi_nor *nor, co
28         if (ret)
29                 return ret;
30  
31 -       id = spi_nor_match_id(name);
32 +       if (name)
33 +               id = spi_nor_match_id(name);
34         if (!id)
35 +               id = nor->read_id(nor);
36 +       if (IS_ERR_OR_NULL(id))
37                 return -ENOENT;
38  
39         info = (void *)id->driver_data;