Subject: Re: [PATCH -next] scsi: RAID_ATTRS depends on SCSI

From: James Bottomley <[email-masked]>
Date: Wed, 03 Mar 2010 11:06:56 +0530

On Sun, 2010-02-21 at 19:46 -0800, Randy Dunlap wrote:
> From: Randy Dunlap <[email-masked]>
> 
> raid_class uses scsi interfaces, so it should depend on SCSI.
> Otherwise build errors occur when RAID_ATTRS=y and SCSI=m:
> 
> ERROR: "raid_class_release" [drivers/scsi/mpt2sas/mpt2sas.ko] undefined!
> ERROR: "raid_class_attach" [drivers/scsi/mpt2sas/mpt2sas.ko] undefined!
> 
> Signed-off-by: Randy Dunlap <[email-masked]>
> ---
>  drivers/scsi/Kconfig |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> --- linux-next-20100219.orig/drivers/scsi/Kconfig
> +++ linux-next-20100219/drivers/scsi/Kconfig
> @@ -1,12 +1,5 @@
>  menu "SCSI device support"
>  
> -config RAID_ATTRS
> -	tristate "RAID Transport Class"
> -	default n
> -	depends on BLOCK
> -	---help---
> -	  Provides RAID
> -
>  config SCSI
>  	tristate "SCSI device support"
>  	depends on BLOCK
> @@ -34,6 +27,13 @@ config SCSI_DMA
>  	bool
>  	default n
>  
> +config RAID_ATTRS
> +	tristate "RAID Transport Class"
> +	default n
> +	depends on BLOCK && SCSI
> +	---help---
> +	  Provides RAID
> +

This will fix the error, but it's not quite the right thing to do.  the
RAID class should be independent of SCSI, but it wants to do a SCSI
check if SCSI is compiled in the matching routines.  This gives us a
nasty dependency, the condition being that the raid class must be m if
SCSI is m.

I think this patch does the right thing.  Can someone test it on the
config checker?  Or I can just put it in linux-next and have Stephen's
builds do it.

Thanks,

James

---

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 9191d1e..75f2336 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1,9 +1,15 @@
 menu "SCSI device support"
 
+config SCSI_MOD
+       tristate
+       default y if SCSI=n || SCSI=y
+       default m if SCSI=m
+
 config RAID_ATTRS
 	tristate "RAID Transport Class"
 	default n
 	depends on BLOCK
+	depends on SCSI_MOD
 	---help---
 	  Provides RAID
 
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index bd88349..2c146b4 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -63,6 +63,7 @@ static int raid_match(struct attribute_container *cont, struct device *dev)
 	 * emulated RAID devices, so start with SCSI */
 	struct raid_internal *i = ac_to_raid_internal(cont);
 
+#if defined(CONFIG_SCSI) || defined(CONFIG_SCSI_MODULE)
 	if (scsi_is_sdev_device(dev)) {
 		struct scsi_device *sdev = to_scsi_device(dev);
 
@@ -71,6 +72,7 @@ static int raid_match(struct attribute_container *cont, struct device *dev)
 
 		return i->f->is_raid(dev);
 	}
+#endif
 	/* FIXME: look at other subsystems too */
 	return 0;
 }