#include <linux/config.h>
#include <linux/ctype.h>
#include <linux/init.h>
-#include <linux/module.h>
#include <asm/debug.h>
#include <asm/uaccess.h>
unsigned int devindex;
unsigned short features;
struct dasd_device *device;
- struct dasd_uid uid;
};
/*
* strings when running as a module.
*/
static char *dasd[256];
-module_param_array(dasd, charp, NULL, 0);
-
/*
* Single spinlock to protect devmap structures and lists.
*/
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);
+ if (devmap->device != NULL)
+ BUG();
list_del(&devmap->list);
kfree(devmap);
}
/* First remove device pointer from devmap. */
devmap = dasd_find_busid(device->cdev->dev.bus_id);
- BUG_ON(IS_ERR(devmap));
+ if (IS_ERR(devmap))
+ BUG();
spin_lock(&dasd_devmap_lock);
if (devmap->device != device) {
spin_unlock(&dasd_devmap_lock);
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
-static ssize_t
-dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct dasd_devmap *devmap;
- int alias;
-
- devmap = dasd_find_busid(dev->bus_id);
- spin_lock(&dasd_devmap_lock);
- if (!IS_ERR(devmap))
- alias = devmap->uid.alias;
- else
- alias = 0;
- spin_unlock(&dasd_devmap_lock);
-
- return sprintf(buf, alias ? "1\n" : "0\n");
-}
-
-static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL);
-
-static ssize_t
-dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct dasd_devmap *devmap;
- char *vendor;
-
- devmap = dasd_find_busid(dev->bus_id);
- spin_lock(&dasd_devmap_lock);
- if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
- vendor = devmap->uid.vendor;
- else
- vendor = "";
- spin_unlock(&dasd_devmap_lock);
-
- 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 +\
- /* SSID */ 4 + 1 + /* unit addr */ 2 + 1)
-
-static ssize_t
-dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct dasd_devmap *devmap;
- char uid[UID_STRLEN];
-
- devmap = dasd_find_busid(dev->bus_id);
- spin_lock(&dasd_devmap_lock);
- if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0)
- snprintf(uid, sizeof(uid), "%s.%s.%04x.%02x",
- devmap->uid.vendor, devmap->uid.serial,
- devmap->uid.ssid, devmap->uid.unit_addr);
- else
- uid[0] = 0;
- spin_unlock(&dasd_devmap_lock);
-
- return snprintf(buf, PAGE_SIZE, "%s\n", uid);
-}
-
-static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL);
-
-/*
- * 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;
-
- devmap = dasd_find_busid(dev->bus_id);
- 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)
-{
- struct dasd_devmap *devmap;
- int rc;
-
- devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
- if (IS_ERR(devmap))
- return PTR_ERR(devmap);
- if (!devmap->device)
- return count;
- if (buf[0] == '1') {
- rc = dasd_eer_enable(devmap->device);
- if (rc)
- return rc;
- } else
- dasd_eer_disable(devmap->device);
- return count;
-}
-
-static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
-
static struct attribute * dasd_attrs[] = {
&dev_attr_readonly.attr,
&dev_attr_discipline.attr,
- &dev_attr_alias.attr,
- &dev_attr_vendor.attr,
- &dev_attr_uid.attr,
&dev_attr_use_diag.attr,
- &dev_attr_eer_enabled.attr,
NULL,
};
.attrs = dasd_attrs,
};
-
-/*
- * Return copy of the device unique identifier.
- */
-int
-dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid)
-{
- struct dasd_devmap *devmap;
-
- devmap = dasd_find_busid(cdev->dev.bus_id);
- if (IS_ERR(devmap))
- return PTR_ERR(devmap);
- spin_lock(&dasd_devmap_lock);
- *uid = devmap->uid;
- spin_unlock(&dasd_devmap_lock);
- return 0;
-}
-
-/*
- * Register the given device unique identifier into devmap struct.
- */
-int
-dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid)
-{
- struct dasd_devmap *devmap;
-
- devmap = dasd_find_busid(cdev->dev.bus_id);
- if (IS_ERR(devmap))
- return PTR_ERR(devmap);
- spin_lock(&dasd_devmap_lock);
- devmap->uid = *uid;
- spin_unlock(&dasd_devmap_lock);
- return 0;
-}
-EXPORT_SYMBOL(dasd_set_uid);
-
/*
* Return value of the specified feature.
*/