aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/phram.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 22:31:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 22:31:43 -0500
commit82cb6acea4d10fa4080612c58deb63993f558e5a (patch)
treeba6f0b8281e37c7e1830ef2162d38d8a2bc2fbb7 /drivers/mtd/devices/phram.c
parent0d522ee7499e4abe7189b2f1728e838959b8ddde (diff)
parent885d71e5838f68d5dbee92ab952cc90ad6c1dc6b (diff)
Merge tag 'for-linus-20131112' of git://git.infradead.org/linux-mtd
Pull MTD changes from Brian Norris: - Unify some compile-time differences so that we have fewer uses of #ifdef CONFIG_OF in atmel_nand - Other general cleanups (removing unused functions, options, variables, fields; use correct interfaces) - Fix BUG() for new odd-sized NAND, which report non-power-of-2 dimensions via ONFI - Miscellaneous driver fixes (SPI NOR flash; BCM47xx NAND flash; etc.) - Improve differentiation between SLC and MLC NAND -- this clarifies an ABI issue regarding the MTD "type" (in sysfs and in the MEMGETINFO ioctl), where the MTD_MLCNANDFLASH type was present but inconsistently used - Extend GPMI NAND to support multi-chip-select NAND for some platforms - Many improvements to the OMAP2/3 NAND driver, including an expanded DT binding to bring us closer to mainline support for some OMAP systems - Fix a deadlock in the error path of the Atmel NAND driver probe - Correct the error codes from MTD mmap() to conform to POSIX and the Linux Programmer's Manual. This is an acknowledged change in the MTD ABI, but I can't imagine somebody relying on the non-standard -ENOSYS error code specifically. Am I just being unimaginative? :) - Fix a few important GPMI NAND bugs (one regression from 3.12 and one long-standing race condition) - More? Read the log! * tag 'for-linus-20131112' of git://git.infradead.org/linux-mtd: (98 commits) mtd: gpmi: fix the NULL pointer mtd: gpmi: fix kernel BUG due to racing DMA operations mtd: mtdchar: return expected errors on mmap() call mtd: gpmi: only scan two chips for imx6 mtd: gpmi: Use devm_kzalloc() mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected mtd: nand: use a local variable to simplify the nand_scan_tail mtd: nand: remove deprecated IRQF_DISABLED mtd: dataflash: Say if we find a device we don't support mtd: nand: omap: fix error return code in omap_nand_probe() mtd: nand_bbt: kill NAND_BBT_SCANALLPAGES mtd: m25p80: fixup device removal failure path mtd: mxc_nand: Include linux/of.h header mtd: remove duplicated include from mtdcore.c mtd: m25p80: add support for Macronix mx25l3255e mtd: nand: omap: remove selection of BCH ecc-scheme via KConfig mtd: nand: omap: updated devm_xx for all resource allocation and free calls mtd: nand: omap: use drivers/mtd/nand/nand_bch.c wrapper for BCH ECC instead of lib/bch.c mtd: nand: omap: clean-up ecc layout for BCH ecc schemes mtd: nand: omap2: clean-up BCHx_HW and BCHx_SW ECC configurations in device_probe ...
Diffstat (limited to 'drivers/mtd/devices/phram.c')
-rw-r--r--drivers/mtd/devices/phram.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 67823de68db6..e1f2aebaa489 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -94,7 +94,7 @@ static void unregister_devices(void)
94 } 94 }
95} 95}
96 96
97static int register_device(char *name, unsigned long start, unsigned long len) 97static int register_device(char *name, phys_addr_t start, size_t len)
98{ 98{
99 struct phram_mtd_list *new; 99 struct phram_mtd_list *new;
100 int ret = -ENOMEM; 100 int ret = -ENOMEM;
@@ -141,35 +141,35 @@ out0:
141 return ret; 141 return ret;
142} 142}
143 143
144static int ustrtoul(const char *cp, char **endp, unsigned int base) 144static int parse_num64(uint64_t *num64, char *token)
145{ 145{
146 unsigned long result = simple_strtoul(cp, endp, base); 146 size_t len;
147 147 int shift = 0;
148 switch (**endp) { 148 int ret;
149 case 'G': 149
150 result *= 1024; 150 len = strlen(token);
151 case 'M':
152 result *= 1024;
153 case 'k':
154 result *= 1024;
155 /* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */ 151 /* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
156 if ((*endp)[1] == 'i') 152 if (len > 2) {
157 (*endp) += 2; 153 if (token[len - 1] == 'i') {
154 switch (token[len - 2]) {
155 case 'G':
156 shift += 10;
157 case 'M':
158 shift += 10;
159 case 'k':
160 shift += 10;
161 token[len - 2] = 0;
162 break;
163 default:
164 return -EINVAL;
165 }
166 }
158 } 167 }
159 return result;
160}
161 168
162static int parse_num32(uint32_t *num32, const char *token) 169 ret = kstrtou64(token, 0, num64);
163{ 170 *num64 <<= shift;
164 char *endp;
165 unsigned long n;
166 171
167 n = ustrtoul(token, &endp, 0); 172 return ret;
168 if (*endp)
169 return -EINVAL;
170
171 *num32 = n;
172 return 0;
173} 173}
174 174
175static int parse_name(char **pname, const char *token) 175static int parse_name(char **pname, const char *token)
@@ -209,19 +209,19 @@ static inline void kill_final_newline(char *str)
209 * This shall contain the module parameter if any. It is of the form: 209 * This shall contain the module parameter if any. It is of the form:
210 * - phram=<device>,<address>,<size> for module case 210 * - phram=<device>,<address>,<size> for module case
211 * - phram.phram=<device>,<address>,<size> for built-in case 211 * - phram.phram=<device>,<address>,<size> for built-in case
212 * We leave 64 bytes for the device name, 12 for the address and 12 for the 212 * We leave 64 bytes for the device name, 20 for the address and 20 for the
213 * size. 213 * size.
214 * Example: phram.phram=rootfs,0xa0000000,512Mi 214 * Example: phram.phram=rootfs,0xa0000000,512Mi
215 */ 215 */
216static __initdata char phram_paramline[64+12+12]; 216static __initdata char phram_paramline[64 + 20 + 20];
217 217
218static int __init phram_setup(const char *val) 218static int __init phram_setup(const char *val)
219{ 219{
220 char buf[64+12+12], *str = buf; 220 char buf[64 + 20 + 20], *str = buf;
221 char *token[3]; 221 char *token[3];
222 char *name; 222 char *name;
223 uint32_t start; 223 uint64_t start;
224 uint32_t len; 224 uint64_t len;
225 int i, ret; 225 int i, ret;
226 226
227 if (strnlen(val, sizeof(buf)) >= sizeof(buf)) 227 if (strnlen(val, sizeof(buf)) >= sizeof(buf))
@@ -243,13 +243,13 @@ static int __init phram_setup(const char *val)
243 if (ret) 243 if (ret)
244 return ret; 244 return ret;
245 245
246 ret = parse_num32(&start, token[1]); 246 ret = parse_num64(&start, token[1]);
247 if (ret) { 247 if (ret) {
248 kfree(name); 248 kfree(name);
249 parse_err("illegal start address\n"); 249 parse_err("illegal start address\n");
250 } 250 }
251 251
252 ret = parse_num32(&len, token[2]); 252 ret = parse_num64(&len, token[2]);
253 if (ret) { 253 if (ret) {
254 kfree(name); 254 kfree(name);
255 parse_err("illegal device length\n"); 255 parse_err("illegal device length\n");
@@ -257,7 +257,7 @@ static int __init phram_setup(const char *val)
257 257
258 ret = register_device(name, start, len); 258 ret = register_device(name, start, len);
259 if (!ret) 259 if (!ret)
260 pr_info("%s device: %#x at %#x\n", name, len, start); 260 pr_info("%s device: %#llx at %#llx\n", name, len, start);
261 else 261 else
262 kfree(name); 262 kfree(name);
263 263