// SPDX-License-Identifier: GPL-2.0/* * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> * Horst Hummel <Horst.Hummel@de.ibm.com> * Carsten Otte <Cotte@de.ibm.com> * Martin Schwidefsky <schwidefsky@de.ibm.com> * Bugreports.to..: <Linux390@de.ibm.com> * Copyright IBM Corp. 1999,2001 * * Device mapping and dasd= parameter parsing functions. All devmap * functions may not be called from interrupt context. In particular * dasd_get_device is a no-no from interrupt context. * */ #include <linux/export.h>#include <linux/ctype.h>#include <linux/init.h>#include <linux/module.h>#include <linux/slab.h> #include <asm/machine.h>#include <asm/debug.h>#include <linux/uaccess.h>#include <asm/ipl.h> #define DASD_MAX_PARAMS 256 #include "dasd_int.h" struct kmem_cache *dasd_page_cache;EXPORT_SYMBOL_GPL(dasd_page_cache); /* * dasd_devmap_t is used to store the features and the relation * between device number and device index. To find a dasd_devmap_t * that corresponds to a device number of a device index each * dasd_devmap_t is added to two linked lists, one to search by * the device number and one to search by the device index. As * soon as big minor numbers are available the device index list * can be removed since the device number will then be identical * to the device index. */struct dasd_devmap { struct list_head list; char bus_id[DASD_BUS_ID_SIZE]; unsigned int devindex; unsigned short features; struct dasd_device *device; struct dasd_copy_relation *copy; unsigned int aq_mask;}; /* * Parameter parsing functions for dasd= parameter. The syntax is: * <devno> : (0x)?[0-9a-fA-F]+ * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+ * <feature> : ro * <feature_list> : \(<feature>(:<feature>)*\) * <devno-range> : <devno>(-<devno>)?<feature_list>? * <busid-range> : <busid>(-<busid>)?<feature_list>? * <devices> : <devno-range>|<busid-range> * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod * * <dasd> : autodetect|probeonly|<devices>(,<devices>)* */ int dasd_probeonly = 0; /* is true, when probeonly mode is active */int dasd_autodetect = 0; /* is true, when autodetection is active */int dasd_nopav = 0; /* is true, when PAV is disabled */EXPORT_SYMBOL_GPL(dasd_nopav);int dasd_nofcx; /* disable High Performance Ficon */EXPORT_SYMBOL_GPL(dasd_nofcx); /* * char *dasd[] is intended to hold the ranges supplied by the dasd= statement * it is named 'dasd' to directly be filled by insmod with the comma separated * strings when running as a module. */static char *dasd[DASD_MAX_PARAMS];module_param_array(dasd, charp, NULL, S_IRUGO); /* * Single spinlock to protect devmap and servermap structures and lists. */static DEFINE_SPINLOCK(dasd_devmap_lock); /* * Hash lists for devmap structures. */static struct list_head dasd_hashlists[256];int dasd_max_devindex; static struct dasd_devmap *dasd_add_busid(const char *, int); static inline intdasd_hash_busid(const char *bus_id){ int hash, i; hash = 0; for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++) hash += *bus_id; return hash & 0xff;} #ifndef MODULEstatic int __init dasd_call_setup(char *opt){ static int i __initdata; char *tmp; while (i < DASD_MAX_PARAMS) { tmp = strsep(&opt, ","); if (!tmp) break; dasd[i++] = tmp; } return 1;} __setup ("dasd=", dasd_call_setup);#endif /* #ifndef MODULE */ #define DASD_IPLDEV "ipldev" /* * Read a device busid/devno from a string. */static int dasd_busid(char *str, int *id0, int *id1, int *devno){ unsigned int val; char *tok; /* Interpret ipldev busid */ if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) { if (ipl_info.type != IPL_TYPE_CCW) { pr_err("The IPL device is not a CCW device\n"); return -EINVAL; } *id0 = 0; *id1 = ipl_info.data.ccw.dev_id.ssid; *devno = ipl_info.data.ccw.dev_id.devno; return 0; } /* Old style 0xXXXX or XXXX */ if (!kstrtouint(str, 16, &val)) { *id0 = *id1 = 0; if (val > 0xffff) return -EINVAL; *devno = val; return 0; } /* New style x.y.z busid */ tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xff) return -EINVAL; *id0 = val; tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xff) return -EINVAL; *id1 = val; tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xffff) return -EINVAL; *devno = val; return 0;} /* * Read colon separated list of dasd features. */static int __init dasd_feature_list(char *str){ int features, len, rc; features = 0; rc = 0; if (!str) return DASD_FEATURE_DEFAULT; while (1) { for (len = 0; str[len] && str[len] != ':' && str[len] != ')'; len++); if (len == 2 && !strncmp(str, "ro", 2)) features |= DASD_FEATURE_READONLY; else if (len == 4 && !strncmp(str, "diag", 4)) features |= DASD_FEATURE_USEDIAG; else if (len == 3 && !strncmp(str, "raw", 3)) features |= DASD_FEATURE_USERAW; else if (len == 6 && !strncmp(str, "erplog", 6)) features |= DASD_FEATURE_ERPLOG; else if (len == 8 && !strncmp(str, "failfast", 8)) features |= DASD_FEATURE_FAILFAST; else { pr_warn("%.*s is not a supported device option\n", len, str); rc = -EINVAL; } str += len; if (*str != ':') break; str++; } return rc ? : features;} /* * Try to match the first element on the comma separated parse string * with one of the known keywords. If a keyword is found, take the approprate * action and return a pointer to the residual string. If the first element * could not be matched to any keyword then return an error code. */static int __init dasd_parse_keyword(char *keyword){ int length = strlen(keyword); if (strncmp("autodetect", keyword, length) == 0) { dasd_autodetect = 1; pr_info("The autodetection mode has been activated\n"); return 0; } if (strncmp("probeonly", keyword, length) == 0) { dasd_probeonly = 1; pr_info("The probeonly mode has been activated\n"); return 0; } if (strncmp("nopav", keyword, length) == 0) { if (machine_is_vm()) pr_info("'nopav' is not supported on z/VM\n"); else { dasd_nopav = 1; pr_info("PAV support has be deactivated\n"); } return 0; } if (strncmp("nofcx", keyword, length) == 0) { dasd_nofcx = 1; pr_info("High Performance FICON support has been " "deactivated\n"); return 0; } if (strncmp("fixedbuffers", keyword, length) == 0) { if (dasd_page_cache) return 0; dasd_page_cache = kmem_cache_create("dasd_page_cache", PAGE_SIZE, PAGE_SIZE, SLAB_CACHE_DMA, NULL); if (!dasd_page_cache) DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, " "fixed buffer mode disabled."); else DBF_EVENT(DBF_INFO, "%s", "turning on fixed buffer mode"); return 0; } return -EINVAL;} /* * Split a string of a device range into its pieces and return the from, to, and * feature parts separately. * e.g.: * 0.0.1234-0.0.5678(ro:erplog) -> from: 0.0.1234 to: 0.0.5678 features: ro:erplog * 0.0.8765(raw) -> from: 0.0.8765 to: null features: raw * 0x4321 -> from: 0x4321 to: null features: null */static int __init dasd_evaluate_range_param(char *range, char **from_str, char **to_str, char **features_str){ int rc = 0; /* Do we have a range or a single device? */ if (strchr(range, '-')) { *from_str = strsep(&range, "-"); *to_str = strsep(&range, "("); *features_str = strsep(&range, ")"); } else { *from_str = strsep(&range, "("); *features_str = strsep(&range, ")"); } if (*features_str && !range) { pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n"); rc = -EINVAL; } return rc;} /* * Try to interprete the range string as a device number or a range of devices. * If the interpretation is successful, create the matching dasd_devmap entries. * If interpretation fails or in case of an error, return an error code. */static int __init dasd_parse_range(const char *range){ struct dasd_devmap *devmap; int from, from_id0, from_id1; int to, to_id0, to_id1; int features; char bus_id[DASD_BUS_ID_SIZE + 1]; char *features_str = NULL; char *from_str = NULL; char *to_str = NULL; int rc = 0; char *tmp; tmp = kstrdup(range, GFP_KERNEL); if (!tmp) return -ENOMEM; if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str)) { rc = -EINVAL; goto out; } if (dasd_busid(from_str, &from_id0, &from_id1, &from)) { rc = -EINVAL; goto out; } to = from; to_id0 = from_id0; to_id1 = from_id1; if (to_str) { if (dasd_busid(to_str, &to_id0, &to_id1, &to)) { rc = -EINVAL; goto out; } if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) { pr_err("%s is not a valid device range\n", range); rc = -EINVAL; goto out; } } features = dasd_feature_list(features_str); if (features < 0) { rc = -EINVAL; goto out; } /* each device in dasd= parameter should be set initially online */ features |= DASD_FEATURE_INITIAL_ONLINE; while (from <= to) { scnprintf(bus_id, sizeof(bus_id), "%01x.%01x.%04x", from_id0, from_id1, from++); devmap = dasd_add_busid(bus_id, features); if (IS_ERR(devmap)) { rc = PTR_ERR(devmap); goto out; } } out: kfree(tmp); return rc;} /* * Parse parameters stored in dasd[] * The 'dasd=...' parameter allows to specify a comma separated list of * keywords and device ranges. The parameters in that list will be stored as * separate elementes in dasd[]. */int __init dasd_parse(void){ int rc, i; char *cur; rc = 0; for (i = 0; i < DASD_MAX_PARAMS; i++) { cur = dasd[i]; if (!cur) break; if (*cur == '\0') continue; rc = dasd_parse_keyword(cur); if (rc) rc = dasd_parse_range(cur); if (rc) break; } return rc;} /* * Add a devmap for the device specified by busid. It is possible that * the devmap already exists (dasd= parameter). The order of the devices * added through this function will define the kdevs for the individual * devices. */static struct dasd_devmap *dasd_add_busid(const char *bus_id, int features){ struct dasd_devmap *devmap, *new, *tmp; int hash; new = kzalloc_obj(struct dasd_devmap); if (!new) return ERR_PTR(-ENOMEM); spin_lock(&dasd_devmap_lock); devmap = NULL; hash = dasd_hash_busid(bus_id); list_for_each_entry(tmp, &dasd_hashlists[hash], list) if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { devmap = tmp; break; } if (!devmap) { /* This bus_id is new. */ new->devindex = dasd_max_devindex++; strscpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); new->features = features; new->device = NULL; list_add(&new->list, &dasd_hashlists[hash]); devmap = new; new = NULL; } spin_unlock(&dasd_devmap_lock); kfree(new); return devmap;} static struct dasd_devmap *dasd_find_busid_locked(const char *bus_id){ struct dasd_devmap *devmap, *tmp; int hash; devmap = ERR_PTR(-ENODEV); hash = dasd_hash_busid(bus_id); list_for_each_entry(tmp, &dasd_hashlists[hash], list) { if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { devmap = tmp; break; } } return devmap;} /* * Find devmap for device with given bus_id. */static struct dasd_devmap *dasd_find_busid(const char *bus_id){ struct dasd_devmap *devmap; spin_lock(&dasd_devmap_lock); devmap = dasd_find_busid_locked(bus_id); spin_unlock(&dasd_devmap_lock); return devmap;} /* * Check if busid has been added to the list of dasd ranges. */intdasd_busid_known(const char *bus_id){ return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;} /* * Forget all about the device numbers added so far. * This may only be called at module unload or system shutdown. */static voiddasd_forget_ranges(void){ struct dasd_devmap *devmap, *n; int i; spin_lock(&dasd_devmap_lock); for (i = 0; i < 256; i++) { list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) { BUG_ON(devmap->device != NULL); list_del(&devmap->list); kfree(devmap); } } spin_unlock(&dasd_devmap_lock);}Lines 1–500 of 2708. Load more
// SPDX-License-Identifier: GPL-2.0 /* * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> * Horst Hummel <Horst.Hummel@de.ibm.com> * Carsten Otte <Cotte@de.ibm.com> * Martin Schwidefsky <schwidefsky@de.ibm.com> * Bugreports.to..: <Linux390@de.ibm.com> * Copyright IBM Corp. 1999,2001 * * Device mapping and dasd= parameter parsing functions. All devmap * functions may not be called from interrupt context. In particular * dasd_get_device is a no-no from interrupt context. * */ #include <linux/export.h> #include <linux/ctype.h> #include <linux/init.h> #include <linux/module.h> #include <linux/slab.h> #include <asm/machine.h> #include <asm/debug.h> #include <linux/uaccess.h> #include <asm/ipl.h> #define DASD_MAX_PARAMS 256 #include "dasd_int.h" struct kmem_cache *dasd_page_cache; EXPORT_SYMBOL_GPL(dasd_page_cache); /* * dasd_devmap_t is used to store the features and the relation * between device number and device index. To find a dasd_devmap_t * that corresponds to a device number of a device index each * dasd_devmap_t is added to two linked lists, one to search by * the device number and one to search by the device index. As * soon as big minor numbers are available the device index list * can be removed since the device number will then be identical * to the device index. */ struct dasd_devmap { struct list_head list; char bus_id[DASD_BUS_ID_SIZE]; unsigned int devindex; unsigned short features; struct dasd_device *device; struct dasd_copy_relation *copy; unsigned int aq_mask; }; /* * Parameter parsing functions for dasd= parameter. The syntax is: * <devno> : (0x)?[0-9a-fA-F]+ * <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+ * <feature> : ro * <feature_list> : \(<feature>(:<feature>)*\) * <devno-range> : <devno>(-<devno>)?<feature_list>? * <busid-range> : <busid>(-<busid>)?<feature_list>? * <devices> : <devno-range>|<busid-range> * <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod * * <dasd> : autodetect|probeonly|<devices>(,<devices>)* */ int dasd_probeonly = 0; /* is true, when probeonly mode is active */ int dasd_autodetect = 0; /* is true, when autodetection is active */ int dasd_nopav = 0; /* is true, when PAV is disabled */ EXPORT_SYMBOL_GPL(dasd_nopav); int dasd_nofcx; /* disable High Performance Ficon */ EXPORT_SYMBOL_GPL(dasd_nofcx); /* * char *dasd[] is intended to hold the ranges supplied by the dasd= statement * it is named 'dasd' to directly be filled by insmod with the comma separated * strings when running as a module. */ static char *dasd[DASD_MAX_PARAMS]; module_param_array(dasd, charp, NULL, S_IRUGO); /* * Single spinlock to protect devmap and servermap structures and lists. */ static DEFINE_SPINLOCK(dasd_devmap_lock); /* * Hash lists for devmap structures. */ static struct list_head dasd_hashlists[256]; int dasd_max_devindex; static struct dasd_devmap *dasd_add_busid(const char *, int); static inline int dasd_hash_busid(const char *bus_id) { int hash, i; hash = 0; for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++) hash += *bus_id; return hash & 0xff; } #ifndef MODULE static int __init dasd_call_setup(char *opt) { static int i __initdata; char *tmp; while (i < DASD_MAX_PARAMS) { tmp = strsep(&opt, ","); if (!tmp) break; dasd[i++] = tmp; } return 1; } __setup ("dasd=", dasd_call_setup); #endif /* #ifndef MODULE */ #define DASD_IPLDEV "ipldev" /* * Read a device busid/devno from a string. */ static int dasd_busid(char *str, int *id0, int *id1, int *devno) { unsigned int val; char *tok; /* Interpret ipldev busid */ if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) { if (ipl_info.type != IPL_TYPE_CCW) { pr_err("The IPL device is not a CCW device\n"); return -EINVAL; } *id0 = 0; *id1 = ipl_info.data.ccw.dev_id.ssid; *devno = ipl_info.data.ccw.dev_id.devno; return 0; } /* Old style 0xXXXX or XXXX */ if (!kstrtouint(str, 16, &val)) { *id0 = *id1 = 0; if (val > 0xffff) return -EINVAL; *devno = val; return 0; } /* New style x.y.z busid */ tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xff) return -EINVAL; *id0 = val; tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xff) return -EINVAL; *id1 = val; tok = strsep(&str, "."); if (kstrtouint(tok, 16, &val) || val > 0xffff) return -EINVAL; *devno = val; return 0; } /* * Read colon separated list of dasd features. */ static int __init dasd_feature_list(char *str) { int features, len, rc; features = 0; rc = 0; if (!str) return DASD_FEATURE_DEFAULT; while (1) { for (len = 0; str[len] && str[len] != ':' && str[len] != ')'; len++); if (len == 2 && !strncmp(str, "ro", 2)) features |= DASD_FEATURE_READONLY; else if (len == 4 && !strncmp(str, "diag", 4)) features |= DASD_FEATURE_USEDIAG; else if (len == 3 && !strncmp(str, "raw", 3)) features |= DASD_FEATURE_USERAW; else if (len == 6 && !strncmp(str, "erplog", 6)) features |= DASD_FEATURE_ERPLOG; else if (len == 8 && !strncmp(str, "failfast", 8)) features |= DASD_FEATURE_FAILFAST; else { pr_warn("%.*s is not a supported device option\n", len, str); rc = -EINVAL; } str += len; if (*str != ':') break; str++; } return rc ? : features; } /* * Try to match the first element on the comma separated parse string * with one of the known keywords. If a keyword is found, take the approprate * action and return a pointer to the residual string. If the first element * could not be matched to any keyword then return an error code. */ static int __init dasd_parse_keyword(char *keyword) { int length = strlen(keyword); if (strncmp("autodetect", keyword, length) == 0) { dasd_autodetect = 1; pr_info("The autodetection mode has been activated\n"); return 0; } if (strncmp("probeonly", keyword, length) == 0) { dasd_probeonly = 1; pr_info("The probeonly mode has been activated\n"); return 0; } if (strncmp("nopav", keyword, length) == 0) { if (machine_is_vm()) pr_info("'nopav' is not supported on z/VM\n"); else { dasd_nopav = 1; pr_info("PAV support has be deactivated\n"); } return 0; } if (strncmp("nofcx", keyword, length) == 0) { dasd_nofcx = 1; pr_info("High Performance FICON support has been " "deactivated\n"); return 0; } if (strncmp("fixedbuffers", keyword, length) == 0) { if (dasd_page_cache) return 0; dasd_page_cache = kmem_cache_create("dasd_page_cache", PAGE_SIZE, PAGE_SIZE, SLAB_CACHE_DMA, NULL); if (!dasd_page_cache) DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, " "fixed buffer mode disabled."); else DBF_EVENT(DBF_INFO, "%s", "turning on fixed buffer mode"); return 0; } return -EINVAL; } /* * Split a string of a device range into its pieces and return the from, to, and * feature parts separately. * e.g.: * 0.0.1234-0.0.5678(ro:erplog) -> from: 0.0.1234 to: 0.0.5678 features: ro:erplog * 0.0.8765(raw) -> from: 0.0.8765 to: null features: raw * 0x4321 -> from: 0x4321 to: null features: null */ static int __init dasd_evaluate_range_param(char *range, char **from_str, char **to_str, char **features_str) { int rc = 0; /* Do we have a range or a single device? */ if (strchr(range, '-')) { *from_str = strsep(&range, "-"); *to_str = strsep(&range, "("); *features_str = strsep(&range, ")"); } else { *from_str = strsep(&range, "("); *features_str = strsep(&range, ")"); } if (*features_str && !range) { pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n"); rc = -EINVAL; } return rc; } /* * Try to interprete the range string as a device number or a range of devices. * If the interpretation is successful, create the matching dasd_devmap entries. * If interpretation fails or in case of an error, return an error code. */ static int __init dasd_parse_range(const char *range) { struct dasd_devmap *devmap; int from, from_id0, from_id1; int to, to_id0, to_id1; int features; char bus_id[DASD_BUS_ID_SIZE + 1]; char *features_str = NULL; char *from_str = NULL; char *to_str = NULL; int rc = 0; char *tmp; tmp = kstrdup(range, GFP_KERNEL); if (!tmp) return -ENOMEM; if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str)) { rc = -EINVAL; goto out; } if (dasd_busid(from_str, &from_id0, &from_id1, &from)) { rc = -EINVAL; goto out; } to = from; to_id0 = from_id0; to_id1 = from_id1; if (to_str) { if (dasd_busid(to_str, &to_id0, &to_id1, &to)) { rc = -EINVAL; goto out; } if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) { pr_err("%s is not a valid device range\n", range); rc = -EINVAL; goto out; } } features = dasd_feature_list(features_str); if (features < 0) { rc = -EINVAL; goto out; } /* each device in dasd= parameter should be set initially online */ features |= DASD_FEATURE_INITIAL_ONLINE; while (from <= to) { scnprintf(bus_id, sizeof(bus_id), "%01x.%01x.%04x", from_id0, from_id1, from++); devmap = dasd_add_busid(bus_id, features); if (IS_ERR(devmap)) { rc = PTR_ERR(devmap); goto out; } } out: kfree(tmp); return rc; } /* * Parse parameters stored in dasd[] * The 'dasd=...' parameter allows to specify a comma separated list of * keywords and device ranges. The parameters in that list will be stored as * separate elementes in dasd[]. */ int __init dasd_parse(void) { int rc, i; char *cur; rc = 0; for (i = 0; i < DASD_MAX_PARAMS; i++) { cur = dasd[i]; if (!cur) break; if (*cur == '\0') continue; rc = dasd_parse_keyword(cur); if (rc) rc = dasd_parse_range(cur); if (rc) break; } return rc; } /* * Add a devmap for the device specified by busid. It is possible that * the devmap already exists (dasd= parameter). The order of the devices * added through this function will define the kdevs for the individual * devices. */ static struct dasd_devmap * dasd_add_busid(const char *bus_id, int features) { struct dasd_devmap *devmap, *new, *tmp; int hash; new = kzalloc_obj(struct dasd_devmap); if (!new) return ERR_PTR(-ENOMEM); spin_lock(&dasd_devmap_lock); devmap = NULL; hash = dasd_hash_busid(bus_id); list_for_each_entry(tmp, &dasd_hashlists[hash], list) if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { devmap = tmp; break; } if (!devmap) { /* This bus_id is new. */ new->devindex = dasd_max_devindex++; strscpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); new->features = features; new->device = NULL; list_add(&new->list, &dasd_hashlists[hash]); devmap = new; new = NULL; } spin_unlock(&dasd_devmap_lock); kfree(new); return devmap; } static struct dasd_devmap * dasd_find_busid_locked(const char *bus_id) { struct dasd_devmap *devmap, *tmp; int hash; devmap = ERR_PTR(-ENODEV); hash = dasd_hash_busid(bus_id); list_for_each_entry(tmp, &dasd_hashlists[hash], list) { if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { devmap = tmp; break; } } return devmap; } /* * Find devmap for device with given bus_id. */ static struct dasd_devmap * dasd_find_busid(const char *bus_id) { struct dasd_devmap *devmap; spin_lock(&dasd_devmap_lock); devmap = dasd_find_busid_locked(bus_id); spin_unlock(&dasd_devmap_lock); return devmap; } /* * Check if busid has been added to the list of dasd ranges. */ int dasd_busid_known(const char *bus_id) { return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0; } /* * Forget all about the device numbers added so far. * This may only be called at module unload or system shutdown. */ static void dasd_forget_ranges(void) { struct dasd_devmap *devmap, *n; int i; spin_lock(&dasd_devmap_lock); for (i = 0; i < 256; i++) { list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) { BUG_ON(devmap->device != NULL); list_del(&devmap->list); kfree(devmap); } } spin_unlock(&dasd_devmap_lock); }