Lines Matching refs:device

38  * between device number and device index. To find a dasd_devmap_t
39 * that corresponds to a device number of a device index each
41 * the device number and one to search by the device index. As
42 * soon as big minor numbers are available the device index list
43 * can be removed since the device number will then be identical
44 * to the device index.
51 struct dasd_device *device;
132 * Read a device busid/devno from a string.
142 pr_err("The IPL device is not a CCW device\n");
207 pr_warn("%.*s is not a supported device option\n",
275 * Split a string of a device range into its pieces and return the from, to, and
287 /* Do we have a range or a single device? */
306 * Try to interprete the range string as a device number or a range of devices.
346 pr_err("%s is not a valid device range\n", range);
357 /* each device in dasd= parameter should be set initially online */
377 * keywords and device ranges. The parameters in that list will be stored as
405 * Add a devmap for the device specified by busid. It is possible that
432 new->device = NULL;
460 * Find devmap for device with given bus_id.
483 * Forget all about the device numbers added so far.
495 BUG_ON(devmap->device != NULL);
504 * Find the device struct by its device index.
510 struct dasd_device *device;
518 /* Found the devmap for the device. */
522 if (devmap && devmap->device) {
523 device = devmap->device;
524 dasd_get_device(device);
526 device = ERR_PTR(-ENODEV);
528 return device;
548 * Create a dasd device structure for cdev.
554 struct dasd_device *device;
562 device = dasd_alloc_device();
563 if (IS_ERR(device))
564 return device;
565 atomic_set(&device->ref_count, 3);
568 if (!devmap->device) {
569 devmap->device = device;
570 device->devindex = devmap->devindex;
571 device->features = devmap->features;
573 device->cdev = cdev;
581 dasd_free_device(device);
586 dev_set_drvdata(&cdev->dev, device);
589 device->paths_info = kset_create_and_add("paths_info", NULL,
590 &device->cdev->dev.kobj);
591 if (!device->paths_info)
594 return device;
600 static int dasd_devmap_get_pprc_status(struct dasd_device *device,
605 if (!device->discipline || !device->discipline->pprc_status) {
606 dev_warn(&device->cdev->dev, "Unable to query copy relation status\n");
614 if (device->discipline->pprc_status(device, temp)) {
615 dev_warn(&device->cdev->dev, "Error during copy relation status query\n");
626 * depending on the primary/secondary state of the device it has to be
653 * - is the given device part of a copy pair setup
654 * - does the state of the device match the state in the PPRC status data
655 * - does the device UID match with the UID in the PPRC status data
656 * - to prevent misrouted IO check if the given device is present in all
659 static int dasd_devmap_check_copy_relation(struct dasd_device *device,
669 if (!device->discipline || !device->discipline->get_uid ||
670 device->discipline->get_uid(device, &uid))
675 dev_warn(&device->cdev->dev, "Device not part of a copy relation\n");
679 /* double check which role the current device has */
682 dev_warn(&device->cdev->dev, "Copy pair secondary is setup as primary\n");
687 dev_warn(&device->cdev->dev,
688 "Primary device %s does not match copy pair status primary device %04x\n",
689 dev_name(&device->cdev->dev),
696 dev_warn(&device->cdev->dev, "Copy pair primary is setup as secondary\n");
701 dev_warn(&device->cdev->dev,
702 "Secondary device %s does not match copy pair status secondary device %04x\n",
703 dev_name(&device->cdev->dev),
711 * the current device has to be part of the copy relation of all
716 tmp_dev = device;
718 tmp_dev = copy->entry[j].device;
728 "Copy pair relation does not contain device: %s\n",
729 dev_name(&device->cdev->dev));
738 /* delete device from copy relation entry */
739 static void dasd_devmap_delete_copy_relation_device(struct dasd_device *device)
744 if (!device->copy)
747 copy = device->copy;
749 if (copy->entry[i].device == device)
750 copy->entry[i].device = NULL;
752 dasd_put_device(device);
753 device->copy = NULL;
757 * read all required information for a copy relation setup and setup the device
767 struct dasd_device *device;
774 device = devmap->device;
775 if (!device)
779 /* no copy pair setup for this device */
783 rc = dasd_devmap_get_pprc_status(device, &data);
795 dev_warn(&device->cdev->dev, "Copy pair setup requested for device not in copy relation\n");
809 dev_warn(&device->cdev->dev, "Copy relation entry not found\n");
814 if (dasd_devmap_check_copy_relation(device, entry, data, copy)) {
815 dev_warn(&device->cdev->dev, "Copy relation faulty\n");
820 dasd_get_device(device);
821 copy->entry[i].device = device;
822 device->copy = copy;
835 * Remove a dasd device structure. The passed referenced
839 dasd_delete_device(struct dasd_device *device)
845 /* First remove device pointer from devmap. */
846 devmap = dasd_find_busid(dev_name(&device->cdev->dev));
849 if (devmap->device != device) {
851 dasd_put_device(device);
854 devmap->device = NULL;
858 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
859 dev_set_drvdata(&device->cdev->dev, NULL);
860 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
863 dasd_devmap_delete_copy_relation_device(device);
868 atomic_sub(3, &device->ref_count);
871 wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
873 dasd_generic_free_discipline(device);
875 kset_unregister(device->paths_info);
878 cdev = device->cdev;
879 device->cdev = NULL;
884 /* Now the device structure can be freed. */
885 dasd_free_device(device);
893 dasd_put_device_wake(struct dasd_device *device)
901 * This function needs to be called with the ccw device
907 struct dasd_device *device = dev_get_drvdata(&cdev->dev);
909 if (!device)
911 dasd_get_device(device);
912 return device;
921 struct dasd_device *device;
925 device = dasd_device_from_cdev_locked(cdev);
927 return device;
930 void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device)
934 devmap = dasd_find_busid(dev_name(&device->cdev->dev));
945 struct dasd_device *device;
950 device = NULL;
953 if (devmap && devmap->device) {
954 device = devmap->device;
955 dasd_get_device(device);
958 return device;
968 static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
982 static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr,
1002 dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
1005 struct dasd_device *device;
1015 device = devmap->device;
1016 if (device)
1017 ro_flag |= test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
1025 dasd_ro_store(struct device *dev, struct device_attribute *attr,
1029 struct dasd_device *device;
1041 device = dasd_device_from_cdev(cdev);
1042 if (IS_ERR(device))
1046 val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags);
1048 if (!device->block || !device->block->gdp ||
1049 test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
1053 /* Increase open_count to avoid losing the block device */
1054 atomic_inc(&device->block->open_count);
1057 set_disk_ro(device->block->gdp, val);
1058 atomic_dec(&device->block->open_count);
1061 dasd_put_device(device);
1072 dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf)
1086 dasd_erplog_store(struct device *dev, struct device_attribute *attr,
1104 * to talk to the device
1107 dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
1121 dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
1138 if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) {
1156 dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf)
1170 dasd_use_raw_store(struct device *dev, struct device_attribute *attr,
1187 if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) {
1202 dasd_safe_offline_store(struct device *dev, struct device_attribute *attr,
1206 struct dasd_device *device;
1211 device = dasd_device_from_cdev_locked(cdev);
1212 if (IS_ERR(device)) {
1213 rc = PTR_ERR(device);
1218 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
1219 test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) {
1221 dasd_put_device(device);
1227 set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags);
1228 dasd_put_device(device);
1240 dasd_access_show(struct device *dev, struct device_attribute *attr,
1244 struct dasd_device *device;
1247 device = dasd_device_from_cdev(cdev);
1248 if (IS_ERR(device))
1249 return PTR_ERR(device);
1251 if (!device->discipline)
1253 else if (!device->discipline->host_access_count)
1256 count = device->discipline->host_access_count(device);
1258 dasd_put_device(device);
1268 dasd_discipline_show(struct device *dev, struct device_attribute *attr,
1271 struct dasd_device *device;
1274 device = dasd_device_from_cdev(to_ccwdev(dev));
1275 if (IS_ERR(device))
1277 else if (!device->discipline) {
1278 dasd_put_device(device);
1282 device->discipline->name);
1283 dasd_put_device(device);
1294 dasd_device_status_show(struct device *dev, struct device_attribute *attr,
1297 struct dasd_device *device;
1300 device = dasd_device_from_cdev(to_ccwdev(dev));
1301 if (!IS_ERR(device)) {
1302 switch (device->state) {
1325 dasd_put_device(device);
1333 static ssize_t dasd_alias_show(struct device *dev,
1336 struct dasd_device *device;
1339 device = dasd_device_from_cdev(to_ccwdev(dev));
1340 if (IS_ERR(device))
1343 if (device->discipline && device->discipline->get_uid &&
1344 !device->discipline->get_uid(device, &uid)) {
1347 dasd_put_device(device);
1351 dasd_put_device(device);
1358 static ssize_t dasd_vendor_show(struct device *dev,
1361 struct dasd_device *device;
1365 device = dasd_device_from_cdev(to_ccwdev(dev));
1367 if (IS_ERR(device))
1370 if (device->discipline && device->discipline->get_uid &&
1371 !device->discipline->get_uid(device, &uid))
1374 dasd_put_device(device);
1382 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf)
1385 struct dasd_device *device;
1389 device = dasd_device_from_cdev(to_ccwdev(dev));
1391 if (IS_ERR(device))
1394 if (device->discipline && device->discipline->get_uid &&
1395 !device->discipline->get_uid(device, &uid)) {
1409 /* should not happen, treat like base device */
1425 dasd_put_device(device);
1435 dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
1441 if (!IS_ERR(devmap) && devmap->device)
1442 eer_flag = dasd_eer_enabled(devmap->device);
1449 dasd_eer_store(struct device *dev, struct device_attribute *attr,
1452 struct dasd_device *device;
1456 device = dasd_device_from_cdev(to_ccwdev(dev));
1457 if (IS_ERR(device))
1458 return PTR_ERR(device);
1464 rc = dasd_eer_enable(device);
1466 dasd_eer_disable(device);
1468 dasd_put_device(device);
1479 static ssize_t dasd_aq_mask_show(struct device *dev, struct device_attribute *attr,
1492 static ssize_t dasd_aq_mask_store(struct device *dev, struct device_attribute *attr,
1507 if (devmap->device)
1508 devmap->device->aq_mask = devmap->aq_mask;
1520 static ssize_t dasd_aqr_show(struct device *dev, struct device_attribute *attr,
1535 static ssize_t dasd_aqr_store(struct device *dev, struct device_attribute *attr,
1553 * a device gets autoquiesced
1556 dasd_aq_timeouts_show(struct device *dev, struct device_attribute *attr,
1559 struct dasd_device *device;
1562 device = dasd_device_from_cdev(to_ccwdev(dev));
1563 if (IS_ERR(device))
1565 len = sysfs_emit(buf, "%u\n", device->aq_timeouts);
1566 dasd_put_device(device);
1571 dasd_aq_timeouts_store(struct device *dev, struct device_attribute *attr,
1574 struct dasd_device *device;
1577 device = dasd_device_from_cdev(to_ccwdev(dev));
1578 if (IS_ERR(device))
1583 dasd_put_device(device);
1588 device->aq_timeouts = val;
1590 dasd_put_device(device);
1601 dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf)
1603 struct dasd_device *device;
1606 device = dasd_device_from_cdev(to_ccwdev(dev));
1607 if (IS_ERR(device))
1609 len = sysfs_emit(buf, "%lu\n", device->default_expires);
1610 dasd_put_device(device);
1615 dasd_expires_store(struct device *dev, struct device_attribute *attr,
1618 struct dasd_device *device;
1621 device = dasd_device_from_cdev(to_ccwdev(dev));
1622 if (IS_ERR(device))
1627 dasd_put_device(device);
1632 device->default_expires = val;
1634 dasd_put_device(device);
1641 dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf)
1643 struct dasd_device *device;
1646 device = dasd_device_from_cdev(to_ccwdev(dev));
1647 if (IS_ERR(device))
1649 len = sysfs_emit(buf, "%lu\n", device->default_retries);
1650 dasd_put_device(device);
1655 dasd_retries_store(struct device *dev, struct device_attribute *attr,
1658 struct dasd_device *device;
1661 device = dasd_device_from_cdev(to_ccwdev(dev));
1662 if (IS_ERR(device))
1667 dasd_put_device(device);
1672 device->default_retries = val;
1674 dasd_put_device(device);
1681 dasd_timeout_show(struct device *dev, struct device_attribute *attr,
1684 struct dasd_device *device;
1687 device = dasd_device_from_cdev(to_ccwdev(dev));
1688 if (IS_ERR(device))
1690 len = sysfs_emit(buf, "%lu\n", device->blk_timeout);
1691 dasd_put_device(device);
1696 dasd_timeout_store(struct device *dev, struct device_attribute *attr,
1699 struct dasd_device *device;
1702 device = dasd_device_from_cdev(to_ccwdev(dev));
1703 if (IS_ERR(device) || !device->block)
1708 dasd_put_device(device);
1711 if (!device->block->gdp) {
1712 dasd_put_device(device);
1716 device->blk_timeout = val;
1717 blk_queue_rq_timeout(device->block->gdp->queue, val * HZ);
1719 dasd_put_device(device);
1728 dasd_path_reset_store(struct device *dev, struct device_attribute *attr,
1731 struct dasd_device *device;
1734 device = dasd_device_from_cdev(to_ccwdev(dev));
1735 if (IS_ERR(device))
1741 if (device->discipline && device->discipline->reset_path)
1742 device->discipline->reset_path(device, (__u8) val);
1744 dasd_put_device(device);
1750 static ssize_t dasd_hpf_show(struct device *dev, struct device_attribute *attr,
1753 struct dasd_device *device;
1756 device = dasd_device_from_cdev(to_ccwdev(dev));
1757 if (IS_ERR(device))
1759 if (!device->discipline || !device->discipline->hpf_enabled) {
1760 dasd_put_device(device);
1763 hpf = device->discipline->hpf_enabled(device);
1764 dasd_put_device(device);
1770 static ssize_t dasd_reservation_policy_show(struct device *dev,
1791 static ssize_t dasd_reservation_policy_store(struct device *dev,
1811 static ssize_t dasd_reservation_state_show(struct device *dev,
1815 struct dasd_device *device;
1818 device = dasd_device_from_cdev(to_ccwdev(dev));
1819 if (IS_ERR(device))
1822 if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags))
1824 else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags))
1828 dasd_put_device(device);
1832 static ssize_t dasd_reservation_state_store(struct device *dev,
1836 struct dasd_device *device;
1839 device = dasd_device_from_cdev(to_ccwdev(dev));
1840 if (IS_ERR(device))
1843 clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags);
1846 dasd_put_device(device);
1857 static ssize_t dasd_pm_show(struct device *dev,
1860 struct dasd_device *device;
1863 device = dasd_device_from_cdev(to_ccwdev(dev));
1864 if (IS_ERR(device))
1867 opm = dasd_path_get_opm(device);
1868 nppm = dasd_path_get_nppm(device);
1869 cablepm = dasd_path_get_cablepm(device);
1870 cuirpm = dasd_path_get_cuirpm(device);
1871 hpfpm = dasd_path_get_hpfpm(device);
1872 ifccpm = dasd_path_get_ifccpm(device);
1873 dasd_put_device(device);
1885 dasd_path_threshold_show(struct device *dev,
1888 struct dasd_device *device;
1891 device = dasd_device_from_cdev(to_ccwdev(dev));
1892 if (IS_ERR(device))
1894 len = sysfs_emit(buf, "%lu\n", device->path_thrhld);
1895 dasd_put_device(device);
1900 dasd_path_threshold_store(struct device *dev, struct device_attribute *attr,
1903 struct dasd_device *device;
1907 device = dasd_device_from_cdev(to_ccwdev(dev));
1908 if (IS_ERR(device))
1912 dasd_put_device(device);
1916 device->path_thrhld = val;
1918 dasd_put_device(device);
1929 dasd_path_autodisable_show(struct device *dev,
1945 dasd_path_autodisable_store(struct device *dev,
1970 dasd_path_interval_show(struct device *dev,
1973 struct dasd_device *device;
1976 device = dasd_device_from_cdev(to_ccwdev(dev));
1977 if (IS_ERR(device))
1979 len = sysfs_emit(buf, "%lu\n", device->path_interval);
1980 dasd_put_device(device);
1985 dasd_path_interval_store(struct device *dev, struct device_attribute *attr,
1988 struct dasd_device *device;
1992 device = dasd_device_from_cdev(to_ccwdev(dev));
1993 if (IS_ERR(device))
1998 dasd_put_device(device);
2003 device->path_interval = val;
2005 dasd_put_device(device);
2013 dasd_device_fcs_show(struct device *dev, struct device_attribute *attr,
2016 struct dasd_device *device;
2020 device = dasd_device_from_cdev(to_ccwdev(dev));
2021 if (IS_ERR(device))
2023 fc_sec = dasd_path_get_fcs_device(device);
2028 dasd_put_device(device);
2051 dasd_copy_pair_show(struct device *dev,
2148 static int dasd_devmap_clear_copy_relation(struct device *dev)
2168 if (copy->entry[i].device == copy->active->device)
2171 if (copy->entry[i].device)
2178 if (copy->entry[i].device) {
2179 dasd_put_device(copy->entry[i].device);
2180 copy->entry[i].device->copy = NULL;
2181 copy->entry[i].device = NULL;
2233 static ssize_t dasd_copy_pair_store(struct device *dev,
2241 struct dasd_device *device;
2270 if (sec_devmap->device)
2295 /* if primary device is already online call device setup directly */
2296 if (prim_devmap->device && !prim_devmap->device->copy) {
2297 device = prim_devmap->device;
2298 if (device->discipline->pprc_enabled) {
2299 pprc_enabled = device->discipline->pprc_enabled(device);
2300 rc = dasd_devmap_set_device_copy_relation(device->cdev,
2318 dasd_copy_role_show(struct device *dev,
2322 struct dasd_device *device;
2325 device = dasd_device_from_cdev(to_ccwdev(dev));
2326 if (IS_ERR(device))
2329 if (!device->copy) {
2333 copy = device->copy;
2334 /* only the active device is primary */
2335 if (copy->active->device == device) {
2340 if (copy->entry[i].device == device) {
2348 dasd_put_device(device);
2353 static ssize_t dasd_device_ping(struct device *dev,
2357 struct dasd_device *device;
2360 device = dasd_device_from_cdev(to_ccwdev(dev));
2361 if (IS_ERR(device))
2370 if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
2374 if (!device->discipline || !device->discipline->device_ping) {
2378 rc = device->discipline->device_ping(device);
2382 dasd_put_device(device);
2388 static ssize_t dasd_##_name##_show(struct device *dev, \
2393 struct dasd_device *device = dasd_device_from_cdev(cdev); \
2396 if (IS_ERR(device)) \
2398 if (device->discipline && _func) \
2399 val = _func(device); \
2400 dasd_put_device(device); \
2406 DASD_DEFINE_ATTR(ese, device->discipline->is_ese);
2407 DASD_DEFINE_ATTR(extent_size, device->discipline->ext_size);
2408 DASD_DEFINE_ATTR(pool_id, device->discipline->ext_pool_id);
2409 DASD_DEFINE_ATTR(space_configured, device->discipline->space_configured);
2410 DASD_DEFINE_ATTR(space_allocated, device->discipline->space_allocated);
2411 DASD_DEFINE_ATTR(logical_capacity, device->discipline->logical_capacity);
2412 DASD_DEFINE_ATTR(warn_threshold, device->discipline->ext_pool_warn_thrshld);
2413 DASD_DEFINE_ATTR(cap_at_warnlevel, device->discipline->ext_pool_cap_at_warnlevel);
2414 DASD_DEFINE_ATTR(pool_oos, device->discipline->ext_pool_oos);
2523 if (devmap->device)
2524 devmap->device->features = devmap->features;
2542 static void dasd_path_init_kobj(struct dasd_device *device, int chp)
2544 device->path[chp].kobj.kset = device->paths_info;
2545 kobject_init(&device->path[chp].kobj, &path_attr_type);
2548 void dasd_path_create_kobj(struct dasd_device *device, int chp)
2552 if (test_bit(DASD_FLAG_OFFLINE, &device->flags))
2554 if (!device->paths_info) {
2555 dev_warn(&device->cdev->dev, "Unable to create paths objects\n");
2558 if (device->path[chp].in_sysfs)
2560 if (!device->path[chp].conf_data)
2563 dasd_path_init_kobj(device, chp);
2565 rc = kobject_add(&device->path[chp].kobj, NULL, "%x.%02x",
2566 device->path[chp].cssid, device->path[chp].chpid);
2568 kobject_put(&device->path[chp].kobj);
2569 device->path[chp].in_sysfs = true;
2573 void dasd_path_create_kobjects(struct dasd_device *device)
2577 opm = dasd_path_get_opm(device);
2581 dasd_path_create_kobj(device, pathmask_to_pos(lpm));
2586 static void dasd_path_remove_kobj(struct dasd_device *device, int chp)
2588 if (device->path[chp].in_sysfs) {
2589 kobject_put(&device->path[chp].kobj);
2590 device->path[chp].in_sysfs = false;
2595 * As we keep kobjects for the lifetime of a device, this function must not be
2596 * called anywhere but in the context of offlining a device.
2598 void dasd_path_remove_kobjects(struct dasd_device *device)
2603 dasd_path_remove_kobj(device, i);