Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> |
| 3 | * Horst Hummel <Horst.Hummel@de.ibm.com> |
| 4 | * Carsten Otte <Cotte@de.ibm.com> |
| 5 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 6 | * Bugreports.to..: <Linux390@de.ibm.com> |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 7 | * Copyright IBM Corp. 1999,2001 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * Device mapping and dasd= parameter parsing functions. All devmap |
| 10 | * functions may not be called from interrupt context. In particular |
| 11 | * dasd_get_device is a no-no from interrupt context. |
| 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 15 | #define KMSG_COMPONENT "dasd" |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/ctype.h> |
| 18 | #include <linux/init.h> |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 19 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 20 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | #include <asm/debug.h> |
| 23 | #include <asm/uaccess.h> |
Peter Oberparleiter | 7039d3a | 2007-04-27 16:01:48 +0200 | [diff] [blame] | 24 | #include <asm/ipl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | /* This is ugly... */ |
| 27 | #define PRINTK_HEADER "dasd_devmap:" |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 28 | #define DASD_BUS_ID_SIZE 20 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | #include "dasd_int.h" |
| 31 | |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 32 | struct kmem_cache *dasd_page_cache; |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 33 | EXPORT_SYMBOL_GPL(dasd_page_cache); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * dasd_devmap_t is used to store the features and the relation |
| 37 | * between device number and device index. To find a dasd_devmap_t |
| 38 | * that corresponds to a device number of a device index each |
| 39 | * dasd_devmap_t is added to two linked lists, one to search by |
| 40 | * the device number and one to search by the device index. As |
| 41 | * soon as big minor numbers are available the device index list |
| 42 | * can be removed since the device number will then be identical |
| 43 | * to the device index. |
| 44 | */ |
| 45 | struct dasd_devmap { |
| 46 | struct list_head list; |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 47 | char bus_id[DASD_BUS_ID_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | unsigned int devindex; |
| 49 | unsigned short features; |
| 50 | struct dasd_device *device; |
| 51 | }; |
| 52 | |
| 53 | /* |
| 54 | * Parameter parsing functions for dasd= parameter. The syntax is: |
| 55 | * <devno> : (0x)?[0-9a-fA-F]+ |
| 56 | * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+ |
| 57 | * <feature> : ro |
| 58 | * <feature_list> : \(<feature>(:<feature>)*\) |
| 59 | * <devno-range> : <devno>(-<devno>)?<feature_list>? |
| 60 | * <busid-range> : <busid>(-<busid>)?<feature_list>? |
| 61 | * <devices> : <devno-range>|<busid-range> |
| 62 | * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod |
| 63 | * |
| 64 | * <dasd> : autodetect|probeonly|<devices>(,<devices>)* |
| 65 | */ |
| 66 | |
| 67 | int dasd_probeonly = 0; /* is true, when probeonly mode is active */ |
| 68 | int dasd_autodetect = 0; /* is true, when autodetection is active */ |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 69 | int dasd_nopav = 0; /* is true, when PAV is disabled */ |
| 70 | EXPORT_SYMBOL_GPL(dasd_nopav); |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 71 | int dasd_nofcx; /* disable High Performance Ficon */ |
| 72 | EXPORT_SYMBOL_GPL(dasd_nofcx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * char *dasd[] is intended to hold the ranges supplied by the dasd= statement |
| 76 | * it is named 'dasd' to directly be filled by insmod with the comma separated |
| 77 | * strings when running as a module. |
| 78 | */ |
| 79 | static char *dasd[256]; |
Peter Oberparleiter | 3b12693 | 2014-08-20 15:35:44 +0200 | [diff] [blame] | 80 | module_param_array(dasd, charp, NULL, S_IRUGO); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | /* |
Horst Hummel | d0710c7 | 2006-08-10 15:45:16 +0200 | [diff] [blame] | 83 | * Single spinlock to protect devmap and servermap structures and lists. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | */ |
| 85 | static DEFINE_SPINLOCK(dasd_devmap_lock); |
| 86 | |
| 87 | /* |
| 88 | * Hash lists for devmap structures. |
| 89 | */ |
| 90 | static struct list_head dasd_hashlists[256]; |
| 91 | int dasd_max_devindex; |
| 92 | |
Cornelia Huck | 69f90f6 | 2008-05-15 16:52:34 +0200 | [diff] [blame] | 93 | static struct dasd_devmap *dasd_add_busid(const char *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | static inline int |
Cornelia Huck | 69f90f6 | 2008-05-15 16:52:34 +0200 | [diff] [blame] | 96 | dasd_hash_busid(const char *bus_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
| 98 | int hash, i; |
| 99 | |
| 100 | hash = 0; |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 101 | for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | hash += *bus_id; |
| 103 | return hash & 0xff; |
| 104 | } |
| 105 | |
| 106 | #ifndef MODULE |
| 107 | /* |
| 108 | * The parameter parsing functions for builtin-drivers are called |
| 109 | * before kmalloc works. Store the pointers to the parameters strings |
| 110 | * into dasd[] for later processing. |
| 111 | */ |
| 112 | static int __init |
| 113 | dasd_call_setup(char *str) |
| 114 | { |
| 115 | static int count = 0; |
| 116 | |
| 117 | if (count < 256) |
| 118 | dasd[count++] = str; |
| 119 | return 1; |
| 120 | } |
| 121 | |
| 122 | __setup ("dasd=", dasd_call_setup); |
| 123 | #endif /* #ifndef MODULE */ |
| 124 | |
Peter Oberparleiter | 7039d3a | 2007-04-27 16:01:48 +0200 | [diff] [blame] | 125 | #define DASD_IPLDEV "ipldev" |
| 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | /* |
| 128 | * Read a device busid/devno from a string. |
| 129 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 130 | static int |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | dasd_busid(char **str, int *id0, int *id1, int *devno) |
| 133 | { |
| 134 | int val, old_style; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 135 | |
Peter Oberparleiter | 7039d3a | 2007-04-27 16:01:48 +0200 | [diff] [blame] | 136 | /* Interpret ipldev busid */ |
| 137 | if (strncmp(DASD_IPLDEV, *str, strlen(DASD_IPLDEV)) == 0) { |
| 138 | if (ipl_info.type != IPL_TYPE_CCW) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 139 | pr_err("The IPL device is not a CCW device\n"); |
Peter Oberparleiter | 7039d3a | 2007-04-27 16:01:48 +0200 | [diff] [blame] | 140 | return -EINVAL; |
| 141 | } |
| 142 | *id0 = 0; |
| 143 | *id1 = ipl_info.data.ccw.dev_id.ssid; |
| 144 | *devno = ipl_info.data.ccw.dev_id.devno; |
| 145 | *str += strlen(DASD_IPLDEV); |
| 146 | |
| 147 | return 0; |
| 148 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | /* check for leading '0x' */ |
| 150 | old_style = 0; |
| 151 | if ((*str)[0] == '0' && (*str)[1] == 'x') { |
| 152 | *str += 2; |
| 153 | old_style = 1; |
| 154 | } |
| 155 | if (!isxdigit((*str)[0])) /* We require at least one hex digit */ |
| 156 | return -EINVAL; |
| 157 | val = simple_strtoul(*str, str, 16); |
| 158 | if (old_style || (*str)[0] != '.') { |
| 159 | *id0 = *id1 = 0; |
| 160 | if (val < 0 || val > 0xffff) |
| 161 | return -EINVAL; |
| 162 | *devno = val; |
| 163 | return 0; |
| 164 | } |
| 165 | /* New style x.y.z busid */ |
| 166 | if (val < 0 || val > 0xff) |
| 167 | return -EINVAL; |
| 168 | *id0 = val; |
| 169 | (*str)++; |
| 170 | if (!isxdigit((*str)[0])) /* We require at least one hex digit */ |
| 171 | return -EINVAL; |
| 172 | val = simple_strtoul(*str, str, 16); |
| 173 | if (val < 0 || val > 0xff || (*str)++[0] != '.') |
| 174 | return -EINVAL; |
| 175 | *id1 = val; |
| 176 | if (!isxdigit((*str)[0])) /* We require at least one hex digit */ |
| 177 | return -EINVAL; |
| 178 | val = simple_strtoul(*str, str, 16); |
| 179 | if (val < 0 || val > 0xffff) |
| 180 | return -EINVAL; |
| 181 | *devno = val; |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Read colon separated list of dasd features. Currently there is |
| 187 | * only one: "ro" for read-only devices. The default feature set |
| 188 | * is empty (value 0). |
| 189 | */ |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 190 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | dasd_feature_list(char *str, char **endp) |
| 192 | { |
| 193 | int features, len, rc; |
| 194 | |
| 195 | rc = 0; |
| 196 | if (*str != '(') { |
| 197 | *endp = str; |
| 198 | return DASD_FEATURE_DEFAULT; |
| 199 | } |
| 200 | str++; |
| 201 | features = 0; |
| 202 | |
| 203 | while (1) { |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 204 | for (len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | str[len] && str[len] != ':' && str[len] != ')'; len++); |
| 206 | if (len == 2 && !strncmp(str, "ro", 2)) |
| 207 | features |= DASD_FEATURE_READONLY; |
| 208 | else if (len == 4 && !strncmp(str, "diag", 4)) |
| 209 | features |= DASD_FEATURE_USEDIAG; |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 210 | else if (len == 3 && !strncmp(str, "raw", 3)) |
| 211 | features |= DASD_FEATURE_USERAW; |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 212 | else if (len == 6 && !strncmp(str, "erplog", 6)) |
| 213 | features |= DASD_FEATURE_ERPLOG; |
Holger Smolinski | 13de227 | 2009-01-09 12:14:51 +0100 | [diff] [blame] | 214 | else if (len == 8 && !strncmp(str, "failfast", 8)) |
| 215 | features |= DASD_FEATURE_FAILFAST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | else { |
Joe Perches | baebc70 | 2016-03-03 20:49:57 -0800 | [diff] [blame^] | 217 | pr_warn("%*s is not a supported device option\n", |
| 218 | len, str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | rc = -EINVAL; |
| 220 | } |
| 221 | str += len; |
| 222 | if (*str != ':') |
| 223 | break; |
| 224 | str++; |
| 225 | } |
| 226 | if (*str != ')') { |
Joe Perches | baebc70 | 2016-03-03 20:49:57 -0800 | [diff] [blame^] | 227 | pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | rc = -EINVAL; |
| 229 | } else |
| 230 | str++; |
| 231 | *endp = str; |
| 232 | if (rc != 0) |
| 233 | return rc; |
| 234 | return features; |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | * Try to match the first element on the comma separated parse string |
| 239 | * with one of the known keywords. If a keyword is found, take the approprate |
| 240 | * action and return a pointer to the residual string. If the first element |
| 241 | * could not be matched to any keyword then return an error code. |
| 242 | */ |
| 243 | static char * |
| 244 | dasd_parse_keyword( char *parsestring ) { |
| 245 | |
| 246 | char *nextcomma, *residual_str; |
| 247 | int length; |
| 248 | |
| 249 | nextcomma = strchr(parsestring,','); |
| 250 | if (nextcomma) { |
| 251 | length = nextcomma - parsestring; |
| 252 | residual_str = nextcomma + 1; |
| 253 | } else { |
| 254 | length = strlen(parsestring); |
| 255 | residual_str = parsestring + length; |
| 256 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 257 | if (strncmp("autodetect", parsestring, length) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | dasd_autodetect = 1; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 259 | pr_info("The autodetection mode has been activated\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | return residual_str; |
| 261 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 262 | if (strncmp("probeonly", parsestring, length) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | dasd_probeonly = 1; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 264 | pr_info("The probeonly mode has been activated\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | return residual_str; |
| 266 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 267 | if (strncmp("nopav", parsestring, length) == 0) { |
Peter Oberparleiter | dcd707b | 2006-09-20 15:59:52 +0200 | [diff] [blame] | 268 | if (MACHINE_IS_VM) |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 269 | pr_info("'nopav' is not supported on z/VM\n"); |
Peter Oberparleiter | dcd707b | 2006-09-20 15:59:52 +0200 | [diff] [blame] | 270 | else { |
| 271 | dasd_nopav = 1; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 272 | pr_info("PAV support has be deactivated\n"); |
Peter Oberparleiter | dcd707b | 2006-09-20 15:59:52 +0200 | [diff] [blame] | 273 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 274 | return residual_str; |
| 275 | } |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 276 | if (strncmp("nofcx", parsestring, length) == 0) { |
| 277 | dasd_nofcx = 1; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 278 | pr_info("High Performance FICON support has been " |
| 279 | "deactivated\n"); |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 280 | return residual_str; |
| 281 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 282 | if (strncmp("fixedbuffers", parsestring, length) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | if (dasd_page_cache) |
| 284 | return residual_str; |
| 285 | dasd_page_cache = |
Heiko Carstens | 2f6c55f | 2006-08-16 13:49:27 +0200 | [diff] [blame] | 286 | kmem_cache_create("dasd_page_cache", PAGE_SIZE, |
| 287 | PAGE_SIZE, SLAB_CACHE_DMA, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 288 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | if (!dasd_page_cache) |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 290 | DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | "fixed buffer mode disabled."); |
| 292 | else |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 293 | DBF_EVENT(DBF_INFO, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | "turning on fixed buffer mode"); |
| 295 | return residual_str; |
| 296 | } |
| 297 | return ERR_PTR(-EINVAL); |
| 298 | } |
| 299 | |
| 300 | /* |
| 301 | * Try to interprete the first element on the comma separated parse string |
| 302 | * as a device number or a range of devices. If the interpretation is |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 303 | * successful, create the matching dasd_devmap entries and return a pointer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | * to the residual string. |
| 305 | * If interpretation fails or in case of an error, return an error code. |
| 306 | */ |
| 307 | static char * |
| 308 | dasd_parse_range( char *parsestring ) { |
| 309 | |
| 310 | struct dasd_devmap *devmap; |
| 311 | int from, from_id0, from_id1; |
| 312 | int to, to_id0, to_id1; |
| 313 | int features, rc; |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 314 | char bus_id[DASD_BUS_ID_SIZE+1], *str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | str = parsestring; |
| 317 | rc = dasd_busid(&str, &from_id0, &from_id1, &from); |
| 318 | if (rc == 0) { |
| 319 | to = from; |
| 320 | to_id0 = from_id0; |
| 321 | to_id1 = from_id1; |
| 322 | if (*str == '-') { |
| 323 | str++; |
| 324 | rc = dasd_busid(&str, &to_id0, &to_id1, &to); |
| 325 | } |
| 326 | } |
| 327 | if (rc == 0 && |
| 328 | (from_id0 != to_id0 || from_id1 != to_id1 || from > to)) |
| 329 | rc = -EINVAL; |
| 330 | if (rc) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 331 | pr_err("%s is not a valid device range\n", parsestring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | return ERR_PTR(rc); |
| 333 | } |
| 334 | features = dasd_feature_list(str, &str); |
| 335 | if (features < 0) |
| 336 | return ERR_PTR(-EINVAL); |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 337 | /* each device in dasd= parameter should be set initially online */ |
| 338 | features |= DASD_FEATURE_INITIAL_ONLINE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | while (from <= to) { |
| 340 | sprintf(bus_id, "%01x.%01x.%04x", |
| 341 | from_id0, from_id1, from++); |
| 342 | devmap = dasd_add_busid(bus_id, features); |
| 343 | if (IS_ERR(devmap)) |
| 344 | return (char *)devmap; |
| 345 | } |
| 346 | if (*str == ',') |
| 347 | return str + 1; |
| 348 | if (*str == '\0') |
| 349 | return str; |
Joe Perches | baebc70 | 2016-03-03 20:49:57 -0800 | [diff] [blame^] | 350 | pr_warn("The dasd= parameter value %s has an invalid ending\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | return ERR_PTR(-EINVAL); |
| 352 | } |
| 353 | |
Heiko Carstens | 4d284ca | 2007-02-05 21:18:53 +0100 | [diff] [blame] | 354 | static char * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | dasd_parse_next_element( char *parsestring ) { |
| 356 | char * residual_str; |
| 357 | residual_str = dasd_parse_keyword(parsestring); |
| 358 | if (!IS_ERR(residual_str)) |
| 359 | return residual_str; |
| 360 | residual_str = dasd_parse_range(parsestring); |
| 361 | return residual_str; |
| 362 | } |
| 363 | |
| 364 | /* |
| 365 | * Parse parameters stored in dasd[] |
| 366 | * The 'dasd=...' parameter allows to specify a comma separated list of |
| 367 | * keywords and device ranges. When the dasd driver is build into the kernel, |
| 368 | * the complete list will be stored as one element of the dasd[] array. |
| 369 | * When the dasd driver is build as a module, then the list is broken into |
| 370 | * it's elements and each dasd[] entry contains one element. |
| 371 | */ |
| 372 | int |
| 373 | dasd_parse(void) |
| 374 | { |
| 375 | int rc, i; |
| 376 | char *parsestring; |
| 377 | |
| 378 | rc = 0; |
| 379 | for (i = 0; i < 256; i++) { |
| 380 | if (dasd[i] == NULL) |
| 381 | break; |
| 382 | parsestring = dasd[i]; |
| 383 | /* loop over the comma separated list in the parsestring */ |
| 384 | while (*parsestring) { |
| 385 | parsestring = dasd_parse_next_element(parsestring); |
| 386 | if(IS_ERR(parsestring)) { |
| 387 | rc = PTR_ERR(parsestring); |
| 388 | break; |
| 389 | } |
| 390 | } |
| 391 | if (rc) { |
| 392 | DBF_EVENT(DBF_ALERT, "%s", "invalid range found"); |
| 393 | break; |
| 394 | } |
| 395 | } |
| 396 | return rc; |
| 397 | } |
| 398 | |
| 399 | /* |
| 400 | * Add a devmap for the device specified by busid. It is possible that |
| 401 | * the devmap already exists (dasd= parameter). The order of the devices |
| 402 | * added through this function will define the kdevs for the individual |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 403 | * devices. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | */ |
| 405 | static struct dasd_devmap * |
Cornelia Huck | 69f90f6 | 2008-05-15 16:52:34 +0200 | [diff] [blame] | 406 | dasd_add_busid(const char *bus_id, int features) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | { |
| 408 | struct dasd_devmap *devmap, *new, *tmp; |
| 409 | int hash; |
| 410 | |
Zhang Yanfei | 006485d | 2013-03-12 13:18:47 +0800 | [diff] [blame] | 411 | new = kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | if (!new) |
| 413 | return ERR_PTR(-ENOMEM); |
| 414 | spin_lock(&dasd_devmap_lock); |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 415 | devmap = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | hash = dasd_hash_busid(bus_id); |
| 417 | list_for_each_entry(tmp, &dasd_hashlists[hash], list) |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 418 | if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | devmap = tmp; |
| 420 | break; |
| 421 | } |
| 422 | if (!devmap) { |
| 423 | /* This bus_id is new. */ |
| 424 | new->devindex = dasd_max_devindex++; |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 425 | strncpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | new->features = features; |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 427 | new->device = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | list_add(&new->list, &dasd_hashlists[hash]); |
| 429 | devmap = new; |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 430 | new = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | } |
| 432 | spin_unlock(&dasd_devmap_lock); |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 433 | kfree(new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | return devmap; |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | * Find devmap for device with given bus_id. |
| 439 | */ |
| 440 | static struct dasd_devmap * |
Cornelia Huck | 69f90f6 | 2008-05-15 16:52:34 +0200 | [diff] [blame] | 441 | dasd_find_busid(const char *bus_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | { |
| 443 | struct dasd_devmap *devmap, *tmp; |
| 444 | int hash; |
| 445 | |
| 446 | spin_lock(&dasd_devmap_lock); |
| 447 | devmap = ERR_PTR(-ENODEV); |
| 448 | hash = dasd_hash_busid(bus_id); |
| 449 | list_for_each_entry(tmp, &dasd_hashlists[hash], list) { |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 450 | if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | devmap = tmp; |
| 452 | break; |
| 453 | } |
| 454 | } |
| 455 | spin_unlock(&dasd_devmap_lock); |
| 456 | return devmap; |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * Check if busid has been added to the list of dasd ranges. |
| 461 | */ |
| 462 | int |
Cornelia Huck | 69f90f6 | 2008-05-15 16:52:34 +0200 | [diff] [blame] | 463 | dasd_busid_known(const char *bus_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | { |
| 465 | return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0; |
| 466 | } |
| 467 | |
| 468 | /* |
| 469 | * Forget all about the device numbers added so far. |
| 470 | * This may only be called at module unload or system shutdown. |
| 471 | */ |
| 472 | static void |
| 473 | dasd_forget_ranges(void) |
| 474 | { |
| 475 | struct dasd_devmap *devmap, *n; |
| 476 | int i; |
| 477 | |
| 478 | spin_lock(&dasd_devmap_lock); |
| 479 | for (i = 0; i < 256; i++) { |
| 480 | list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) { |
Eric Sesterhenn | 606f442 | 2006-03-26 18:33:07 +0200 | [diff] [blame] | 481 | BUG_ON(devmap->device != NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | list_del(&devmap->list); |
| 483 | kfree(devmap); |
| 484 | } |
| 485 | } |
| 486 | spin_unlock(&dasd_devmap_lock); |
| 487 | } |
| 488 | |
| 489 | /* |
| 490 | * Find the device struct by its device index. |
| 491 | */ |
| 492 | struct dasd_device * |
| 493 | dasd_device_from_devindex(int devindex) |
| 494 | { |
| 495 | struct dasd_devmap *devmap, *tmp; |
| 496 | struct dasd_device *device; |
| 497 | int i; |
| 498 | |
| 499 | spin_lock(&dasd_devmap_lock); |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 500 | devmap = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | for (i = 0; (i < 256) && !devmap; i++) |
| 502 | list_for_each_entry(tmp, &dasd_hashlists[i], list) |
| 503 | if (tmp->devindex == devindex) { |
| 504 | /* Found the devmap for the device. */ |
| 505 | devmap = tmp; |
| 506 | break; |
| 507 | } |
| 508 | if (devmap && devmap->device) { |
| 509 | device = devmap->device; |
| 510 | dasd_get_device(device); |
| 511 | } else |
| 512 | device = ERR_PTR(-ENODEV); |
| 513 | spin_unlock(&dasd_devmap_lock); |
| 514 | return device; |
| 515 | } |
| 516 | |
| 517 | /* |
| 518 | * Return devmap for cdev. If no devmap exists yet, create one and |
| 519 | * connect it to the cdev. |
| 520 | */ |
| 521 | static struct dasd_devmap * |
| 522 | dasd_devmap_from_cdev(struct ccw_device *cdev) |
| 523 | { |
| 524 | struct dasd_devmap *devmap; |
| 525 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 526 | devmap = dasd_find_busid(dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | if (IS_ERR(devmap)) |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 528 | devmap = dasd_add_busid(dev_name(&cdev->dev), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | DASD_FEATURE_DEFAULT); |
| 530 | return devmap; |
| 531 | } |
| 532 | |
| 533 | /* |
| 534 | * Create a dasd device structure for cdev. |
| 535 | */ |
| 536 | struct dasd_device * |
| 537 | dasd_create_device(struct ccw_device *cdev) |
| 538 | { |
| 539 | struct dasd_devmap *devmap; |
| 540 | struct dasd_device *device; |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 541 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | int rc; |
| 543 | |
| 544 | devmap = dasd_devmap_from_cdev(cdev); |
| 545 | if (IS_ERR(devmap)) |
| 546 | return (void *) devmap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | |
| 548 | device = dasd_alloc_device(); |
| 549 | if (IS_ERR(device)) |
| 550 | return device; |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 551 | atomic_set(&device->ref_count, 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
| 553 | spin_lock(&dasd_devmap_lock); |
| 554 | if (!devmap->device) { |
| 555 | devmap->device = device; |
| 556 | device->devindex = devmap->devindex; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 557 | device->features = devmap->features; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | get_device(&cdev->dev); |
| 559 | device->cdev = cdev; |
| 560 | rc = 0; |
| 561 | } else |
| 562 | /* Someone else was faster. */ |
| 563 | rc = -EBUSY; |
| 564 | spin_unlock(&dasd_devmap_lock); |
| 565 | |
| 566 | if (rc) { |
| 567 | dasd_free_device(device); |
| 568 | return ERR_PTR(rc); |
| 569 | } |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 570 | |
| 571 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
Cornelia Huck | faf16aa | 2008-12-25 13:38:52 +0100 | [diff] [blame] | 572 | dev_set_drvdata(&cdev->dev, device); |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 573 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | return device; |
| 576 | } |
| 577 | |
| 578 | /* |
| 579 | * Wait queue for dasd_delete_device waits. |
| 580 | */ |
| 581 | static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq); |
| 582 | |
| 583 | /* |
| 584 | * Remove a dasd device structure. The passed referenced |
| 585 | * is destroyed. |
| 586 | */ |
| 587 | void |
| 588 | dasd_delete_device(struct dasd_device *device) |
| 589 | { |
| 590 | struct ccw_device *cdev; |
| 591 | struct dasd_devmap *devmap; |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 592 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
| 594 | /* First remove device pointer from devmap. */ |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 595 | devmap = dasd_find_busid(dev_name(&device->cdev->dev)); |
Eric Sesterhenn | 606f442 | 2006-03-26 18:33:07 +0200 | [diff] [blame] | 596 | BUG_ON(IS_ERR(devmap)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | spin_lock(&dasd_devmap_lock); |
| 598 | if (devmap->device != device) { |
| 599 | spin_unlock(&dasd_devmap_lock); |
| 600 | dasd_put_device(device); |
| 601 | return; |
| 602 | } |
| 603 | devmap->device = NULL; |
| 604 | spin_unlock(&dasd_devmap_lock); |
| 605 | |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 606 | /* Disconnect dasd_device structure from ccw_device structure. */ |
| 607 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
Cornelia Huck | faf16aa | 2008-12-25 13:38:52 +0100 | [diff] [blame] | 608 | dev_set_drvdata(&device->cdev->dev, NULL); |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 609 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 610 | |
| 611 | /* |
| 612 | * Drop ref_count by 3, one for the devmap reference, one for |
| 613 | * the cdev reference and one for the passed reference. |
| 614 | */ |
| 615 | atomic_sub(3, &device->ref_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
| 617 | /* Wait for reference counter to drop to zero. */ |
| 618 | wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0); |
| 619 | |
| 620 | /* Disconnect dasd_device structure from ccw_device structure. */ |
| 621 | cdev = device->cdev; |
| 622 | device->cdev = NULL; |
| 623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | /* Put ccw_device structure. */ |
| 625 | put_device(&cdev->dev); |
| 626 | |
| 627 | /* Now the device structure can be freed. */ |
| 628 | dasd_free_device(device); |
| 629 | } |
| 630 | |
| 631 | /* |
| 632 | * Reference counter dropped to zero. Wake up waiter |
| 633 | * in dasd_delete_device. |
| 634 | */ |
| 635 | void |
| 636 | dasd_put_device_wake(struct dasd_device *device) |
| 637 | { |
| 638 | wake_up(&dasd_delete_wq); |
| 639 | } |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 640 | EXPORT_SYMBOL_GPL(dasd_put_device_wake); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | |
| 642 | /* |
| 643 | * Return dasd_device structure associated with cdev. |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 644 | * This function needs to be called with the ccw device |
| 645 | * lock held. It can be used from interrupt context. |
| 646 | */ |
| 647 | struct dasd_device * |
| 648 | dasd_device_from_cdev_locked(struct ccw_device *cdev) |
| 649 | { |
Cornelia Huck | faf16aa | 2008-12-25 13:38:52 +0100 | [diff] [blame] | 650 | struct dasd_device *device = dev_get_drvdata(&cdev->dev); |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 651 | |
| 652 | if (!device) |
| 653 | return ERR_PTR(-ENODEV); |
| 654 | dasd_get_device(device); |
| 655 | return device; |
| 656 | } |
| 657 | |
| 658 | /* |
| 659 | * Return dasd_device structure associated with cdev. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | */ |
| 661 | struct dasd_device * |
| 662 | dasd_device_from_cdev(struct ccw_device *cdev) |
| 663 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | struct dasd_device *device; |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 665 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 667 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 668 | device = dasd_device_from_cdev_locked(cdev); |
| 669 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | return device; |
| 671 | } |
| 672 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 673 | void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device) |
| 674 | { |
| 675 | struct dasd_devmap *devmap; |
| 676 | |
| 677 | devmap = dasd_find_busid(dev_name(&device->cdev->dev)); |
| 678 | if (IS_ERR(devmap)) |
| 679 | return; |
| 680 | spin_lock(&dasd_devmap_lock); |
| 681 | gdp->private_data = devmap; |
| 682 | spin_unlock(&dasd_devmap_lock); |
| 683 | } |
| 684 | |
| 685 | struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp) |
| 686 | { |
| 687 | struct dasd_device *device; |
| 688 | struct dasd_devmap *devmap; |
| 689 | |
| 690 | if (!gdp->private_data) |
| 691 | return NULL; |
| 692 | device = NULL; |
| 693 | spin_lock(&dasd_devmap_lock); |
| 694 | devmap = gdp->private_data; |
| 695 | if (devmap && devmap->device) { |
| 696 | device = devmap->device; |
| 697 | dasd_get_device(device); |
| 698 | } |
| 699 | spin_unlock(&dasd_devmap_lock); |
| 700 | return device; |
| 701 | } |
| 702 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | /* |
| 704 | * SECTION: files in sysfs |
| 705 | */ |
| 706 | |
| 707 | /* |
Holger Smolinski | 13de227 | 2009-01-09 12:14:51 +0100 | [diff] [blame] | 708 | * failfast controls the behaviour, if no path is available |
| 709 | */ |
| 710 | static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr, |
| 711 | char *buf) |
| 712 | { |
| 713 | struct dasd_devmap *devmap; |
| 714 | int ff_flag; |
| 715 | |
Cornelia Huck | ca0b4b7 | 2009-02-11 10:37:30 +0100 | [diff] [blame] | 716 | devmap = dasd_find_busid(dev_name(dev)); |
Holger Smolinski | 13de227 | 2009-01-09 12:14:51 +0100 | [diff] [blame] | 717 | if (!IS_ERR(devmap)) |
| 718 | ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0; |
| 719 | else |
| 720 | ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0; |
| 721 | return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n"); |
| 722 | } |
| 723 | |
| 724 | static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr, |
| 725 | const char *buf, size_t count) |
| 726 | { |
| 727 | struct dasd_devmap *devmap; |
| 728 | int val; |
| 729 | char *endp; |
| 730 | |
| 731 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 732 | if (IS_ERR(devmap)) |
| 733 | return PTR_ERR(devmap); |
| 734 | |
| 735 | val = simple_strtoul(buf, &endp, 0); |
| 736 | if (((endp + 1) < (buf + count)) || (val > 1)) |
| 737 | return -EINVAL; |
| 738 | |
| 739 | spin_lock(&dasd_devmap_lock); |
| 740 | if (val) |
| 741 | devmap->features |= DASD_FEATURE_FAILFAST; |
| 742 | else |
| 743 | devmap->features &= ~DASD_FEATURE_FAILFAST; |
| 744 | if (devmap->device) |
| 745 | devmap->device->features = devmap->features; |
| 746 | spin_unlock(&dasd_devmap_lock); |
| 747 | return count; |
| 748 | } |
| 749 | |
| 750 | static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store); |
| 751 | |
| 752 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | * readonly controls the readonly status of a dasd |
| 754 | */ |
| 755 | static ssize_t |
Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 756 | dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | { |
| 758 | struct dasd_devmap *devmap; |
| 759 | int ro_flag; |
| 760 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 761 | devmap = dasd_find_busid(dev_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | if (!IS_ERR(devmap)) |
| 763 | ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0; |
| 764 | else |
| 765 | ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0; |
| 766 | return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n"); |
| 767 | } |
| 768 | |
| 769 | static ssize_t |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 770 | dasd_ro_store(struct device *dev, struct device_attribute *attr, |
| 771 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | { |
| 773 | struct dasd_devmap *devmap; |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 774 | struct dasd_device *device; |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 775 | int val; |
| 776 | char *endp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| 778 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 779 | if (IS_ERR(devmap)) |
| 780 | return PTR_ERR(devmap); |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 781 | |
| 782 | val = simple_strtoul(buf, &endp, 0); |
| 783 | if (((endp + 1) < (buf + count)) || (val > 1)) |
| 784 | return -EINVAL; |
| 785 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | spin_lock(&dasd_devmap_lock); |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 787 | if (val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | devmap->features |= DASD_FEATURE_READONLY; |
| 789 | else |
| 790 | devmap->features &= ~DASD_FEATURE_READONLY; |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 791 | device = devmap->device; |
| 792 | if (device) { |
| 793 | device->features = devmap->features; |
| 794 | val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags); |
| 795 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | spin_unlock(&dasd_devmap_lock); |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 797 | if (device && device->block && device->block->gdp) |
| 798 | set_disk_ro(device->block->gdp, val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | return count; |
| 800 | } |
| 801 | |
| 802 | static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store); |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 803 | /* |
| 804 | * erplog controls the logging of ERP related data |
| 805 | * (e.g. failing channel programs). |
| 806 | */ |
| 807 | static ssize_t |
| 808 | dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 809 | { |
| 810 | struct dasd_devmap *devmap; |
| 811 | int erplog; |
| 812 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 813 | devmap = dasd_find_busid(dev_name(dev)); |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 814 | if (!IS_ERR(devmap)) |
| 815 | erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0; |
| 816 | else |
| 817 | erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0; |
| 818 | return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n"); |
| 819 | } |
| 820 | |
| 821 | static ssize_t |
| 822 | dasd_erplog_store(struct device *dev, struct device_attribute *attr, |
| 823 | const char *buf, size_t count) |
| 824 | { |
| 825 | struct dasd_devmap *devmap; |
| 826 | int val; |
| 827 | char *endp; |
| 828 | |
| 829 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 830 | if (IS_ERR(devmap)) |
| 831 | return PTR_ERR(devmap); |
| 832 | |
| 833 | val = simple_strtoul(buf, &endp, 0); |
| 834 | if (((endp + 1) < (buf + count)) || (val > 1)) |
| 835 | return -EINVAL; |
| 836 | |
| 837 | spin_lock(&dasd_devmap_lock); |
| 838 | if (val) |
| 839 | devmap->features |= DASD_FEATURE_ERPLOG; |
| 840 | else |
| 841 | devmap->features &= ~DASD_FEATURE_ERPLOG; |
| 842 | if (devmap->device) |
| 843 | devmap->device->features = devmap->features; |
| 844 | spin_unlock(&dasd_devmap_lock); |
| 845 | return count; |
| 846 | } |
| 847 | |
| 848 | static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | |
| 850 | /* |
| 851 | * use_diag controls whether the driver should use diag rather than ssch |
| 852 | * to talk to the device |
| 853 | */ |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 854 | static ssize_t |
Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 855 | dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | { |
| 857 | struct dasd_devmap *devmap; |
| 858 | int use_diag; |
| 859 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 860 | devmap = dasd_find_busid(dev_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | if (!IS_ERR(devmap)) |
| 862 | use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0; |
| 863 | else |
| 864 | use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0; |
| 865 | return sprintf(buf, use_diag ? "1\n" : "0\n"); |
| 866 | } |
| 867 | |
| 868 | static ssize_t |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 869 | dasd_use_diag_store(struct device *dev, struct device_attribute *attr, |
| 870 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | { |
| 872 | struct dasd_devmap *devmap; |
| 873 | ssize_t rc; |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 874 | int val; |
| 875 | char *endp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | |
| 877 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 878 | if (IS_ERR(devmap)) |
| 879 | return PTR_ERR(devmap); |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 880 | |
| 881 | val = simple_strtoul(buf, &endp, 0); |
| 882 | if (((endp + 1) < (buf + count)) || (val > 1)) |
| 883 | return -EINVAL; |
| 884 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | spin_lock(&dasd_devmap_lock); |
| 886 | /* Changing diag discipline flag is only allowed in offline state. */ |
| 887 | rc = count; |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 888 | if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) { |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 889 | if (val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | devmap->features |= DASD_FEATURE_USEDIAG; |
| 891 | else |
| 892 | devmap->features &= ~DASD_FEATURE_USEDIAG; |
| 893 | } else |
| 894 | rc = -EPERM; |
| 895 | spin_unlock(&dasd_devmap_lock); |
| 896 | return rc; |
| 897 | } |
| 898 | |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 899 | static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 901 | /* |
| 902 | * use_raw controls whether the driver should give access to raw eckd data or |
| 903 | * operate in standard mode |
| 904 | */ |
| 905 | static ssize_t |
| 906 | dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 907 | { |
| 908 | struct dasd_devmap *devmap; |
| 909 | int use_raw; |
| 910 | |
| 911 | devmap = dasd_find_busid(dev_name(dev)); |
| 912 | if (!IS_ERR(devmap)) |
| 913 | use_raw = (devmap->features & DASD_FEATURE_USERAW) != 0; |
| 914 | else |
| 915 | use_raw = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USERAW) != 0; |
| 916 | return sprintf(buf, use_raw ? "1\n" : "0\n"); |
| 917 | } |
| 918 | |
| 919 | static ssize_t |
| 920 | dasd_use_raw_store(struct device *dev, struct device_attribute *attr, |
| 921 | const char *buf, size_t count) |
| 922 | { |
| 923 | struct dasd_devmap *devmap; |
| 924 | ssize_t rc; |
| 925 | unsigned long val; |
| 926 | |
| 927 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 928 | if (IS_ERR(devmap)) |
| 929 | return PTR_ERR(devmap); |
| 930 | |
Jingoo Han | 0178722 | 2013-07-22 10:18:15 +0900 | [diff] [blame] | 931 | if ((kstrtoul(buf, 10, &val) != 0) || val > 1) |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 932 | return -EINVAL; |
| 933 | |
| 934 | spin_lock(&dasd_devmap_lock); |
| 935 | /* Changing diag discipline flag is only allowed in offline state. */ |
| 936 | rc = count; |
| 937 | if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) { |
| 938 | if (val) |
| 939 | devmap->features |= DASD_FEATURE_USERAW; |
| 940 | else |
| 941 | devmap->features &= ~DASD_FEATURE_USERAW; |
| 942 | } else |
| 943 | rc = -EPERM; |
| 944 | spin_unlock(&dasd_devmap_lock); |
| 945 | return rc; |
| 946 | } |
| 947 | |
| 948 | static DEVICE_ATTR(raw_track_access, 0644, dasd_use_raw_show, |
| 949 | dasd_use_raw_store); |
| 950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | static ssize_t |
Stefan Haberland | d07dc5d | 2012-11-28 13:43:38 +0100 | [diff] [blame] | 952 | dasd_safe_offline_store(struct device *dev, struct device_attribute *attr, |
| 953 | const char *buf, size_t count) |
| 954 | { |
| 955 | struct ccw_device *cdev = to_ccwdev(dev); |
| 956 | struct dasd_device *device; |
| 957 | int rc; |
| 958 | |
| 959 | device = dasd_device_from_cdev(cdev); |
| 960 | if (IS_ERR(device)) { |
| 961 | rc = PTR_ERR(device); |
| 962 | goto out; |
| 963 | } |
| 964 | |
| 965 | if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || |
| 966 | test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { |
| 967 | /* Already doing offline processing */ |
| 968 | dasd_put_device(device); |
| 969 | rc = -EBUSY; |
| 970 | goto out; |
| 971 | } |
| 972 | |
| 973 | set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags); |
| 974 | dasd_put_device(device); |
| 975 | |
| 976 | rc = ccw_device_set_offline(cdev); |
| 977 | |
| 978 | out: |
| 979 | return rc ? rc : count; |
| 980 | } |
| 981 | |
| 982 | static DEVICE_ATTR(safe_offline, 0200, NULL, dasd_safe_offline_store); |
| 983 | |
| 984 | static ssize_t |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 985 | dasd_discipline_show(struct device *dev, struct device_attribute *attr, |
| 986 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | { |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 988 | struct dasd_device *device; |
| 989 | ssize_t len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 991 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
Stefan Haberland | 589c74d | 2010-02-26 22:37:47 +0100 | [diff] [blame] | 992 | if (IS_ERR(device)) |
| 993 | goto out; |
| 994 | else if (!device->discipline) { |
| 995 | dasd_put_device(device); |
| 996 | goto out; |
| 997 | } else { |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 998 | len = snprintf(buf, PAGE_SIZE, "%s\n", |
| 999 | device->discipline->name); |
| 1000 | dasd_put_device(device); |
Stefan Haberland | 589c74d | 2010-02-26 22:37:47 +0100 | [diff] [blame] | 1001 | return len; |
| 1002 | } |
| 1003 | out: |
| 1004 | len = snprintf(buf, PAGE_SIZE, "none\n"); |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 1005 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); |
| 1009 | |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1010 | static ssize_t |
Horst Hummel | 4dfd5c4 | 2007-04-27 16:01:47 +0200 | [diff] [blame] | 1011 | dasd_device_status_show(struct device *dev, struct device_attribute *attr, |
| 1012 | char *buf) |
| 1013 | { |
| 1014 | struct dasd_device *device; |
| 1015 | ssize_t len; |
| 1016 | |
| 1017 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1018 | if (!IS_ERR(device)) { |
| 1019 | switch (device->state) { |
| 1020 | case DASD_STATE_NEW: |
| 1021 | len = snprintf(buf, PAGE_SIZE, "new\n"); |
| 1022 | break; |
| 1023 | case DASD_STATE_KNOWN: |
| 1024 | len = snprintf(buf, PAGE_SIZE, "detected\n"); |
| 1025 | break; |
| 1026 | case DASD_STATE_BASIC: |
| 1027 | len = snprintf(buf, PAGE_SIZE, "basic\n"); |
| 1028 | break; |
| 1029 | case DASD_STATE_UNFMT: |
| 1030 | len = snprintf(buf, PAGE_SIZE, "unformatted\n"); |
| 1031 | break; |
| 1032 | case DASD_STATE_READY: |
| 1033 | len = snprintf(buf, PAGE_SIZE, "ready\n"); |
| 1034 | break; |
| 1035 | case DASD_STATE_ONLINE: |
| 1036 | len = snprintf(buf, PAGE_SIZE, "online\n"); |
| 1037 | break; |
| 1038 | default: |
| 1039 | len = snprintf(buf, PAGE_SIZE, "no stat\n"); |
| 1040 | break; |
| 1041 | } |
| 1042 | dasd_put_device(device); |
| 1043 | } else |
| 1044 | len = snprintf(buf, PAGE_SIZE, "unknown\n"); |
| 1045 | return len; |
| 1046 | } |
| 1047 | |
| 1048 | static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL); |
| 1049 | |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1050 | static ssize_t dasd_alias_show(struct device *dev, |
| 1051 | struct device_attribute *attr, char *buf) |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1052 | { |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1053 | struct dasd_device *device; |
| 1054 | struct dasd_uid uid; |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1055 | |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1056 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1057 | if (IS_ERR(device)) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1058 | return sprintf(buf, "0\n"); |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1059 | |
| 1060 | if (device->discipline && device->discipline->get_uid && |
| 1061 | !device->discipline->get_uid(device, &uid)) { |
| 1062 | if (uid.type == UA_BASE_PAV_ALIAS || |
Stefan Haberland | 0abccf7 | 2010-07-19 09:22:36 +0200 | [diff] [blame] | 1063 | uid.type == UA_HYPER_PAV_ALIAS) { |
| 1064 | dasd_put_device(device); |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1065 | return sprintf(buf, "1\n"); |
Stefan Haberland | 0abccf7 | 2010-07-19 09:22:36 +0200 | [diff] [blame] | 1066 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1067 | } |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1068 | dasd_put_device(device); |
| 1069 | |
| 1070 | return sprintf(buf, "0\n"); |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL); |
| 1074 | |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1075 | static ssize_t dasd_vendor_show(struct device *dev, |
| 1076 | struct device_attribute *attr, char *buf) |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1077 | { |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1078 | struct dasd_device *device; |
| 1079 | struct dasd_uid uid; |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1080 | char *vendor; |
| 1081 | |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1082 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1083 | vendor = ""; |
| 1084 | if (IS_ERR(device)) |
| 1085 | return snprintf(buf, PAGE_SIZE, "%s\n", vendor); |
| 1086 | |
| 1087 | if (device->discipline && device->discipline->get_uid && |
| 1088 | !device->discipline->get_uid(device, &uid)) |
| 1089 | vendor = uid.vendor; |
| 1090 | |
| 1091 | dasd_put_device(device); |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1092 | |
| 1093 | return snprintf(buf, PAGE_SIZE, "%s\n", vendor); |
| 1094 | } |
| 1095 | |
| 1096 | static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); |
| 1097 | |
| 1098 | #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\ |
Stefan Weinhuber | 4abb08c | 2008-08-01 16:39:09 +0200 | [diff] [blame] | 1099 | /* SSID */ 4 + 1 + /* unit addr */ 2 + 1 +\ |
| 1100 | /* vduit */ 32 + 1) |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1101 | |
| 1102 | static ssize_t |
| 1103 | dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1104 | { |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1105 | struct dasd_device *device; |
| 1106 | struct dasd_uid uid; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1107 | char uid_string[UID_STRLEN]; |
| 1108 | char ua_string[3]; |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1109 | |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1110 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1111 | uid_string[0] = 0; |
| 1112 | if (IS_ERR(device)) |
| 1113 | return snprintf(buf, PAGE_SIZE, "%s\n", uid_string); |
| 1114 | |
| 1115 | if (device->discipline && device->discipline->get_uid && |
| 1116 | !device->discipline->get_uid(device, &uid)) { |
| 1117 | switch (uid.type) { |
| 1118 | case UA_BASE_DEVICE: |
| 1119 | snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1120 | uid.real_unit_addr); |
| 1121 | break; |
| 1122 | case UA_BASE_PAV_ALIAS: |
| 1123 | snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1124 | uid.base_unit_addr); |
| 1125 | break; |
| 1126 | case UA_HYPER_PAV_ALIAS: |
| 1127 | snprintf(ua_string, sizeof(ua_string), "xx"); |
| 1128 | break; |
| 1129 | default: |
| 1130 | /* should not happen, treat like base device */ |
| 1131 | snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1132 | uid.real_unit_addr); |
| 1133 | break; |
| 1134 | } |
| 1135 | |
| 1136 | if (strlen(uid.vduit) > 0) |
| 1137 | snprintf(uid_string, sizeof(uid_string), |
| 1138 | "%s.%s.%04x.%s.%s", |
| 1139 | uid.vendor, uid.serial, uid.ssid, ua_string, |
| 1140 | uid.vduit); |
| 1141 | else |
| 1142 | snprintf(uid_string, sizeof(uid_string), |
| 1143 | "%s.%s.%04x.%s", |
| 1144 | uid.vendor, uid.serial, uid.ssid, ua_string); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1145 | } |
Stefan Haberland | 2dedf0d | 2010-05-17 10:00:11 +0200 | [diff] [blame] | 1146 | dasd_put_device(device); |
| 1147 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1148 | return snprintf(buf, PAGE_SIZE, "%s\n", uid_string); |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1149 | } |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1150 | static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL); |
| 1151 | |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1152 | /* |
| 1153 | * extended error-reporting |
| 1154 | */ |
| 1155 | static ssize_t |
| 1156 | dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1157 | { |
| 1158 | struct dasd_devmap *devmap; |
| 1159 | int eer_flag; |
| 1160 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 1161 | devmap = dasd_find_busid(dev_name(dev)); |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1162 | if (!IS_ERR(devmap) && devmap->device) |
| 1163 | eer_flag = dasd_eer_enabled(devmap->device); |
| 1164 | else |
| 1165 | eer_flag = 0; |
| 1166 | return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n"); |
| 1167 | } |
| 1168 | |
| 1169 | static ssize_t |
| 1170 | dasd_eer_store(struct device *dev, struct device_attribute *attr, |
| 1171 | const char *buf, size_t count) |
| 1172 | { |
| 1173 | struct dasd_devmap *devmap; |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 1174 | int val, rc; |
| 1175 | char *endp; |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1176 | |
| 1177 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 1178 | if (IS_ERR(devmap)) |
| 1179 | return PTR_ERR(devmap); |
| 1180 | if (!devmap->device) |
Horst Hummel | 01376f4 | 2006-12-04 15:39:50 +0100 | [diff] [blame] | 1181 | return -ENODEV; |
| 1182 | |
| 1183 | val = simple_strtoul(buf, &endp, 0); |
| 1184 | if (((endp + 1) < (buf + count)) || (val > 1)) |
| 1185 | return -EINVAL; |
| 1186 | |
Horst Hummel | 645c98c | 2006-12-04 15:40:18 +0100 | [diff] [blame] | 1187 | if (val) { |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1188 | rc = dasd_eer_enable(devmap->device); |
Horst Hummel | 645c98c | 2006-12-04 15:40:18 +0100 | [diff] [blame] | 1189 | if (rc) |
| 1190 | return rc; |
| 1191 | } else |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1192 | dasd_eer_disable(devmap->device); |
Horst Hummel | 645c98c | 2006-12-04 15:40:18 +0100 | [diff] [blame] | 1193 | return count; |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store); |
| 1197 | |
Stefan Haberland | 7c8faa8 | 2010-08-09 18:13:00 +0200 | [diff] [blame] | 1198 | /* |
| 1199 | * expiration time for default requests |
| 1200 | */ |
| 1201 | static ssize_t |
| 1202 | dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1203 | { |
| 1204 | struct dasd_device *device; |
| 1205 | int len; |
| 1206 | |
| 1207 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1208 | if (IS_ERR(device)) |
| 1209 | return -ENODEV; |
| 1210 | len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_expires); |
| 1211 | dasd_put_device(device); |
| 1212 | return len; |
| 1213 | } |
| 1214 | |
| 1215 | static ssize_t |
| 1216 | dasd_expires_store(struct device *dev, struct device_attribute *attr, |
| 1217 | const char *buf, size_t count) |
| 1218 | { |
| 1219 | struct dasd_device *device; |
| 1220 | unsigned long val; |
| 1221 | |
| 1222 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1223 | if (IS_ERR(device)) |
| 1224 | return -ENODEV; |
| 1225 | |
Jingoo Han | 0178722 | 2013-07-22 10:18:15 +0900 | [diff] [blame] | 1226 | if ((kstrtoul(buf, 10, &val) != 0) || |
Stefan Haberland | 7c8faa8 | 2010-08-09 18:13:00 +0200 | [diff] [blame] | 1227 | (val > DASD_EXPIRES_MAX) || val == 0) { |
| 1228 | dasd_put_device(device); |
| 1229 | return -EINVAL; |
| 1230 | } |
| 1231 | |
| 1232 | if (val) |
| 1233 | device->default_expires = val; |
| 1234 | |
| 1235 | dasd_put_device(device); |
| 1236 | return count; |
| 1237 | } |
| 1238 | |
| 1239 | static DEVICE_ATTR(expires, 0644, dasd_expires_show, dasd_expires_store); |
| 1240 | |
Hannes Reinecke | 1f1ee9a | 2013-01-30 09:26:12 +0000 | [diff] [blame] | 1241 | static ssize_t |
| 1242 | dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1243 | { |
| 1244 | struct dasd_device *device; |
| 1245 | int len; |
| 1246 | |
| 1247 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1248 | if (IS_ERR(device)) |
| 1249 | return -ENODEV; |
| 1250 | len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_retries); |
| 1251 | dasd_put_device(device); |
| 1252 | return len; |
| 1253 | } |
| 1254 | |
| 1255 | static ssize_t |
| 1256 | dasd_retries_store(struct device *dev, struct device_attribute *attr, |
| 1257 | const char *buf, size_t count) |
| 1258 | { |
| 1259 | struct dasd_device *device; |
| 1260 | unsigned long val; |
| 1261 | |
| 1262 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1263 | if (IS_ERR(device)) |
| 1264 | return -ENODEV; |
| 1265 | |
Jingoo Han | 0178722 | 2013-07-22 10:18:15 +0900 | [diff] [blame] | 1266 | if ((kstrtoul(buf, 10, &val) != 0) || |
Hannes Reinecke | 1f1ee9a | 2013-01-30 09:26:12 +0000 | [diff] [blame] | 1267 | (val > DASD_RETRIES_MAX)) { |
| 1268 | dasd_put_device(device); |
| 1269 | return -EINVAL; |
| 1270 | } |
| 1271 | |
| 1272 | if (val) |
| 1273 | device->default_retries = val; |
| 1274 | |
| 1275 | dasd_put_device(device); |
| 1276 | return count; |
| 1277 | } |
| 1278 | |
| 1279 | static DEVICE_ATTR(retries, 0644, dasd_retries_show, dasd_retries_store); |
| 1280 | |
Hannes Reinecke | 3d71ad3 | 2013-01-30 09:26:18 +0000 | [diff] [blame] | 1281 | static ssize_t |
| 1282 | dasd_timeout_show(struct device *dev, struct device_attribute *attr, |
| 1283 | char *buf) |
| 1284 | { |
| 1285 | struct dasd_device *device; |
| 1286 | int len; |
| 1287 | |
| 1288 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1289 | if (IS_ERR(device)) |
| 1290 | return -ENODEV; |
| 1291 | len = snprintf(buf, PAGE_SIZE, "%lu\n", device->blk_timeout); |
| 1292 | dasd_put_device(device); |
| 1293 | return len; |
| 1294 | } |
| 1295 | |
| 1296 | static ssize_t |
| 1297 | dasd_timeout_store(struct device *dev, struct device_attribute *attr, |
| 1298 | const char *buf, size_t count) |
| 1299 | { |
| 1300 | struct dasd_device *device; |
| 1301 | struct request_queue *q; |
| 1302 | unsigned long val, flags; |
| 1303 | |
| 1304 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1305 | if (IS_ERR(device) || !device->block) |
| 1306 | return -ENODEV; |
| 1307 | |
Jingoo Han | 0178722 | 2013-07-22 10:18:15 +0900 | [diff] [blame] | 1308 | if ((kstrtoul(buf, 10, &val) != 0) || |
Hannes Reinecke | 3d71ad3 | 2013-01-30 09:26:18 +0000 | [diff] [blame] | 1309 | val > UINT_MAX / HZ) { |
| 1310 | dasd_put_device(device); |
| 1311 | return -EINVAL; |
| 1312 | } |
| 1313 | q = device->block->request_queue; |
| 1314 | if (!q) { |
| 1315 | dasd_put_device(device); |
| 1316 | return -ENODEV; |
| 1317 | } |
| 1318 | spin_lock_irqsave(&device->block->request_queue_lock, flags); |
| 1319 | if (!val) |
| 1320 | blk_queue_rq_timed_out(q, NULL); |
| 1321 | else |
| 1322 | blk_queue_rq_timed_out(q, dasd_times_out); |
| 1323 | |
| 1324 | device->blk_timeout = val; |
| 1325 | |
| 1326 | blk_queue_rq_timeout(q, device->blk_timeout * HZ); |
| 1327 | spin_unlock_irqrestore(&device->block->request_queue_lock, flags); |
| 1328 | |
| 1329 | dasd_put_device(device); |
| 1330 | return count; |
| 1331 | } |
| 1332 | |
| 1333 | static DEVICE_ATTR(timeout, 0644, |
| 1334 | dasd_timeout_show, dasd_timeout_store); |
| 1335 | |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1336 | static ssize_t dasd_reservation_policy_show(struct device *dev, |
| 1337 | struct device_attribute *attr, |
| 1338 | char *buf) |
| 1339 | { |
| 1340 | struct dasd_devmap *devmap; |
| 1341 | int rc = 0; |
| 1342 | |
| 1343 | devmap = dasd_find_busid(dev_name(dev)); |
| 1344 | if (IS_ERR(devmap)) { |
| 1345 | rc = snprintf(buf, PAGE_SIZE, "ignore\n"); |
| 1346 | } else { |
| 1347 | spin_lock(&dasd_devmap_lock); |
| 1348 | if (devmap->features & DASD_FEATURE_FAILONSLCK) |
| 1349 | rc = snprintf(buf, PAGE_SIZE, "fail\n"); |
| 1350 | else |
| 1351 | rc = snprintf(buf, PAGE_SIZE, "ignore\n"); |
| 1352 | spin_unlock(&dasd_devmap_lock); |
| 1353 | } |
| 1354 | return rc; |
| 1355 | } |
| 1356 | |
| 1357 | static ssize_t dasd_reservation_policy_store(struct device *dev, |
| 1358 | struct device_attribute *attr, |
| 1359 | const char *buf, size_t count) |
| 1360 | { |
| 1361 | struct dasd_devmap *devmap; |
| 1362 | int rc; |
| 1363 | |
| 1364 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 1365 | if (IS_ERR(devmap)) |
| 1366 | return PTR_ERR(devmap); |
| 1367 | rc = 0; |
| 1368 | spin_lock(&dasd_devmap_lock); |
| 1369 | if (sysfs_streq("ignore", buf)) |
| 1370 | devmap->features &= ~DASD_FEATURE_FAILONSLCK; |
| 1371 | else if (sysfs_streq("fail", buf)) |
| 1372 | devmap->features |= DASD_FEATURE_FAILONSLCK; |
| 1373 | else |
| 1374 | rc = -EINVAL; |
| 1375 | if (devmap->device) |
| 1376 | devmap->device->features = devmap->features; |
| 1377 | spin_unlock(&dasd_devmap_lock); |
| 1378 | if (rc) |
| 1379 | return rc; |
| 1380 | else |
| 1381 | return count; |
| 1382 | } |
| 1383 | |
| 1384 | static DEVICE_ATTR(reservation_policy, 0644, |
| 1385 | dasd_reservation_policy_show, dasd_reservation_policy_store); |
| 1386 | |
| 1387 | static ssize_t dasd_reservation_state_show(struct device *dev, |
| 1388 | struct device_attribute *attr, |
| 1389 | char *buf) |
| 1390 | { |
| 1391 | struct dasd_device *device; |
| 1392 | int rc = 0; |
| 1393 | |
| 1394 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1395 | if (IS_ERR(device)) |
| 1396 | return snprintf(buf, PAGE_SIZE, "none\n"); |
| 1397 | |
| 1398 | if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags)) |
| 1399 | rc = snprintf(buf, PAGE_SIZE, "reserved\n"); |
| 1400 | else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) |
| 1401 | rc = snprintf(buf, PAGE_SIZE, "lost\n"); |
| 1402 | else |
| 1403 | rc = snprintf(buf, PAGE_SIZE, "none\n"); |
| 1404 | dasd_put_device(device); |
| 1405 | return rc; |
| 1406 | } |
| 1407 | |
| 1408 | static ssize_t dasd_reservation_state_store(struct device *dev, |
| 1409 | struct device_attribute *attr, |
| 1410 | const char *buf, size_t count) |
| 1411 | { |
| 1412 | struct dasd_device *device; |
| 1413 | int rc = 0; |
| 1414 | |
| 1415 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1416 | if (IS_ERR(device)) |
| 1417 | return -ENODEV; |
| 1418 | if (sysfs_streq("reset", buf)) |
| 1419 | clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags); |
| 1420 | else |
| 1421 | rc = -EINVAL; |
| 1422 | dasd_put_device(device); |
| 1423 | |
| 1424 | if (rc) |
| 1425 | return rc; |
| 1426 | else |
| 1427 | return count; |
| 1428 | } |
| 1429 | |
| 1430 | static DEVICE_ATTR(last_known_reservation_state, 0644, |
| 1431 | dasd_reservation_state_show, dasd_reservation_state_store); |
| 1432 | |
Stefan Haberland | 5db8440 | 2014-10-01 14:39:47 +0200 | [diff] [blame] | 1433 | static ssize_t dasd_pm_show(struct device *dev, |
| 1434 | struct device_attribute *attr, char *buf) |
| 1435 | { |
| 1436 | struct dasd_device *device; |
| 1437 | u8 opm, nppm, cablepm, cuirpm, hpfpm; |
| 1438 | |
| 1439 | device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1440 | if (IS_ERR(device)) |
| 1441 | return sprintf(buf, "0\n"); |
| 1442 | |
| 1443 | opm = device->path_data.opm; |
| 1444 | nppm = device->path_data.npm; |
| 1445 | cablepm = device->path_data.cablepm; |
| 1446 | cuirpm = device->path_data.cuirpm; |
| 1447 | hpfpm = device->path_data.hpfpm; |
| 1448 | dasd_put_device(device); |
| 1449 | |
| 1450 | return sprintf(buf, "%02x %02x %02x %02x %02x\n", opm, nppm, |
| 1451 | cablepm, cuirpm, hpfpm); |
| 1452 | } |
| 1453 | |
| 1454 | static DEVICE_ATTR(path_masks, 0444, dasd_pm_show, NULL); |
| 1455 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | static struct attribute * dasd_attrs[] = { |
| 1457 | &dev_attr_readonly.attr, |
| 1458 | &dev_attr_discipline.attr, |
Horst Hummel | 4dfd5c4 | 2007-04-27 16:01:47 +0200 | [diff] [blame] | 1459 | &dev_attr_status.attr, |
Horst Hummel | 3d05259 | 2006-04-27 18:40:28 -0700 | [diff] [blame] | 1460 | &dev_attr_alias.attr, |
| 1461 | &dev_attr_vendor.attr, |
| 1462 | &dev_attr_uid.attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | &dev_attr_use_diag.attr, |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 1464 | &dev_attr_raw_track_access.attr, |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1465 | &dev_attr_eer_enabled.attr, |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 1466 | &dev_attr_erplog.attr, |
Holger Smolinski | 13de227 | 2009-01-09 12:14:51 +0100 | [diff] [blame] | 1467 | &dev_attr_failfast.attr, |
Stefan Haberland | 7c8faa8 | 2010-08-09 18:13:00 +0200 | [diff] [blame] | 1468 | &dev_attr_expires.attr, |
Hannes Reinecke | 1f1ee9a | 2013-01-30 09:26:12 +0000 | [diff] [blame] | 1469 | &dev_attr_retries.attr, |
Hannes Reinecke | 3d71ad3 | 2013-01-30 09:26:18 +0000 | [diff] [blame] | 1470 | &dev_attr_timeout.attr, |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1471 | &dev_attr_reservation_policy.attr, |
| 1472 | &dev_attr_last_known_reservation_state.attr, |
Stefan Haberland | d07dc5d | 2012-11-28 13:43:38 +0100 | [diff] [blame] | 1473 | &dev_attr_safe_offline.attr, |
Stefan Haberland | 5db8440 | 2014-10-01 14:39:47 +0200 | [diff] [blame] | 1474 | &dev_attr_path_masks.attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | NULL, |
| 1476 | }; |
| 1477 | |
| 1478 | static struct attribute_group dasd_attr_group = { |
| 1479 | .attrs = dasd_attrs, |
| 1480 | }; |
| 1481 | |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 1482 | /* |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1483 | * Return value of the specified feature. |
| 1484 | */ |
| 1485 | int |
| 1486 | dasd_get_feature(struct ccw_device *cdev, int feature) |
| 1487 | { |
| 1488 | struct dasd_devmap *devmap; |
| 1489 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 1490 | devmap = dasd_find_busid(dev_name(&cdev->dev)); |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1491 | if (IS_ERR(devmap)) |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 1492 | return PTR_ERR(devmap); |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1493 | |
| 1494 | return ((devmap->features & feature) != 0); |
| 1495 | } |
| 1496 | |
| 1497 | /* |
| 1498 | * Set / reset given feature. |
Adam Buchbinder | 48fc7f7 | 2012-09-19 21:48:00 -0400 | [diff] [blame] | 1499 | * Flag indicates whether to set (!=0) or the reset (=0) the feature. |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1500 | */ |
| 1501 | int |
| 1502 | dasd_set_feature(struct ccw_device *cdev, int feature, int flag) |
| 1503 | { |
| 1504 | struct dasd_devmap *devmap; |
| 1505 | |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 1506 | devmap = dasd_find_busid(dev_name(&cdev->dev)); |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1507 | if (IS_ERR(devmap)) |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 1508 | return PTR_ERR(devmap); |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1509 | |
| 1510 | spin_lock(&dasd_devmap_lock); |
| 1511 | if (flag) |
| 1512 | devmap->features |= feature; |
| 1513 | else |
| 1514 | devmap->features &= ~feature; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 1515 | if (devmap->device) |
| 1516 | devmap->device->features = devmap->features; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1517 | spin_unlock(&dasd_devmap_lock); |
| 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | int |
| 1523 | dasd_add_sysfs_files(struct ccw_device *cdev) |
| 1524 | { |
| 1525 | return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group); |
| 1526 | } |
| 1527 | |
| 1528 | void |
| 1529 | dasd_remove_sysfs_files(struct ccw_device *cdev) |
| 1530 | { |
| 1531 | sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group); |
| 1532 | } |
| 1533 | |
| 1534 | |
| 1535 | int |
| 1536 | dasd_devmap_init(void) |
| 1537 | { |
| 1538 | int i; |
| 1539 | |
| 1540 | /* Initialize devmap structures. */ |
| 1541 | dasd_max_devindex = 0; |
| 1542 | for (i = 0; i < 256; i++) |
| 1543 | INIT_LIST_HEAD(&dasd_hashlists[i]); |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 1544 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | void |
| 1548 | dasd_devmap_exit(void) |
| 1549 | { |
| 1550 | dasd_forget_ranges(); |
| 1551 | } |