Skip to contentSkip to conversation

take 3 add sysfs attributes to scan and delete scsi_devices

PATCH New Patrick Mansfield 1 participant 1 message Aug 8, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 take 3 add sysfs attributes to scan and delete scsi_devices

This patch against scsi-misc-2.5 adds a sysfs attribute to allow scanning (or rescanning) and deletion of scsi_devices.

It also allows scanning of entire hosts, channels, or targets.

It adds a per-host scan attribute, and a per scsi_device delete attribute.

drivers/scsi/scsi_priv.h +8 -0
diff -purN -X /home/patman/dontdiff scsi-misc-2.5-pure/drivers/scsi/scsi_priv.h scan-del-attr-sm-2.5/drivers/scsi/scsi_priv.h
@@ -42,6 +42,12 @@
 	(((scmd)->sense_buffer[0] & 0x70) == 0x70)
 
 /*
+ * Special value for scanning to specify scanning or rescanning of all
+ * possible channels, (target) ids, or luns on a given shost.
+ */
+#define SCAN_WILD_CARD	~0
+
+/*
  * scsi_target: representation of a scsi target, for now, this is only
  * used for single_lun devices. If no one has active IO to the target,
  * starget_sdev_user is NULL, else it points to the active sdev.
@@ -106,6 +112,8 @@ extern void scsi_exit_procfs(void);
 #endif /* CONFIG_PROC_FS */
 
 /* scsi_scan.c */
+int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, unsigned int,
+			    unsigned int, int);
 extern void scsi_forget_host(struct Scsi_Host *);
 extern void scsi_free_sdev(struct scsi_device *);
 extern void scsi_free_shost(struct Scsi_Host *);
drivers/scsi/scsi_proc.c +1 -9
diff -purN -X /home/patman/dontdiff scsi-misc-2.5-pure/drivers/scsi/scsi_proc.c scan-del-attr-sm-2.5/drivers/scsi/scsi_proc.c
@@ -189,21 +189,13 @@ static int proc_print_scsidevice(struct 
 static int scsi_add_single_device(uint host, uint channel, uint id, uint lun)
 {
 	struct Scsi_Host *shost;
-	struct scsi_device *sdev;
 	int error = -ENXIO;
 
 	shost = scsi_host_lookup(host);
 	if (IS_ERR(shost))
 		return PTR_ERR(shost);
 
-	if (!scsi_find_device(shost, channel, id, lun)) {
-		sdev = scsi_add_device(shost, channel, id, lun);
-		if (IS_ERR(sdev))
-			error = PTR_ERR(sdev);
-		else
-			error = 0;
-	}
-
+	error = scsi_scan_host_selected(shost, channel, id, lun, 1);
 	scsi_host_put(shost);
 	return error;
 }
drivers/scsi/scsi_scan.c +88 -38

215 lines not on this page · raw message

drivers/scsi/scsi_sysfs.c +71 -1

108 lines not on this page · raw message