Thomas Gleixner | 09c434b | 2019-05-19 13:08:20 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /** |
David Woodhouse | 151e7659 | 2006-05-14 01:51:54 +0100 | [diff] [blame] | 3 | * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> |
Joern Engel | 2b54aae | 2008-02-06 01:38:02 -0800 | [diff] [blame] | 4 | * Copyright (c) 2003-2004 Joern Engel <joern@wh.fh-wedel.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 6 | * Usage: |
| 7 | * |
| 8 | * one commend line parameter per device, each in the form: |
| 9 | * phram=<name>,<start>,<len> |
| 10 | * <name> may be up to 63 characters. |
| 11 | * <start> and <len> can be octal, decimal or hexadecimal. If followed |
| 12 | * by "ki", "Mi" or "Gi", the numbers will be interpreted as kilo, mega or |
| 13 | * gigabytes. |
| 14 | * |
| 15 | * Example: |
| 16 | * phram=swap,64Mi,128Mi phram=test,900Mi,1Mi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 18 | |
Joe Perches | 1cd844f | 2010-10-20 10:39:22 -0700 | [diff] [blame] | 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 20 | |
Rob Ward | b85b8d9 | 2014-10-21 20:01:09 +0100 | [diff] [blame] | 21 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/list.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/moduleparam.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 27 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/mtd/mtd.h> |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct phram_mtd_list { |
| 31 | struct mtd_info mtd; |
| 32 | struct list_head list; |
| 33 | }; |
| 34 | |
| 35 | static LIST_HEAD(phram_list); |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) |
| 38 | { |
| 39 | u_char *start = mtd->priv; |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | memset(start + instr->addr, 0xff, instr->len); |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, |
Jared Hulbert | a98889f | 2008-04-29 23:26:49 -0700 | [diff] [blame] | 47 | size_t *retlen, void **virt, resource_size_t *phys) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
Jared Hulbert | a98889f | 2008-04-29 23:26:49 -0700 | [diff] [blame] | 49 | *virt = mtd->priv + from; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | *retlen = len; |
| 51 | return 0; |
| 52 | } |
| 53 | |
Artem Bityutskiy | 5e4e6e3 | 2012-02-03 13:20:43 +0200 | [diff] [blame] | 54 | static int phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
Artem Bityutskiy | 5e4e6e3 | 2012-02-03 13:20:43 +0200 | [diff] [blame] | 56 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, |
| 60 | size_t *retlen, u_char *buf) |
| 61 | { |
| 62 | u_char *start = mtd->priv; |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | memcpy(buf, start + from, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | *retlen = len; |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | static int phram_write(struct mtd_info *mtd, loff_t to, size_t len, |
| 70 | size_t *retlen, const u_char *buf) |
| 71 | { |
| 72 | u_char *start = mtd->priv; |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | memcpy(start + to, buf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | *retlen = len; |
| 76 | return 0; |
| 77 | } |
| 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | static void unregister_devices(void) |
| 80 | { |
Joern Engel | d30f11d | 2005-02-23 19:37:11 +0000 | [diff] [blame] | 81 | struct phram_mtd_list *this, *safe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Joern Engel | d30f11d | 2005-02-23 19:37:11 +0000 | [diff] [blame] | 83 | list_for_each_entry_safe(this, safe, &phram_list, list) { |
Jamie Iles | ee0e87b | 2011-05-23 10:23:40 +0100 | [diff] [blame] | 84 | mtd_device_unregister(&this->mtd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | iounmap(this->mtd.priv); |
Mathias Krause | f17f12c | 2011-01-30 10:31:48 +0100 | [diff] [blame] | 86 | kfree(this->mtd.name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | kfree(this); |
| 88 | } |
| 89 | } |
| 90 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 91 | static int register_device(char *name, phys_addr_t start, size_t len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
| 93 | struct phram_mtd_list *new; |
| 94 | int ret = -ENOMEM; |
| 95 | |
Burman Yan | 95b93a0 | 2006-11-15 21:10:29 +0200 | [diff] [blame] | 96 | new = kzalloc(sizeof(*new), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | if (!new) |
| 98 | goto out0; |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | ret = -EIO; |
| 101 | new->mtd.priv = ioremap(start, len); |
| 102 | if (!new->mtd.priv) { |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 103 | pr_err("ioremap failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | goto out1; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | new->mtd.name = name; |
| 109 | new->mtd.size = len; |
Jörn Engel | a6c591e | 2006-04-13 18:54:34 +0200 | [diff] [blame] | 110 | new->mtd.flags = MTD_CAP_RAM; |
Artem Bityutskiy | 3c3c10b | 2012-01-30 14:58:32 +0200 | [diff] [blame] | 111 | new->mtd._erase = phram_erase; |
| 112 | new->mtd._point = phram_point; |
| 113 | new->mtd._unpoint = phram_unpoint; |
| 114 | new->mtd._read = phram_read; |
| 115 | new->mtd._write = phram_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | new->mtd.owner = THIS_MODULE; |
David Woodhouse | 21c8db9 | 2006-06-14 21:39:48 +0100 | [diff] [blame] | 117 | new->mtd.type = MTD_RAM; |
Joern Engel | 663259a | 2005-03-07 21:43:42 +0000 | [diff] [blame] | 118 | new->mtd.erasesize = PAGE_SIZE; |
Artem B. Bityutskiy | 17ffc7b | 2006-06-22 18:15:48 +0400 | [diff] [blame] | 119 | new->mtd.writesize = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | ret = -EAGAIN; |
Jamie Iles | ee0e87b | 2011-05-23 10:23:40 +0100 | [diff] [blame] | 122 | if (mtd_device_register(&new->mtd, NULL, 0)) { |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 123 | pr_err("Failed to register new device\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | goto out2; |
| 125 | } |
| 126 | |
| 127 | list_add_tail(&new->list, &phram_list); |
Thomas Gleixner | e5580fb | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 128 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | out2: |
| 131 | iounmap(new->mtd.priv); |
| 132 | out1: |
| 133 | kfree(new); |
| 134 | out0: |
| 135 | return ret; |
| 136 | } |
| 137 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 138 | static int parse_num64(uint64_t *num64, char *token) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 140 | size_t len; |
| 141 | int shift = 0; |
| 142 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 144 | len = strlen(token); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | /* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */ |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 146 | if (len > 2) { |
| 147 | if (token[len - 1] == 'i') { |
| 148 | switch (token[len - 2]) { |
| 149 | case 'G': |
| 150 | shift += 10; |
Gustavo A. R. Silva | 098d74b | 2019-02-08 12:09:11 -0600 | [diff] [blame] | 151 | /* fall through */ |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 152 | case 'M': |
| 153 | shift += 10; |
Gustavo A. R. Silva | 098d74b | 2019-02-08 12:09:11 -0600 | [diff] [blame] | 154 | /* fall through */ |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 155 | case 'k': |
| 156 | shift += 10; |
| 157 | token[len - 2] = 0; |
| 158 | break; |
| 159 | default: |
| 160 | return -EINVAL; |
| 161 | } |
| 162 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 165 | ret = kstrtou64(token, 0, num64); |
| 166 | *num64 <<= shift; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 168 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static int parse_name(char **pname, const char *token) |
| 172 | { |
| 173 | size_t len; |
| 174 | char *name; |
| 175 | |
| 176 | len = strlen(token) + 1; |
| 177 | if (len > 64) |
| 178 | return -ENOSPC; |
| 179 | |
Fabian Frederick | 89384f6 | 2014-05-28 22:31:28 +0200 | [diff] [blame] | 180 | name = kstrdup(token, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | if (!name) |
| 182 | return -ENOMEM; |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | *pname = name; |
| 185 | return 0; |
| 186 | } |
| 187 | |
Joern Engel | 663259a | 2005-03-07 21:43:42 +0000 | [diff] [blame] | 188 | |
| 189 | static inline void kill_final_newline(char *str) |
| 190 | { |
| 191 | char *newline = strrchr(str, '\n'); |
Rob Ward | c95777a | 2014-07-13 20:39:01 +0100 | [diff] [blame] | 192 | |
Joern Engel | 663259a | 2005-03-07 21:43:42 +0000 | [diff] [blame] | 193 | if (newline && !newline[1]) |
| 194 | *newline = 0; |
| 195 | } |
| 196 | |
| 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | #define parse_err(fmt, args...) do { \ |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 199 | pr_err(fmt , ## args); \ |
| 200 | return 1; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } while (0) |
| 202 | |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 203 | #ifndef MODULE |
| 204 | static int phram_init_called; |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 205 | /* |
| 206 | * This shall contain the module parameter if any. It is of the form: |
| 207 | * - phram=<device>,<address>,<size> for module case |
| 208 | * - phram.phram=<device>,<address>,<size> for built-in case |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 209 | * We leave 64 bytes for the device name, 20 for the address and 20 for the |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 210 | * size. |
| 211 | * Example: phram.phram=rootfs,0xa0000000,512Mi |
| 212 | */ |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 213 | static char phram_paramline[64 + 20 + 20]; |
| 214 | #endif |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 215 | |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 216 | static int phram_setup(const char *val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | { |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 218 | char buf[64 + 20 + 20], *str = buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | char *token[3]; |
| 220 | char *name; |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 221 | uint64_t start; |
| 222 | uint64_t len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | int i, ret; |
| 224 | |
| 225 | if (strnlen(val, sizeof(buf)) >= sizeof(buf)) |
| 226 | parse_err("parameter too long\n"); |
| 227 | |
| 228 | strcpy(str, val); |
Joern Engel | 663259a | 2005-03-07 21:43:42 +0000 | [diff] [blame] | 229 | kill_final_newline(str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Rob Ward | c95777a | 2014-07-13 20:39:01 +0100 | [diff] [blame] | 231 | for (i = 0; i < 3; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | token[i] = strsep(&str, ","); |
| 233 | |
| 234 | if (str) |
| 235 | parse_err("too many arguments\n"); |
| 236 | |
| 237 | if (!token[2]) |
| 238 | parse_err("not enough arguments\n"); |
| 239 | |
| 240 | ret = parse_name(&name, token[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | if (ret) |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 242 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 244 | ret = parse_num64(&start, token[1]); |
Jesper Juhl | 4f678a5 | 2006-05-14 01:07:18 +0200 | [diff] [blame] | 245 | if (ret) { |
| 246 | kfree(name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | parse_err("illegal start address\n"); |
Jesper Juhl | 4f678a5 | 2006-05-14 01:07:18 +0200 | [diff] [blame] | 248 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 250 | ret = parse_num64(&len, token[2]); |
Jesper Juhl | 4f678a5 | 2006-05-14 01:07:18 +0200 | [diff] [blame] | 251 | if (ret) { |
| 252 | kfree(name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | parse_err("illegal device length\n"); |
Jesper Juhl | 4f678a5 | 2006-05-14 01:07:18 +0200 | [diff] [blame] | 254 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 256 | ret = register_device(name, start, len); |
| 257 | if (!ret) |
Alexander Sverdlin | 2a46f83 | 2013-10-02 18:42:29 +0200 | [diff] [blame] | 258 | pr_info("%s device: %#llx at %#llx\n", name, len, start); |
Mathias Krause | f17f12c | 2011-01-30 10:31:48 +0100 | [diff] [blame] | 259 | else |
| 260 | kfree(name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
Mike Frysinger | 64da392 | 2009-06-16 19:20:40 +0000 | [diff] [blame] | 262 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Kees Cook | e4dca7b | 2017-10-17 19:04:42 -0700 | [diff] [blame] | 265 | static int phram_param_call(const char *val, const struct kernel_param *kp) |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 266 | { |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 267 | #ifdef MODULE |
| 268 | return phram_setup(val); |
| 269 | #else |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 270 | /* |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 271 | * If more parameters are later passed in via |
| 272 | * /sys/module/phram/parameters/phram |
| 273 | * and init_phram() has already been called, |
| 274 | * we can parse the argument now. |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 275 | */ |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 276 | |
| 277 | if (phram_init_called) |
| 278 | return phram_setup(val); |
| 279 | |
| 280 | /* |
| 281 | * During early boot stage, we only save the parameters |
| 282 | * here. We must parse them later: if the param passed |
| 283 | * from kernel boot command line, phram_param_call() is |
| 284 | * called so early that it is not possible to resolve |
| 285 | * the device (even kmalloc() fails). Defer that work to |
| 286 | * phram_setup(). |
| 287 | */ |
| 288 | |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 289 | if (strlen(val) >= sizeof(phram_paramline)) |
| 290 | return -ENOSPC; |
| 291 | strcpy(phram_paramline, val); |
| 292 | |
| 293 | return 0; |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 294 | #endif |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | module_param_call(phram, phram_param_call, NULL, NULL, 000); |
Mark Hindley | f72561cf | 2008-03-31 14:25:03 +0100 | [diff] [blame] | 298 | MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>\""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
| 300 | |
| 301 | static int __init init_phram(void) |
| 302 | { |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 303 | int ret = 0; |
Hervé Fache | b2a2a84 | 2012-03-13 16:07:53 +0100 | [diff] [blame] | 304 | |
Alexander Sverdlin | 6f6b9fe | 2013-10-14 18:52:23 +0200 | [diff] [blame] | 305 | #ifndef MODULE |
| 306 | if (phram_paramline[0]) |
| 307 | ret = phram_setup(phram_paramline); |
| 308 | phram_init_called = 1; |
| 309 | #endif |
| 310 | |
| 311 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | static void __exit cleanup_phram(void) |
| 315 | { |
| 316 | unregister_devices(); |
| 317 | } |
| 318 | |
| 319 | module_init(init_phram); |
| 320 | module_exit(cleanup_phram); |
| 321 | |
| 322 | MODULE_LICENSE("GPL"); |
Joern Engel | 2b54aae | 2008-02-06 01:38:02 -0800 | [diff] [blame] | 323 | MODULE_AUTHOR("Joern Engel <joern@wh.fh-wedel.de>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | MODULE_DESCRIPTION("MTD driver for physical RAM"); |