2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* 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>
|
2012-07-20 17:15:04 +08:00
|
|
|
* Copyright IBM Corp. 1999,2001
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-03-26 22:23:49 +08:00
|
|
|
#define KMSG_COMPONENT "dasd"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/init.h>
|
2006-03-25 19:07:05 +08:00
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/debug.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2007-04-27 22:01:48 +08:00
|
|
|
#include <asm/ipl.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* This is ugly... */
|
|
|
|
#define PRINTK_HEADER "dasd_devmap:"
|
2008-12-25 20:38:55 +08:00
|
|
|
#define DASD_BUS_ID_SIZE 20
|
2016-11-21 20:21:59 +08:00
|
|
|
#define DASD_MAX_PARAMS 256
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "dasd_int.h"
|
|
|
|
|
2006-12-07 12:33:20 +08:00
|
|
|
struct kmem_cache *dasd_page_cache;
|
2006-06-29 21:08:18 +08:00
|
|
|
EXPORT_SYMBOL_GPL(dasd_page_cache);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
2008-12-25 20:38:55 +08:00
|
|
|
char bus_id[DASD_BUS_ID_SIZE];
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int devindex;
|
|
|
|
unsigned short features;
|
|
|
|
struct dasd_device *device;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
2006-06-29 21:08:18 +08:00
|
|
|
int dasd_nopav = 0; /* is true, when PAV is disabled */
|
|
|
|
EXPORT_SYMBOL_GPL(dasd_nopav);
|
2009-03-26 22:23:48 +08:00
|
|
|
int dasd_nofcx; /* disable High Performance Ficon */
|
|
|
|
EXPORT_SYMBOL_GPL(dasd_nofcx);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-11-21 20:21:59 +08:00
|
|
|
static char *dasd[DASD_MAX_PARAMS];
|
2014-08-20 21:35:44 +08:00
|
|
|
module_param_array(dasd, charp, NULL, S_IRUGO);
|
2006-03-25 19:07:05 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2006-08-10 21:45:16 +08:00
|
|
|
* Single spinlock to protect devmap and servermap structures and lists.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
static DEFINE_SPINLOCK(dasd_devmap_lock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hash lists for devmap structures.
|
|
|
|
*/
|
|
|
|
static struct list_head dasd_hashlists[256];
|
|
|
|
int dasd_max_devindex;
|
|
|
|
|
2008-05-15 22:52:34 +08:00
|
|
|
static struct dasd_devmap *dasd_add_busid(const char *, int);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static inline int
|
2008-05-15 22:52:34 +08:00
|
|
|
dasd_hash_busid(const char *bus_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int hash, i;
|
|
|
|
|
|
|
|
hash = 0;
|
2008-12-25 20:38:55 +08:00
|
|
|
for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++)
|
2005-04-17 06:20:36 +08:00
|
|
|
hash += *bus_id;
|
|
|
|
return hash & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef MODULE
|
2016-11-21 20:21:59 +08:00
|
|
|
static int __init dasd_call_setup(char *opt)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-11-23 01:11:46 +08:00
|
|
|
static int i __initdata;
|
2016-11-21 20:21:59 +08:00
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
while (i < DASD_MAX_PARAMS) {
|
|
|
|
tmp = strsep(&opt, ",");
|
|
|
|
if (!tmp)
|
|
|
|
break;
|
|
|
|
|
|
|
|
dasd[i++] = tmp;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup ("dasd=", dasd_call_setup);
|
|
|
|
#endif /* #ifndef MODULE */
|
|
|
|
|
2007-04-27 22:01:48 +08:00
|
|
|
#define DASD_IPLDEV "ipldev"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Read a device busid/devno from a string.
|
|
|
|
*/
|
2016-11-23 01:11:46 +08:00
|
|
|
static int __init dasd_busid(char *str, int *id0, int *id1, int *devno)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-11-23 01:11:46 +08:00
|
|
|
unsigned int val;
|
|
|
|
char *tok;
|
2006-06-29 20:58:12 +08:00
|
|
|
|
2007-04-27 22:01:48 +08:00
|
|
|
/* Interpret ipldev busid */
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) {
|
2007-04-27 22:01:48 +08:00
|
|
|
if (ipl_info.type != IPL_TYPE_CCW) {
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_err("The IPL device is not a CCW device\n");
|
2007-04-27 22:01:48 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
*id0 = 0;
|
|
|
|
*id1 = ipl_info.data.ccw.dev_id.ssid;
|
|
|
|
*devno = ipl_info.data.ccw.dev_id.devno;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
/* Old style 0xXXXX or XXXX */
|
|
|
|
if (!kstrtouint(str, 16, &val)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
*id0 = *id1 = 0;
|
|
|
|
if (val < 0 || val > 0xffff)
|
|
|
|
return -EINVAL;
|
|
|
|
*devno = val;
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* New style x.y.z busid */
|
2016-11-23 01:11:46 +08:00
|
|
|
tok = strsep(&str, ".");
|
|
|
|
if (kstrtouint(tok, 16, &val) || val > 0xff)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EINVAL;
|
|
|
|
*id0 = val;
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
tok = strsep(&str, ".");
|
|
|
|
if (kstrtouint(tok, 16, &val) || val > 0xff)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EINVAL;
|
|
|
|
*id1 = val;
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
tok = strsep(&str, ".");
|
|
|
|
if (kstrtouint(tok, 16, &val) || val > 0xffff)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EINVAL;
|
|
|
|
*devno = val;
|
2016-11-23 01:11:46 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-11-23 01:11:46 +08:00
|
|
|
* Read colon separated list of dasd features.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2016-11-23 01:11:46 +08:00
|
|
|
static int __init dasd_feature_list(char *str)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int features, len, rc;
|
|
|
|
|
2016-11-23 01:11:46 +08:00
|
|
|
features = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = 0;
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
if (!str)
|
2005-04-17 06:20:36 +08:00
|
|
|
return DASD_FEATURE_DEFAULT;
|
|
|
|
|
|
|
|
while (1) {
|
2006-06-29 20:58:12 +08:00
|
|
|
for (len = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
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;
|
2011-01-05 19:48:06 +08:00
|
|
|
else if (len == 3 && !strncmp(str, "raw", 3))
|
|
|
|
features |= DASD_FEATURE_USERAW;
|
2006-12-08 22:54:15 +08:00
|
|
|
else if (len == 6 && !strncmp(str, "erplog", 6))
|
|
|
|
features |= DASD_FEATURE_ERPLOG;
|
2009-01-09 19:14:51 +08:00
|
|
|
else if (len == 8 && !strncmp(str, "failfast", 8))
|
|
|
|
features |= DASD_FEATURE_FAILFAST;
|
2005-04-17 06:20:36 +08:00
|
|
|
else {
|
2016-03-04 12:49:57 +08:00
|
|
|
pr_warn("%*s is not a supported device option\n",
|
|
|
|
len, str);
|
2005-04-17 06:20:36 +08:00
|
|
|
rc = -EINVAL;
|
|
|
|
}
|
|
|
|
str += len;
|
|
|
|
if (*str != ':')
|
|
|
|
break;
|
|
|
|
str++;
|
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
return rc ? : features;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-11-23 01:11:46 +08:00
|
|
|
static int __init dasd_parse_keyword(char *keyword)
|
|
|
|
{
|
|
|
|
int length = strlen(keyword);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp("autodetect", keyword, length) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dasd_autodetect = 1;
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_info("The autodetection mode has been activated\n");
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp("probeonly", keyword, length) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dasd_probeonly = 1;
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_info("The probeonly mode has been activated\n");
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp("nopav", keyword, length) == 0) {
|
2006-09-20 21:59:52 +08:00
|
|
|
if (MACHINE_IS_VM)
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_info("'nopav' is not supported on z/VM\n");
|
2006-09-20 21:59:52 +08:00
|
|
|
else {
|
|
|
|
dasd_nopav = 1;
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_info("PAV support has be deactivated\n");
|
2006-09-20 21:59:52 +08:00
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
2006-06-29 21:08:18 +08:00
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp("nofcx", keyword, length) == 0) {
|
2009-03-26 22:23:48 +08:00
|
|
|
dasd_nofcx = 1;
|
2009-03-26 22:23:49 +08:00
|
|
|
pr_info("High Performance FICON support has been "
|
|
|
|
"deactivated\n");
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
2009-03-26 22:23:48 +08:00
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
if (strncmp("fixedbuffers", keyword, length) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dasd_page_cache)
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
dasd_page_cache =
|
2006-08-16 19:49:27 +08:00
|
|
|
kmem_cache_create("dasd_page_cache", PAGE_SIZE,
|
|
|
|
PAGE_SIZE, SLAB_CACHE_DMA,
|
2007-07-20 09:11:58 +08:00
|
|
|
NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!dasd_page_cache)
|
2009-03-26 22:23:49 +08:00
|
|
|
DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, "
|
2005-04-17 06:20:36 +08:00
|
|
|
"fixed buffer mode disabled.");
|
|
|
|
else
|
2009-03-26 22:23:49 +08:00
|
|
|
DBF_EVENT(DBF_INFO, "%s",
|
2005-04-17 06:20:36 +08:00
|
|
|
"turning on fixed buffer mode");
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-11-23 01:11:46 +08:00
|
|
|
* 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
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2016-11-23 01:11:46 +08:00
|
|
|
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;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-11-23 01:11:46 +08:00
|
|
|
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)
|
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int from, from_id0, from_id1;
|
|
|
|
int to, to_id0, to_id1;
|
2016-11-23 01:11:46 +08:00
|
|
|
int features;
|
|
|
|
char bus_id[DASD_BUS_ID_SIZE + 1];
|
|
|
|
char *features_str = NULL;
|
|
|
|
char *from_str = NULL;
|
|
|
|
char *to_str = NULL;
|
|
|
|
size_t len = strlen(range) + 1;
|
|
|
|
char tmp[len];
|
|
|
|
|
|
|
|
strlcpy(tmp, range, len);
|
|
|
|
|
|
|
|
if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str))
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
if (dasd_busid(from_str, &from_id0, &from_id1, &from))
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
to = from;
|
|
|
|
to_id0 = from_id0;
|
|
|
|
to_id1 = from_id1;
|
|
|
|
if (to_str) {
|
|
|
|
if (dasd_busid(to_str, &to_id0, &to_id1, &to))
|
|
|
|
goto out_err;
|
|
|
|
if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) {
|
|
|
|
pr_err("%s is not a valid device range\n", range);
|
|
|
|
goto out_err;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
|
|
|
|
features = dasd_feature_list(features_str);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (features < 0)
|
2016-11-23 01:11:46 +08:00
|
|
|
goto out_err;
|
2006-06-29 21:08:18 +08:00
|
|
|
/* each device in dasd= parameter should be set initially online */
|
|
|
|
features |= DASD_FEATURE_INITIAL_ONLINE;
|
2005-04-17 06:20:36 +08:00
|
|
|
while (from <= to) {
|
2016-11-23 01:11:46 +08:00
|
|
|
sprintf(bus_id, "%01x.%01x.%04x", from_id0, from_id1, from++);
|
2005-04-17 06:20:36 +08:00
|
|
|
devmap = dasd_add_busid(bus_id, features);
|
|
|
|
if (IS_ERR(devmap))
|
2016-11-23 01:11:46 +08:00
|
|
|
return PTR_ERR(devmap);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-11-23 01:11:46 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_err:
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse parameters stored in dasd[]
|
|
|
|
* The 'dasd=...' parameter allows to specify a comma separated list of
|
2016-11-21 20:21:59 +08:00
|
|
|
* keywords and device ranges. The parameters in that list will be stored as
|
|
|
|
* separate elementes in dasd[].
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2016-11-23 01:11:46 +08:00
|
|
|
int __init dasd_parse(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int rc, i;
|
2016-11-23 01:11:46 +08:00
|
|
|
char *cur;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
rc = 0;
|
2016-11-21 20:21:59 +08:00
|
|
|
for (i = 0; i < DASD_MAX_PARAMS; i++) {
|
2016-11-23 01:11:46 +08:00
|
|
|
cur = dasd[i];
|
|
|
|
if (!cur)
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2016-11-23 01:11:46 +08:00
|
|
|
if (*cur == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rc = dasd_parse_keyword(cur);
|
|
|
|
if (rc)
|
|
|
|
rc = dasd_parse_range(cur);
|
|
|
|
|
|
|
|
if (rc)
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
2016-11-23 01:11:46 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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
|
2006-06-29 20:58:12 +08:00
|
|
|
* devices.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
static struct dasd_devmap *
|
2008-05-15 22:52:34 +08:00
|
|
|
dasd_add_busid(const char *bus_id, int features)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap, *new, *tmp;
|
|
|
|
int hash;
|
|
|
|
|
2013-03-12 13:18:47 +08:00
|
|
|
new = kzalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!new)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
2006-07-12 22:41:55 +08:00
|
|
|
devmap = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
hash = dasd_hash_busid(bus_id);
|
|
|
|
list_for_each_entry(tmp, &dasd_hashlists[hash], list)
|
2008-12-25 20:38:55 +08:00
|
|
|
if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
devmap = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!devmap) {
|
|
|
|
/* This bus_id is new. */
|
|
|
|
new->devindex = dasd_max_devindex++;
|
2008-12-25 20:38:55 +08:00
|
|
|
strncpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE);
|
2005-04-17 06:20:36 +08:00
|
|
|
new->features = features;
|
2006-07-12 22:41:55 +08:00
|
|
|
new->device = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
list_add(&new->list, &dasd_hashlists[hash]);
|
|
|
|
devmap = new;
|
2006-07-12 22:41:55 +08:00
|
|
|
new = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
2005-11-07 17:01:30 +08:00
|
|
|
kfree(new);
|
2005-04-17 06:20:36 +08:00
|
|
|
return devmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find devmap for device with given bus_id.
|
|
|
|
*/
|
|
|
|
static struct dasd_devmap *
|
2008-05-15 22:52:34 +08:00
|
|
|
dasd_find_busid(const char *bus_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap, *tmp;
|
|
|
|
int hash;
|
|
|
|
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
devmap = ERR_PTR(-ENODEV);
|
|
|
|
hash = dasd_hash_busid(bus_id);
|
|
|
|
list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
|
2008-12-25 20:38:55 +08:00
|
|
|
if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
devmap = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return devmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if busid has been added to the list of dasd ranges.
|
|
|
|
*/
|
|
|
|
int
|
2008-05-15 22:52:34 +08:00
|
|
|
dasd_busid_known(const char *bus_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
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) {
|
2006-03-27 00:33:07 +08:00
|
|
|
BUG_ON(devmap->device != NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_del(&devmap->list);
|
|
|
|
kfree(devmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the device struct by its device index.
|
|
|
|
*/
|
|
|
|
struct dasd_device *
|
|
|
|
dasd_device_from_devindex(int devindex)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap, *tmp;
|
|
|
|
struct dasd_device *device;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
2006-07-12 22:41:55 +08:00
|
|
|
devmap = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; (i < 256) && !devmap; i++)
|
|
|
|
list_for_each_entry(tmp, &dasd_hashlists[i], list)
|
|
|
|
if (tmp->devindex == devindex) {
|
|
|
|
/* Found the devmap for the device. */
|
|
|
|
devmap = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (devmap && devmap->device) {
|
|
|
|
device = devmap->device;
|
|
|
|
dasd_get_device(device);
|
|
|
|
} else
|
|
|
|
device = ERR_PTR(-ENODEV);
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return devmap for cdev. If no devmap exists yet, create one and
|
|
|
|
* connect it to the cdev.
|
|
|
|
*/
|
|
|
|
static struct dasd_devmap *
|
|
|
|
dasd_devmap_from_cdev(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(&cdev->dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (IS_ERR(devmap))
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_add_busid(dev_name(&cdev->dev),
|
2005-04-17 06:20:36 +08:00
|
|
|
DASD_FEATURE_DEFAULT);
|
|
|
|
return devmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a dasd device structure for cdev.
|
|
|
|
*/
|
|
|
|
struct dasd_device *
|
|
|
|
dasd_create_device(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
struct dasd_device *device;
|
2006-09-20 21:59:05 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
devmap = dasd_devmap_from_cdev(cdev);
|
|
|
|
if (IS_ERR(devmap))
|
|
|
|
return (void *) devmap;
|
|
|
|
|
|
|
|
device = dasd_alloc_device();
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return device;
|
2006-09-20 21:59:05 +08:00
|
|
|
atomic_set(&device->ref_count, 3);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
if (!devmap->device) {
|
|
|
|
devmap->device = device;
|
|
|
|
device->devindex = devmap->devindex;
|
2005-09-04 06:57:58 +08:00
|
|
|
device->features = devmap->features;
|
2005-04-17 06:20:36 +08:00
|
|
|
get_device(&cdev->dev);
|
|
|
|
device->cdev = cdev;
|
|
|
|
rc = 0;
|
|
|
|
} else
|
|
|
|
/* Someone else was faster. */
|
|
|
|
rc = -EBUSY;
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
dasd_free_device(device);
|
|
|
|
return ERR_PTR(rc);
|
|
|
|
}
|
2006-09-20 21:59:05 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
|
2008-12-25 20:38:52 +08:00
|
|
|
dev_set_drvdata(&cdev->dev, device);
|
2006-09-20 21:59:05 +08:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait queue for dasd_delete_device waits.
|
|
|
|
*/
|
|
|
|
static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a dasd device structure. The passed referenced
|
|
|
|
* is destroyed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dasd_delete_device(struct dasd_device *device)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev;
|
|
|
|
struct dasd_devmap *devmap;
|
2006-09-20 21:59:05 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* First remove device pointer from devmap. */
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(&device->cdev->dev));
|
2006-03-27 00:33:07 +08:00
|
|
|
BUG_ON(IS_ERR(devmap));
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
if (devmap->device != device) {
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
devmap->device = NULL;
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
|
2006-09-20 21:59:05 +08:00
|
|
|
/* Disconnect dasd_device structure from ccw_device structure. */
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
|
2008-12-25 20:38:52 +08:00
|
|
|
dev_set_drvdata(&device->cdev->dev, NULL);
|
2006-09-20 21:59:05 +08:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Drop ref_count by 3, one for the devmap reference, one for
|
|
|
|
* the cdev reference and one for the passed reference.
|
|
|
|
*/
|
|
|
|
atomic_sub(3, &device->ref_count);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Wait for reference counter to drop to zero. */
|
|
|
|
wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
|
|
|
|
|
2016-09-20 16:42:38 +08:00
|
|
|
dasd_generic_free_discipline(device);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Disconnect dasd_device structure from ccw_device structure. */
|
|
|
|
cdev = device->cdev;
|
|
|
|
device->cdev = NULL;
|
|
|
|
|
|
|
|
/* Put ccw_device structure. */
|
|
|
|
put_device(&cdev->dev);
|
|
|
|
|
|
|
|
/* Now the device structure can be freed. */
|
|
|
|
dasd_free_device(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reference counter dropped to zero. Wake up waiter
|
|
|
|
* in dasd_delete_device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dasd_put_device_wake(struct dasd_device *device)
|
|
|
|
{
|
|
|
|
wake_up(&dasd_delete_wq);
|
|
|
|
}
|
2011-01-05 19:48:03 +08:00
|
|
|
EXPORT_SYMBOL_GPL(dasd_put_device_wake);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-20 21:59:05 +08:00
|
|
|
/*
|
|
|
|
* Return dasd_device structure associated with cdev.
|
|
|
|
* This function needs to be called with the ccw device
|
|
|
|
* lock held. It can be used from interrupt context.
|
|
|
|
*/
|
|
|
|
struct dasd_device *
|
|
|
|
dasd_device_from_cdev_locked(struct ccw_device *cdev)
|
|
|
|
{
|
2008-12-25 20:38:52 +08:00
|
|
|
struct dasd_device *device = dev_get_drvdata(&cdev->dev);
|
2006-09-20 21:59:05 +08:00
|
|
|
|
|
|
|
if (!device)
|
|
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
dasd_get_device(device);
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Return dasd_device structure associated with cdev.
|
|
|
|
*/
|
|
|
|
struct dasd_device *
|
|
|
|
dasd_device_from_cdev(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
2006-09-20 21:59:05 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-20 21:59:05 +08:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
|
|
|
|
device = dasd_device_from_cdev_locked(cdev);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2011-04-20 16:15:30 +08:00
|
|
|
void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
|
|
|
|
devmap = dasd_find_busid(dev_name(&device->cdev->dev));
|
|
|
|
if (IS_ERR(devmap))
|
|
|
|
return;
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
gdp->private_data = devmap;
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
|
|
|
|
if (!gdp->private_data)
|
|
|
|
return NULL;
|
|
|
|
device = NULL;
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
devmap = gdp->private_data;
|
|
|
|
if (devmap && devmap->device) {
|
|
|
|
device = devmap->device;
|
|
|
|
dasd_get_device(device);
|
|
|
|
}
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* SECTION: files in sysfs
|
|
|
|
*/
|
|
|
|
|
2009-01-09 19:14:51 +08:00
|
|
|
/*
|
|
|
|
* failfast controls the behaviour, if no path is available
|
|
|
|
*/
|
|
|
|
static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int ff_flag;
|
|
|
|
|
2009-02-11 17:37:30 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
2009-01-09 19:14:51 +08:00
|
|
|
if (!IS_ERR(devmap))
|
|
|
|
ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
|
|
|
|
else
|
|
|
|
ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0;
|
|
|
|
return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-10-11 00:29:48 +08:00
|
|
|
unsigned int val;
|
2016-10-07 23:21:24 +08:00
|
|
|
int rc;
|
2009-01-09 19:14:51 +08:00
|
|
|
|
2016-10-11 00:29:48 +08:00
|
|
|
if (kstrtouint(buf, 0, &val) || val > 1)
|
2009-01-09 19:14:51 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-10-07 23:21:24 +08:00
|
|
|
rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_FAILFAST, val);
|
|
|
|
|
|
|
|
return rc ? : count;
|
2009-01-09 19:14:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* readonly controls the readonly status of a dasd
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2005-05-17 18:42:58 +08:00
|
|
|
dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int ro_flag;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!IS_ERR(devmap))
|
|
|
|
ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0;
|
|
|
|
else
|
|
|
|
ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0;
|
|
|
|
return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2006-06-29 20:58:12 +08:00
|
|
|
dasd_ro_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-10-07 23:21:24 +08:00
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
2010-03-08 19:26:24 +08:00
|
|
|
struct dasd_device *device;
|
2016-10-13 19:31:39 +08:00
|
|
|
unsigned long flags;
|
2016-10-11 00:29:48 +08:00
|
|
|
unsigned int val;
|
2016-10-07 23:21:24 +08:00
|
|
|
int rc;
|
2006-12-04 22:39:50 +08:00
|
|
|
|
2016-10-11 00:29:48 +08:00
|
|
|
if (kstrtouint(buf, 0, &val) || val > 1)
|
2006-12-04 22:39:50 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-10-07 23:21:24 +08:00
|
|
|
rc = dasd_set_feature(cdev, DASD_FEATURE_READONLY, val);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(cdev);
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return PTR_ERR(device);
|
|
|
|
|
2016-10-13 19:31:39 +08:00
|
|
|
spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
|
2016-10-07 23:21:24 +08:00
|
|
|
val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
|
|
|
|
|
2016-10-13 19:31:39 +08:00
|
|
|
if (!device->block || !device->block->gdp ||
|
|
|
|
test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/* Increase open_count to avoid losing the block device */
|
|
|
|
atomic_inc(&device->block->open_count);
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
|
|
|
|
|
|
|
|
set_disk_ro(device->block->gdp, val);
|
|
|
|
atomic_dec(&device->block->open_count);
|
|
|
|
|
|
|
|
out:
|
2016-10-07 23:21:24 +08:00
|
|
|
dasd_put_device(device);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
|
2006-12-08 22:54:15 +08:00
|
|
|
/*
|
|
|
|
* erplog controls the logging of ERP related data
|
|
|
|
* (e.g. failing channel programs).
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int erplog;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
2006-12-08 22:54:15 +08:00
|
|
|
if (!IS_ERR(devmap))
|
|
|
|
erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0;
|
|
|
|
else
|
|
|
|
erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0;
|
|
|
|
return snprintf(buf, PAGE_SIZE, erplog ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_erplog_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-10-11 00:29:48 +08:00
|
|
|
unsigned int val;
|
2016-10-07 23:21:24 +08:00
|
|
|
int rc;
|
2006-12-08 22:54:15 +08:00
|
|
|
|
2016-10-11 00:29:48 +08:00
|
|
|
if (kstrtouint(buf, 0, &val) || val > 1)
|
2006-12-08 22:54:15 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-10-07 23:21:24 +08:00
|
|
|
rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_ERPLOG, val);
|
|
|
|
|
|
|
|
return rc ? : count;
|
2006-12-08 22:54:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* use_diag controls whether the driver should use diag rather than ssch
|
|
|
|
* to talk to the device
|
|
|
|
*/
|
2006-06-29 20:58:12 +08:00
|
|
|
static ssize_t
|
2005-05-17 18:42:58 +08:00
|
|
|
dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int use_diag;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!IS_ERR(devmap))
|
|
|
|
use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
|
|
|
|
else
|
|
|
|
use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
|
|
|
|
return sprintf(buf, use_diag ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2006-06-29 20:58:12 +08:00
|
|
|
dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
2016-10-11 00:29:48 +08:00
|
|
|
unsigned int val;
|
2005-04-17 06:20:36 +08:00
|
|
|
ssize_t rc;
|
|
|
|
|
|
|
|
devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(devmap))
|
|
|
|
return PTR_ERR(devmap);
|
2006-12-04 22:39:50 +08:00
|
|
|
|
2016-10-11 00:29:48 +08:00
|
|
|
if (kstrtouint(buf, 0, &val) || val > 1)
|
2006-12-04 22:39:50 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
/* Changing diag discipline flag is only allowed in offline state. */
|
|
|
|
rc = count;
|
2011-01-05 19:48:06 +08:00
|
|
|
if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) {
|
2006-12-04 22:39:50 +08:00
|
|
|
if (val)
|
2005-04-17 06:20:36 +08:00
|
|
|
devmap->features |= DASD_FEATURE_USEDIAG;
|
|
|
|
else
|
|
|
|
devmap->features &= ~DASD_FEATURE_USEDIAG;
|
|
|
|
} else
|
|
|
|
rc = -EPERM;
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-06-29 20:58:12 +08:00
|
|
|
static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-01-05 19:48:06 +08:00
|
|
|
/*
|
|
|
|
* use_raw controls whether the driver should give access to raw eckd data or
|
|
|
|
* operate in standard mode
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int use_raw;
|
|
|
|
|
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
|
|
|
if (!IS_ERR(devmap))
|
|
|
|
use_raw = (devmap->features & DASD_FEATURE_USERAW) != 0;
|
|
|
|
else
|
|
|
|
use_raw = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USERAW) != 0;
|
|
|
|
return sprintf(buf, use_raw ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_use_raw_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
ssize_t rc;
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(devmap))
|
|
|
|
return PTR_ERR(devmap);
|
|
|
|
|
2013-07-22 09:18:15 +08:00
|
|
|
if ((kstrtoul(buf, 10, &val) != 0) || val > 1)
|
2011-01-05 19:48:06 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
/* Changing diag discipline flag is only allowed in offline state. */
|
|
|
|
rc = count;
|
|
|
|
if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) {
|
|
|
|
if (val)
|
|
|
|
devmap->features |= DASD_FEATURE_USERAW;
|
|
|
|
else
|
|
|
|
devmap->features &= ~DASD_FEATURE_USERAW;
|
|
|
|
} else
|
|
|
|
rc = -EPERM;
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(raw_track_access, 0644, dasd_use_raw_show,
|
|
|
|
dasd_use_raw_store);
|
|
|
|
|
2012-11-28 20:43:38 +08:00
|
|
|
static ssize_t
|
|
|
|
dasd_safe_offline_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct dasd_device *device;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(cdev);
|
|
|
|
if (IS_ERR(device)) {
|
|
|
|
rc = PTR_ERR(device);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
|
|
|
|
test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) {
|
|
|
|
/* Already doing offline processing */
|
|
|
|
dasd_put_device(device);
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags);
|
|
|
|
dasd_put_device(device);
|
|
|
|
|
|
|
|
rc = ccw_device_set_offline(cdev);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return rc ? rc : count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(safe_offline, 0200, NULL, dasd_safe_offline_store);
|
|
|
|
|
2016-03-18 16:42:13 +08:00
|
|
|
static ssize_t
|
|
|
|
dasd_access_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct dasd_device *device;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(cdev);
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return PTR_ERR(device);
|
|
|
|
|
2016-08-08 21:56:54 +08:00
|
|
|
if (!device->discipline)
|
|
|
|
count = -ENODEV;
|
|
|
|
else if (!device->discipline->host_access_count)
|
2016-03-18 16:42:13 +08:00
|
|
|
count = -EOPNOTSUPP;
|
2016-08-08 21:56:54 +08:00
|
|
|
else
|
|
|
|
count = device->discipline->host_access_count(device);
|
2016-03-18 16:42:13 +08:00
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
if (count < 0)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
return sprintf(buf, "%d\n", count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(host_access_count, 0444, dasd_access_show, NULL);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static ssize_t
|
2006-06-29 20:58:12 +08:00
|
|
|
dasd_discipline_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-20 21:59:05 +08:00
|
|
|
struct dasd_device *device;
|
|
|
|
ssize_t len;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-20 21:59:05 +08:00
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
2010-02-27 05:37:47 +08:00
|
|
|
if (IS_ERR(device))
|
|
|
|
goto out;
|
|
|
|
else if (!device->discipline) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
goto out;
|
|
|
|
} else {
|
2006-09-20 21:59:05 +08:00
|
|
|
len = snprintf(buf, PAGE_SIZE, "%s\n",
|
|
|
|
device->discipline->name);
|
|
|
|
dasd_put_device(device);
|
2010-02-27 05:37:47 +08:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "none\n");
|
2006-09-20 21:59:05 +08:00
|
|
|
return len;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
|
|
|
|
|
2007-04-27 22:01:47 +08:00
|
|
|
static ssize_t
|
|
|
|
dasd_device_status_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
ssize_t len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (!IS_ERR(device)) {
|
|
|
|
switch (device->state) {
|
|
|
|
case DASD_STATE_NEW:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "new\n");
|
|
|
|
break;
|
|
|
|
case DASD_STATE_KNOWN:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "detected\n");
|
|
|
|
break;
|
|
|
|
case DASD_STATE_BASIC:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "basic\n");
|
|
|
|
break;
|
|
|
|
case DASD_STATE_UNFMT:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "unformatted\n");
|
|
|
|
break;
|
|
|
|
case DASD_STATE_READY:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "ready\n");
|
|
|
|
break;
|
|
|
|
case DASD_STATE_ONLINE:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "online\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "no stat\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dasd_put_device(device);
|
|
|
|
} else
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "unknown\n");
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
|
|
|
|
|
2010-05-17 16:00:11 +08:00
|
|
|
static ssize_t dasd_alias_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2006-04-28 09:40:28 +08:00
|
|
|
{
|
2010-05-17 16:00:11 +08:00
|
|
|
struct dasd_device *device;
|
|
|
|
struct dasd_uid uid;
|
2006-04-28 09:40:28 +08:00
|
|
|
|
2010-05-17 16:00:11 +08:00
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
2008-01-26 21:11:23 +08:00
|
|
|
return sprintf(buf, "0\n");
|
2010-05-17 16:00:11 +08:00
|
|
|
|
|
|
|
if (device->discipline && device->discipline->get_uid &&
|
|
|
|
!device->discipline->get_uid(device, &uid)) {
|
|
|
|
if (uid.type == UA_BASE_PAV_ALIAS ||
|
2010-07-19 15:22:36 +08:00
|
|
|
uid.type == UA_HYPER_PAV_ALIAS) {
|
|
|
|
dasd_put_device(device);
|
2010-05-17 16:00:11 +08:00
|
|
|
return sprintf(buf, "1\n");
|
2010-07-19 15:22:36 +08:00
|
|
|
}
|
2008-01-26 21:11:23 +08:00
|
|
|
}
|
2010-05-17 16:00:11 +08:00
|
|
|
dasd_put_device(device);
|
|
|
|
|
|
|
|
return sprintf(buf, "0\n");
|
2006-04-28 09:40:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
|
|
|
|
|
2010-05-17 16:00:11 +08:00
|
|
|
static ssize_t dasd_vendor_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2006-04-28 09:40:28 +08:00
|
|
|
{
|
2010-05-17 16:00:11 +08:00
|
|
|
struct dasd_device *device;
|
|
|
|
struct dasd_uid uid;
|
2006-04-28 09:40:28 +08:00
|
|
|
char *vendor;
|
|
|
|
|
2010-05-17 16:00:11 +08:00
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
vendor = "";
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
|
|
|
|
|
|
|
|
if (device->discipline && device->discipline->get_uid &&
|
|
|
|
!device->discipline->get_uid(device, &uid))
|
|
|
|
vendor = uid.vendor;
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
2006-04-28 09:40:28 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%s\n", vendor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL);
|
|
|
|
|
|
|
|
#define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\
|
2008-08-01 22:39:09 +08:00
|
|
|
/* SSID */ 4 + 1 + /* unit addr */ 2 + 1 +\
|
|
|
|
/* vduit */ 32 + 1)
|
2006-04-28 09:40:28 +08:00
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2010-05-17 16:00:11 +08:00
|
|
|
struct dasd_device *device;
|
|
|
|
struct dasd_uid uid;
|
2008-01-26 21:11:23 +08:00
|
|
|
char uid_string[UID_STRLEN];
|
|
|
|
char ua_string[3];
|
2006-04-28 09:40:28 +08:00
|
|
|
|
2010-05-17 16:00:11 +08:00
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
uid_string[0] = 0;
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
|
|
|
|
|
|
|
|
if (device->discipline && device->discipline->get_uid &&
|
|
|
|
!device->discipline->get_uid(device, &uid)) {
|
|
|
|
switch (uid.type) {
|
|
|
|
case UA_BASE_DEVICE:
|
|
|
|
snprintf(ua_string, sizeof(ua_string), "%02x",
|
|
|
|
uid.real_unit_addr);
|
|
|
|
break;
|
|
|
|
case UA_BASE_PAV_ALIAS:
|
|
|
|
snprintf(ua_string, sizeof(ua_string), "%02x",
|
|
|
|
uid.base_unit_addr);
|
|
|
|
break;
|
|
|
|
case UA_HYPER_PAV_ALIAS:
|
|
|
|
snprintf(ua_string, sizeof(ua_string), "xx");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* should not happen, treat like base device */
|
|
|
|
snprintf(ua_string, sizeof(ua_string), "%02x",
|
|
|
|
uid.real_unit_addr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(uid.vduit) > 0)
|
|
|
|
snprintf(uid_string, sizeof(uid_string),
|
|
|
|
"%s.%s.%04x.%s.%s",
|
|
|
|
uid.vendor, uid.serial, uid.ssid, ua_string,
|
|
|
|
uid.vduit);
|
|
|
|
else
|
|
|
|
snprintf(uid_string, sizeof(uid_string),
|
|
|
|
"%s.%s.%04x.%s",
|
|
|
|
uid.vendor, uid.serial, uid.ssid, ua_string);
|
2008-01-26 21:11:23 +08:00
|
|
|
}
|
2010-05-17 16:00:11 +08:00
|
|
|
dasd_put_device(device);
|
|
|
|
|
2008-01-26 21:11:23 +08:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%s\n", uid_string);
|
2006-04-28 09:40:28 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
|
|
|
|
|
2006-03-24 19:15:25 +08:00
|
|
|
/*
|
|
|
|
* extended error-reporting
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int eer_flag;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
2006-03-24 19:15:25 +08:00
|
|
|
if (!IS_ERR(devmap) && devmap->device)
|
|
|
|
eer_flag = dasd_eer_enabled(devmap->device);
|
|
|
|
else
|
|
|
|
eer_flag = 0;
|
|
|
|
return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_eer_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-10-12 18:51:04 +08:00
|
|
|
struct dasd_device *device;
|
2016-10-11 00:29:48 +08:00
|
|
|
unsigned int val;
|
2016-10-12 18:51:04 +08:00
|
|
|
int rc = 0;
|
2006-03-24 19:15:25 +08:00
|
|
|
|
2016-10-12 18:51:04 +08:00
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return PTR_ERR(device);
|
2006-12-04 22:39:50 +08:00
|
|
|
|
2016-10-11 00:29:48 +08:00
|
|
|
if (kstrtouint(buf, 0, &val) || val > 1)
|
2006-12-04 22:39:50 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-10-12 18:51:04 +08:00
|
|
|
if (val)
|
|
|
|
rc = dasd_eer_enable(device);
|
|
|
|
else
|
|
|
|
dasd_eer_disable(device);
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
|
|
|
|
return rc ? : count;
|
2006-03-24 19:15:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
|
|
|
|
|
2010-08-10 00:13:00 +08:00
|
|
|
/*
|
|
|
|
* expiration time for default requests
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_expires);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_expires_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-07-22 09:18:15 +08:00
|
|
|
if ((kstrtoul(buf, 10, &val) != 0) ||
|
2010-08-10 00:13:00 +08:00
|
|
|
(val > DASD_EXPIRES_MAX) || val == 0) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
device->default_expires = val;
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(expires, 0644, dasd_expires_show, dasd_expires_store);
|
|
|
|
|
2013-01-30 17:26:12 +08:00
|
|
|
static ssize_t
|
|
|
|
dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "%lu\n", device->default_retries);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_retries_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-07-22 09:18:15 +08:00
|
|
|
if ((kstrtoul(buf, 10, &val) != 0) ||
|
2013-01-30 17:26:12 +08:00
|
|
|
(val > DASD_RETRIES_MAX)) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
device->default_retries = val;
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(retries, 0644, dasd_retries_show, dasd_retries_store);
|
|
|
|
|
2013-01-30 17:26:18 +08:00
|
|
|
static ssize_t
|
|
|
|
dasd_timeout_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "%lu\n", device->blk_timeout);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_timeout_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
struct request_queue *q;
|
|
|
|
unsigned long val, flags;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device) || !device->block)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-07-22 09:18:15 +08:00
|
|
|
if ((kstrtoul(buf, 10, &val) != 0) ||
|
2013-01-30 17:26:18 +08:00
|
|
|
val > UINT_MAX / HZ) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
q = device->block->request_queue;
|
|
|
|
if (!q) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&device->block->request_queue_lock, flags);
|
|
|
|
if (!val)
|
|
|
|
blk_queue_rq_timed_out(q, NULL);
|
|
|
|
else
|
|
|
|
blk_queue_rq_timed_out(q, dasd_times_out);
|
|
|
|
|
|
|
|
device->blk_timeout = val;
|
|
|
|
|
|
|
|
blk_queue_rq_timeout(q, device->blk_timeout * HZ);
|
|
|
|
spin_unlock_irqrestore(&device->block->request_queue_lock, flags);
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(timeout, 0644,
|
|
|
|
dasd_timeout_show, dasd_timeout_store);
|
|
|
|
|
2016-08-08 21:56:54 +08:00
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_path_reset_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if ((kstrtouint(buf, 16, &val) != 0) || val > 0xff)
|
|
|
|
val = 0;
|
|
|
|
|
|
|
|
if (device->discipline && device->discipline->reset_path)
|
|
|
|
device->discipline->reset_path(device, (__u8) val);
|
|
|
|
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(path_reset, 0200, NULL, dasd_path_reset_store);
|
|
|
|
|
|
|
|
static ssize_t dasd_hpf_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int hpf;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
if (!device->discipline || !device->discipline->hpf_enabled) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", dasd_nofcx);
|
|
|
|
}
|
|
|
|
hpf = device->discipline->hpf_enabled(device);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", hpf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(hpf, 0444, dasd_hpf_show, NULL);
|
|
|
|
|
2011-01-05 19:48:04 +08:00
|
|
|
static ssize_t dasd_reservation_policy_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
devmap = dasd_find_busid(dev_name(dev));
|
|
|
|
if (IS_ERR(devmap)) {
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "ignore\n");
|
|
|
|
} else {
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
if (devmap->features & DASD_FEATURE_FAILONSLCK)
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "fail\n");
|
|
|
|
else
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "ignore\n");
|
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t dasd_reservation_policy_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-10-07 23:21:24 +08:00
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
2011-01-05 19:48:04 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (sysfs_streq("ignore", buf))
|
2016-10-07 23:21:24 +08:00
|
|
|
rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 0);
|
2011-01-05 19:48:04 +08:00
|
|
|
else if (sysfs_streq("fail", buf))
|
2016-10-07 23:21:24 +08:00
|
|
|
rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 1);
|
2011-01-05 19:48:04 +08:00
|
|
|
else
|
|
|
|
rc = -EINVAL;
|
2016-10-07 23:21:24 +08:00
|
|
|
|
|
|
|
return rc ? : count;
|
2011-01-05 19:48:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(reservation_policy, 0644,
|
|
|
|
dasd_reservation_policy_show, dasd_reservation_policy_store);
|
|
|
|
|
|
|
|
static ssize_t dasd_reservation_state_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return snprintf(buf, PAGE_SIZE, "none\n");
|
|
|
|
|
|
|
|
if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags))
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "reserved\n");
|
|
|
|
else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags))
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "lost\n");
|
|
|
|
else
|
|
|
|
rc = snprintf(buf, PAGE_SIZE, "none\n");
|
|
|
|
dasd_put_device(device);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t dasd_reservation_state_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
if (sysfs_streq("reset", buf))
|
|
|
|
clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags);
|
|
|
|
else
|
|
|
|
rc = -EINVAL;
|
|
|
|
dasd_put_device(device);
|
|
|
|
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
else
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(last_known_reservation_state, 0644,
|
|
|
|
dasd_reservation_state_show, dasd_reservation_state_store);
|
|
|
|
|
2014-10-01 20:39:47 +08:00
|
|
|
static ssize_t dasd_pm_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
2016-08-08 21:56:54 +08:00
|
|
|
u8 opm, nppm, cablepm, cuirpm, hpfpm, ifccpm;
|
2014-10-01 20:39:47 +08:00
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return sprintf(buf, "0\n");
|
|
|
|
|
2016-08-08 21:53:54 +08:00
|
|
|
opm = dasd_path_get_opm(device);
|
|
|
|
nppm = dasd_path_get_nppm(device);
|
|
|
|
cablepm = dasd_path_get_cablepm(device);
|
|
|
|
cuirpm = dasd_path_get_cuirpm(device);
|
|
|
|
hpfpm = dasd_path_get_hpfpm(device);
|
2016-08-08 21:56:54 +08:00
|
|
|
ifccpm = dasd_path_get_ifccpm(device);
|
2014-10-01 20:39:47 +08:00
|
|
|
dasd_put_device(device);
|
|
|
|
|
2016-08-08 21:56:54 +08:00
|
|
|
return sprintf(buf, "%02x %02x %02x %02x %02x %02x\n", opm, nppm,
|
|
|
|
cablepm, cuirpm, hpfpm, ifccpm);
|
2014-10-01 20:39:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(path_masks, 0444, dasd_pm_show, NULL);
|
|
|
|
|
2016-08-08 21:56:54 +08:00
|
|
|
/*
|
|
|
|
* threshold value for IFCC/CCC errors
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_path_threshold_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_thrhld);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_path_threshold_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2017-01-25 21:08:20 +08:00
|
|
|
if (kstrtoul(buf, 10, &val) != 0 || val > DASD_THRHLD_MAX) {
|
2016-08-08 21:56:54 +08:00
|
|
|
dasd_put_device(device);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
|
2017-01-25 21:08:20 +08:00
|
|
|
device->path_thrhld = val;
|
2016-08-08 21:56:54 +08:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(path_threshold, 0644, dasd_path_threshold_show,
|
|
|
|
dasd_path_threshold_store);
|
|
|
|
/*
|
|
|
|
* interval for IFCC/CCC checks
|
|
|
|
* meaning time with no IFCC/CCC error before the error counter
|
|
|
|
* gets reset
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
dasd_path_interval_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
len = snprintf(buf, PAGE_SIZE, "%lu\n", device->path_interval);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
dasd_path_interval_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
device = dasd_device_from_cdev(to_ccwdev(dev));
|
|
|
|
if (IS_ERR(device))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if ((kstrtoul(buf, 10, &val) != 0) ||
|
|
|
|
(val > DASD_INTERVAL_MAX) || val == 0) {
|
|
|
|
dasd_put_device(device);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags);
|
|
|
|
if (val)
|
|
|
|
device->path_interval = val;
|
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags);
|
|
|
|
dasd_put_device(device);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(path_interval, 0644, dasd_path_interval_show,
|
|
|
|
dasd_path_interval_store);
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct attribute * dasd_attrs[] = {
|
|
|
|
&dev_attr_readonly.attr,
|
|
|
|
&dev_attr_discipline.attr,
|
2007-04-27 22:01:47 +08:00
|
|
|
&dev_attr_status.attr,
|
2006-04-28 09:40:28 +08:00
|
|
|
&dev_attr_alias.attr,
|
|
|
|
&dev_attr_vendor.attr,
|
|
|
|
&dev_attr_uid.attr,
|
2005-04-17 06:20:36 +08:00
|
|
|
&dev_attr_use_diag.attr,
|
2011-01-05 19:48:06 +08:00
|
|
|
&dev_attr_raw_track_access.attr,
|
2006-03-24 19:15:25 +08:00
|
|
|
&dev_attr_eer_enabled.attr,
|
2006-12-08 22:54:15 +08:00
|
|
|
&dev_attr_erplog.attr,
|
2009-01-09 19:14:51 +08:00
|
|
|
&dev_attr_failfast.attr,
|
2010-08-10 00:13:00 +08:00
|
|
|
&dev_attr_expires.attr,
|
2013-01-30 17:26:12 +08:00
|
|
|
&dev_attr_retries.attr,
|
2013-01-30 17:26:18 +08:00
|
|
|
&dev_attr_timeout.attr,
|
2011-01-05 19:48:04 +08:00
|
|
|
&dev_attr_reservation_policy.attr,
|
|
|
|
&dev_attr_last_known_reservation_state.attr,
|
2012-11-28 20:43:38 +08:00
|
|
|
&dev_attr_safe_offline.attr,
|
2016-03-18 16:42:13 +08:00
|
|
|
&dev_attr_host_access_count.attr,
|
2014-10-01 20:39:47 +08:00
|
|
|
&dev_attr_path_masks.attr,
|
2016-08-08 21:56:54 +08:00
|
|
|
&dev_attr_path_threshold.attr,
|
|
|
|
&dev_attr_path_interval.attr,
|
|
|
|
&dev_attr_path_reset.attr,
|
|
|
|
&dev_attr_hpf.attr,
|
2005-04-17 06:20:36 +08:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group dasd_attr_group = {
|
|
|
|
.attrs = dasd_attrs,
|
|
|
|
};
|
|
|
|
|
2005-05-01 23:58:59 +08:00
|
|
|
/*
|
|
|
|
* Return value of the specified feature.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
dasd_get_feature(struct ccw_device *cdev, int feature)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
|
2008-10-11 03:33:09 +08:00
|
|
|
devmap = dasd_find_busid(dev_name(&cdev->dev));
|
2005-05-01 23:58:59 +08:00
|
|
|
if (IS_ERR(devmap))
|
2006-06-29 21:08:18 +08:00
|
|
|
return PTR_ERR(devmap);
|
2005-05-01 23:58:59 +08:00
|
|
|
|
|
|
|
return ((devmap->features & feature) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set / reset given feature.
|
2012-09-20 09:48:00 +08:00
|
|
|
* Flag indicates whether to set (!=0) or the reset (=0) the feature.
|
2005-05-01 23:58:59 +08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
|
|
|
|
{
|
|
|
|
struct dasd_devmap *devmap;
|
|
|
|
|
2016-10-07 23:21:24 +08:00
|
|
|
devmap = dasd_devmap_from_cdev(cdev);
|
2005-05-01 23:58:59 +08:00
|
|
|
if (IS_ERR(devmap))
|
2006-06-29 21:08:18 +08:00
|
|
|
return PTR_ERR(devmap);
|
2005-05-01 23:58:59 +08:00
|
|
|
|
|
|
|
spin_lock(&dasd_devmap_lock);
|
|
|
|
if (flag)
|
|
|
|
devmap->features |= feature;
|
|
|
|
else
|
|
|
|
devmap->features &= ~feature;
|
2005-09-04 06:57:58 +08:00
|
|
|
if (devmap->device)
|
|
|
|
devmap->device->features = devmap->features;
|
2005-05-01 23:58:59 +08:00
|
|
|
spin_unlock(&dasd_devmap_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
int
|
|
|
|
dasd_add_sysfs_files(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dasd_remove_sysfs_files(struct ccw_device *cdev)
|
|
|
|
{
|
|
|
|
sysfs_remove_group(&cdev->dev.kobj, &dasd_attr_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
dasd_devmap_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Initialize devmap structures. */
|
|
|
|
dasd_max_devindex = 0;
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
INIT_LIST_HEAD(&dasd_hashlists[i]);
|
2006-06-29 21:08:18 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dasd_devmap_exit(void)
|
|
|
|
{
|
|
|
|
dasd_forget_ranges();
|
|
|
|
}
|