diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2014-09-29 05:47:54 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-10-17 12:29:21 -0400 |
commit | 70f3ce0510afdad7cbaf27ab7ab961377205c782 (patch) | |
tree | 29df1a4e2259f90e0d2a1d35a7c8484688dc6253 /drivers/mtd/spi-nor | |
parent | 90e55b3812a1245bb674afcc4410ddba7db402f6 (diff) |
mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id
Drivers currently call spi_nor_match_id() and then spi_nor_scan().
This adds a dependency on struct spi_device_id which we want to
avoid. Make spi_nor_scan() do it for them.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/spi-nor')
-rw-r--r-- | drivers/mtd/spi-nor/fsl-quadspi.c | 7 | ||||
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 13 |
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 8d659a2888d5..d5269a26c839 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c | |||
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev) | |||
881 | 881 | ||
882 | /* iterate the subnodes. */ | 882 | /* iterate the subnodes. */ |
883 | for_each_available_child_of_node(dev->of_node, np) { | 883 | for_each_available_child_of_node(dev->of_node, np) { |
884 | const struct spi_device_id *id; | ||
885 | char modalias[40]; | 884 | char modalias[40]; |
886 | 885 | ||
887 | /* skip the holes */ | 886 | /* skip the holes */ |
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev) | |||
909 | if (of_modalias_node(np, modalias, sizeof(modalias)) < 0) | 908 | if (of_modalias_node(np, modalias, sizeof(modalias)) < 0) |
910 | goto map_failed; | 909 | goto map_failed; |
911 | 910 | ||
912 | id = spi_nor_match_id(modalias); | ||
913 | if (!id) | ||
914 | goto map_failed; | ||
915 | |||
916 | ret = of_property_read_u32(np, "spi-max-frequency", | 911 | ret = of_property_read_u32(np, "spi-max-frequency", |
917 | &q->clk_rate); | 912 | &q->clk_rate); |
918 | if (ret < 0) | 913 | if (ret < 0) |
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev) | |||
921 | /* set the chip address for READID */ | 916 | /* set the chip address for READID */ |
922 | fsl_qspi_set_base_addr(q, nor); | 917 | fsl_qspi_set_base_addr(q, nor); |
923 | 918 | ||
924 | ret = spi_nor_scan(nor, id, SPI_NOR_QUAD); | 919 | ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD); |
925 | if (ret) | 920 | if (ret) |
926 | goto map_failed; | 921 | goto map_failed; |
927 | 922 | ||
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index ae16aa2f6885..5c8e39977bc5 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16) | 29 | #define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16) |
30 | 30 | ||
31 | static const struct spi_device_id *spi_nor_match_id(const char *name); | ||
32 | |||
31 | /* | 33 | /* |
32 | * Read the status register, returning its value in the location | 34 | * Read the status register, returning its value in the location |
33 | * Return the status register value. | 35 | * Return the status register value. |
@@ -911,9 +913,9 @@ static int spi_nor_check(struct spi_nor *nor) | |||
911 | return 0; | 913 | return 0; |
912 | } | 914 | } |
913 | 915 | ||
914 | int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, | 916 | int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) |
915 | enum read_mode mode) | ||
916 | { | 917 | { |
918 | const struct spi_device_id *id = NULL; | ||
917 | struct flash_info *info; | 919 | struct flash_info *info; |
918 | struct device *dev = nor->dev; | 920 | struct device *dev = nor->dev; |
919 | struct mtd_info *mtd = nor->mtd; | 921 | struct mtd_info *mtd = nor->mtd; |
@@ -925,6 +927,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, | |||
925 | if (ret) | 927 | if (ret) |
926 | return ret; | 928 | return ret; |
927 | 929 | ||
930 | id = spi_nor_match_id(name); | ||
931 | if (!id) | ||
932 | return -ENOENT; | ||
933 | |||
928 | info = (void *)id->driver_data; | 934 | info = (void *)id->driver_data; |
929 | 935 | ||
930 | if (info->jedec_id) { | 936 | if (info->jedec_id) { |
@@ -1113,7 +1119,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, | |||
1113 | } | 1119 | } |
1114 | EXPORT_SYMBOL_GPL(spi_nor_scan); | 1120 | EXPORT_SYMBOL_GPL(spi_nor_scan); |
1115 | 1121 | ||
1116 | const struct spi_device_id *spi_nor_match_id(char *name) | 1122 | static const struct spi_device_id *spi_nor_match_id(const char *name) |
1117 | { | 1123 | { |
1118 | const struct spi_device_id *id = spi_nor_ids; | 1124 | const struct spi_device_id *id = spi_nor_ids; |
1119 | 1125 | ||
@@ -1124,7 +1130,6 @@ const struct spi_device_id *spi_nor_match_id(char *name) | |||
1124 | } | 1130 | } |
1125 | return NULL; | 1131 | return NULL; |
1126 | } | 1132 | } |
1127 | EXPORT_SYMBOL_GPL(spi_nor_match_id); | ||
1128 | 1133 | ||
1129 | MODULE_LICENSE("GPL"); | 1134 | MODULE_LICENSE("GPL"); |
1130 | MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>"); | 1135 | MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>"); |