scsi_scan.c (633b47cb009d09dc8f4ba9cdb3a0ca138809c7c7) | scsi_scan.c (ff48b37802e5c134e2dfc4d091f10b2eb5065a72) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * scsi_scan.c 4 * 5 * Copyright (C) 2000 Eric Youngdale, 6 * Copyright (C) 2002 Patrick Mansfield 7 * 8 * The general scanning/probing algorithm is as follows, exceptions are --- 808 unchanged lines hidden (view full) --- 817 * request, and then spun up on request. 818 */ 819 820 /* 821 * The scanning code needs to know the scsi_level, even if no 822 * device is attached at LUN 0 (SCSI_SCAN_TARGET_PRESENT) so 823 * non-zero LUNs can be scanned. 824 */ | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * scsi_scan.c 4 * 5 * Copyright (C) 2000 Eric Youngdale, 6 * Copyright (C) 2002 Patrick Mansfield 7 * 8 * The general scanning/probing algorithm is as follows, exceptions are --- 808 unchanged lines hidden (view full) --- 817 * request, and then spun up on request. 818 */ 819 820 /* 821 * The scanning code needs to know the scsi_level, even if no 822 * device is attached at LUN 0 (SCSI_SCAN_TARGET_PRESENT) so 823 * non-zero LUNs can be scanned. 824 */ |
825 sdev->scsi_level = inq_result[2] & 0x0f; | 825 sdev->scsi_level = inq_result[2] & 0x07; |
826 if (sdev->scsi_level >= 2 || 827 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) 828 sdev->scsi_level++; 829 sdev->sdev_target->scsi_level = sdev->scsi_level; 830 831 /* 832 * If SCSI-2 or lower, and if the transport requires it, 833 * store the LUN value in CDB[1]. --- 780 unchanged lines hidden (view full) --- 1614 if (IS_ERR(sdev)) 1615 return PTR_ERR(sdev); 1616 1617 scsi_device_put(sdev); 1618 return 0; 1619} 1620EXPORT_SYMBOL(scsi_add_device); 1621 | 826 if (sdev->scsi_level >= 2 || 827 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) 828 sdev->scsi_level++; 829 sdev->sdev_target->scsi_level = sdev->scsi_level; 830 831 /* 832 * If SCSI-2 or lower, and if the transport requires it, 833 * store the LUN value in CDB[1]. --- 780 unchanged lines hidden (view full) --- 1614 if (IS_ERR(sdev)) 1615 return PTR_ERR(sdev); 1616 1617 scsi_device_put(sdev); 1618 return 0; 1619} 1620EXPORT_SYMBOL(scsi_add_device); 1621 |
1622void scsi_rescan_device(struct scsi_device *sdev) | 1622int scsi_rescan_device(struct scsi_device *sdev) |
1623{ 1624 struct device *dev = &sdev->sdev_gendev; | 1623{ 1624 struct device *dev = &sdev->sdev_gendev; |
1625 int ret = 0; |
|
1625 1626 device_lock(dev); 1627 | 1626 1627 device_lock(dev); 1628 |
1629 /* 1630 * Bail out if the device is not running. Otherwise, the rescan may 1631 * block waiting for commands to be executed, with us holding the 1632 * device lock. This can result in a potential deadlock in the power 1633 * management core code when system resume is on-going. 1634 */ 1635 if (sdev->sdev_state != SDEV_RUNNING) { 1636 ret = -EWOULDBLOCK; 1637 goto unlock; 1638 } 1639 |
|
1628 scsi_attach_vpd(sdev); 1629 scsi_cdl_check(sdev); 1630 1631 if (sdev->handler && sdev->handler->rescan) 1632 sdev->handler->rescan(sdev); 1633 1634 if (dev->driver && try_module_get(dev->driver->owner)) { 1635 struct scsi_driver *drv = to_scsi_driver(dev->driver); 1636 1637 if (drv->rescan) 1638 drv->rescan(dev); 1639 module_put(dev->driver->owner); 1640 } | 1640 scsi_attach_vpd(sdev); 1641 scsi_cdl_check(sdev); 1642 1643 if (sdev->handler && sdev->handler->rescan) 1644 sdev->handler->rescan(sdev); 1645 1646 if (dev->driver && try_module_get(dev->driver->owner)) { 1647 struct scsi_driver *drv = to_scsi_driver(dev->driver); 1648 1649 if (drv->rescan) 1650 drv->rescan(dev); 1651 module_put(dev->driver->owner); 1652 } |
1653 1654unlock: |
|
1641 device_unlock(dev); | 1655 device_unlock(dev); |
1656 1657 return ret; |
|
1642} 1643EXPORT_SYMBOL(scsi_rescan_device); 1644 1645static void __scsi_scan_target(struct device *parent, unsigned int channel, 1646 unsigned int id, u64 lun, enum scsi_scan_mode rescan) 1647{ 1648 struct Scsi_Host *shost = dev_to_shost(parent); 1649 blist_flags_t bflags = 0; --- 343 unchanged lines hidden --- | 1658} 1659EXPORT_SYMBOL(scsi_rescan_device); 1660 1661static void __scsi_scan_target(struct device *parent, unsigned int channel, 1662 unsigned int id, u64 lun, enum scsi_scan_mode rescan) 1663{ 1664 struct Scsi_Host *shost = dev_to_shost(parent); 1665 blist_flags_t bflags = 0; --- 343 unchanged lines hidden --- |