Skip to contentSkip to conversation

allow NULL dev argument to scsi_add_host

PATCH In review Christoph Hellwig 4 participants 7 messages Jan 11, 2003 – Jan 13, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 allow NULL dev argument to scsi_add_host

We need scsi_add_host sometimes without having a struct device (i.e. eisa/vlb drivers, ieee1394 storage), so handle that case gracefully.

drivers/scsi/hosts.c +4 -3
@@ -314,9 +314,10 @@
  **/
 int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 {
-	dev->class_data = shost;
-	shost->host_gendev = dev;
-
+	if (dev) {
+		dev->class_data = shost;
+		shost->host_gendev = dev;
+	}
 	return __scsi_add_host(shost);
 }
 
#1 lore raw
Quoted 3 lines · On 2003.01.11 14:33 Christoph Hellwig wrote:

We need scsi_add_host sometimes without having a struct device (i.e. eisa/vlb drivers, ieee1394 storage), so handle that case gracefully.

Hmmm, I created a token device for ide-scsi (idescsi_primary) because that null case wasn't handled. Should I delete it again?

Thanks, Willem Riede.

#2 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig [[email protected]] wrote:

We need scsi_add_host sometimes without having a struct device (i.e. eisa/vlb drivers, ieee1394 storage), so handle that case gracefully.

drivers/scsi/hosts.c +0 -0
@@ -314,9 +314,10 @@
  **/
 int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
 {

drivers/scsi/hosts.c line 323

Quoted 10 lines
drivers/scsi/hosts.c +4 -3
-	dev->class_data = shost;
-	shost->host_gendev = dev;
-
+	if (dev) {
+		dev->class_data = shost;
+		shost->host_gendev = dev;
+	}
 	return __scsi_add_host(shost);
 }
 

This will cause all scsi device registers to show up in the root of the sysfs tree. The goal was that children of the adapter would be equal to the my_devices member. I also thought that callers of this interface would be converted to support sysfs.

If there are going to be many pseudo adapters that do not want to go through the overhead of creating a sysfs bus entry like ide-scsi then maybe I should work on a sysfs SCSI sub-system like block and if dev is null it means you are pseudo and we would create an entry for the adapter under (? /sysfs/scsi/pseudo ?). This could then be the value we stuff in host_gendev. Though the sysfs entry would not be much use to the caller, but useful for SCSI.

-andmike
--
Michael Anderson
[email protected]

#3 lore raw
Quoted 4 lines · Mike Anderson

This will cause all scsi device registers to show up in the root of the sysfs tree. The goal was that children of the adapter would be equal to the my_devices member. I also thought that callers of this interface would be converted to support sysfs.

I want to use this interface in driver that I can't support to the device model yet (i.e. due to lack of eisa/vlb hardware I can't add ldm support to them, but we have common drivers).

Quoted 7 lines

If there are going to be many pseudo adapters that do not want to go through the overhead of creating a sysfs bus entry like ide-scsi then maybe I should work on a sysfs SCSI sub-system like block and if dev is null it means you are pseudo and we would create an entry for the adapter under (? /sysfs/scsi/pseudo ?). This could then be the value we stuff in host_gendev. Though the sysfs entry would not be much use to the caller, but useful for SCSI.

I'm all for useful entries in sysfs, but what about doing that implicitly in scsi_add_host when dev is null? (and getting rid of the separate __scsi_add_host)

#4 lore raw
Quoted 11 lines · Christoph Hellwig [[email protected]] wrote:
Quoted 7 lines

If there are going to be many pseudo adapters that do not want to go through the overhead of creating a sysfs bus entry like ide-scsi then maybe I should work on a sysfs SCSI sub-system like block and if dev is null it means you are pseudo and we would create an entry for the adapter under (? /sysfs/scsi/pseudo ?). This could then be the value we stuff in host_gendev. Though the sysfs entry would not be much use to the caller, but useful for SCSI.

I'm all for useful entries in sysfs, but what about doing that implicitly in scsi_add_host when dev is null? (and getting rid of the separate __scsi_add_host)

Yes, This is what I meant in the previous comment about create it on the fly if dev is null and clean it up on the scsi_remove_host post call to scsi_forget_host.

Currently we have a couple of issues that might be solved by the creation of a scsi subsystem in /sysfs/scsi:

1. Non converted scsi hosts that need an entry in sysfs.
2. The creation of a sg(n) to scsi_device relationship.

I will start working on a RFC patch for addition of a scsi sub-system. Prior to getting this done the scsi sysfs nodes will just be inconstant for hopefully a short period.

-andmike
--
Michael Anderson
[email protected]

#5 lore raw
Quoted 2 lines · Mike Anderson

Currently we have a couple of issues that might be solved by the creation of a scsi subsystem in /sysfs/scsi:

Is /sysfs/scsi better than /sysfs/devices/scsiX?

Andries

#6 lore raw
Quoted 6 lines · Andries Brouwer [[email protected]] wrote:
Quoted 2 lines · Mike Anderson

Currently we have a couple of issues that might be solved by the creation of a scsi subsystem in /sysfs/scsi:

Is /sysfs/scsi better than /sysfs/devices/scsiX?

The choice was not better it was just a difference of semantics. The /sysfs/devices tree normal contains devices with an associated bus (though you can set this to NULL). The device tree was meant to contain real devices. The support I added to scsi_debug was to emulate a real device so the overhead was needed to try to match the call paths of other LLDD like some of the converted pci's. The addition of ide-scsi to the device tree was that there was no other option.

I hoped to get a smaller object to represent the emulated scsi hosts or hosts that had not been converted in a /sysfs/scsi subsystem. I also thought we might need other sysfs entries related to the SCSI subsystem (scsi logging control, sg mapping solution, scsiX host mapping "The scsi-host class I created sucks right now").

-andmike
--
Michael Anderson
[email protected]