Skip to contentSkip to conversation

fix rescan warning

PATCH In review Christoph Hellwig 2 participants 3 messages Mar 17, 2003 – Mar 18, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix rescan warning

The prototype for scsi_rescan_device was missing and once added it's caller doesn't compile anymore because it expects a return value..

drivers/scsi/scsi.h +1 -0
@@ -442,6 +442,7 @@
 extern int scsi_retry_command(Scsi_Cmnd *);
 extern int scsi_attach_device(struct scsi_device *);
 extern void scsi_detach_device(struct scsi_device *);
+extern void scsi_rescan_device(struct scsi_device *);
 extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
 
 /*
drivers/scsi/scsi_sysfs.c +2 -6
@@ -275,12 +275,8 @@
 static ssize_t
 store_rescan_field (struct device *dev, const char *buf, size_t count) 
 {
-	int ret = ENODEV;
-	struct scsi_device *sdev;
-	sdev = to_scsi_device(dev);
-	if (sdev)
-		ret = scsi_rescan_device(sdev);
-	return ret;
+	scsi_rescan_device(to_scsi_device(dev));
+	return 0;
 }
 
 static DEVICE_ATTR(rescan, S_IRUGO | S_IWUSR, show_rescan_field, store_rescan_field)
#1 lore raw
Quoted 22 lines · Christoph Hellwig

The prototype for scsi_rescan_device was missing and once added it's caller doesn't compile anymore because it expects a return value..

drivers/scsi/scsi.h +1 -0
@@ -442,6 +442,7 @@
 extern int scsi_retry_command(Scsi_Cmnd *);
 extern int scsi_attach_device(struct scsi_device *);
 extern void scsi_detach_device(struct scsi_device *);
+extern void scsi_rescan_device(struct scsi_device *);
 extern int scsi_get_device_flags(unsigned char *vendor, unsigned char *model);
 
 /*
drivers/scsi/scsi_sysfs.c +0 -2
@@ -275,12 +275,8 @@
 static ssize_t
 store_rescan_field (struct device *dev, const char *buf, size_t count) 
 {
-	int ret = ENODEV;
-	struct scsi_device *sdev;

drivers/scsi/scsi_sysfs.c

Quoted 10 lines
drivers/scsi/scsi_sysfs.c +2 -5
-	sdev = to_scsi_device(dev);
-	if (sdev)
-		ret = scsi_rescan_device(sdev);
-	return ret;
+	scsi_rescan_device(to_scsi_device(dev));
+	return 0;
 }
 
 static DEVICE_ATTR(rescan, S_IRUGO | S_IWUSR, show_rescan_field, store_rescan_field)
-

Christoph,
How does this work from a users point of view?
Something like:

  # cd /sys/bus/scsi/devices/2:0:0:0
  # echo "anything_I_like" > rescan

A sysfs store() is meant to return the number of
bytes consumed. In that case shouldn't the last
active line of the patch be "return count;".

How does rescan help us? ...
- a device at the same toplogical address changing its INQUIRY or READ CAPACITY response
- attempt a offline to online transition
- if the device could be no longer there so it
would be equivalent to
"echo 'scsi remove-single-device h c t l' > /proc/scsi/scsi
in that case.

When we get "real" scsi_host nodes in sysfs (i.e. with an instance (not a pointer) of struct device in struct scsi_host) then perhaps we can put a "scan" node in there to perform a bus (re-)scan.

Doug Gilbert

#2 lore raw
Quoted 5 lines · Douglas Gilbert

Christoph,
How does this work from a users point of view?
Something like:

   # cd /sys/bus/scsi/devices/2:0:0:0
   # echo "anything_I_like" > rescan

I think that's how it's supposed to work - it's not my code though and I haven't tested it.

Quoted 3 lines

A sysfs store() is meant to return the number of
bytes consumed. In that case shouldn't the last
active line of the patch be "return count;".

I think you're right.