Hidden scsi devices
PATCH 1/1 Hidden scsi devices
Here is a patch that adds a flag to struct scsi_device which prevents upper layer drivers from binding to it. This flag can be set by LLDs in their slave_configure routine. I plan to use this in the ipr driver so I can have scsi disks that are in RAID arrays show up in sysfs and have sg devices created for them, but prevent sd devices from being created since these devices will fail reads and writes with data protect errors. I tested this out with the ipr driver it worked as expected.
Signature · 3 lines
Brian King eServer Storage I/O IBM Linux Technology Center
drivers/scsi/scsi_sysfs.c +7 -1
@@ -149,7 +149,13 @@/* all probing is done in the individual ->probe routines */ static int scsi_bus_match (struct device *dev,struct device_driver *gendrv) { -return 1 ; +struct scsi_device *sdev; + sdev =to_scsi_device (dev); + +if (sdev->hidden) +return 0 ; +else +return 1 ; }struct bus_type scsi_bus_type = {
include/scsi/scsi_device.h +1 -0
@@ -94,6 +94,7 @@ unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ unsigned no_start_on_add:1; /* do not issue start on add */ + unsigned hidden:1; /* do not bind to upper level driver */unsigned int device_blocked;/* Device returned QUEUE_FULL. */
Ok. Although I'd maybe write it a bit more compact, and a bit commentary could't hurt.
/*
* Sort out hidden devices early. All real probing is done in the
* individual ->probe routines
*/
static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
{
struct scsi_device *sdev = to_scsi_device(dev);
return (sdev->hidden ? 0 : 1);
}