[alsa-devel] Building for 2.4 kernel..

marcus hall marcus at tuells.org
Mon Jan 21 01:28:45 CET 2008


I support a product that is running the 2.4.18 linux kernel, and was trying
to install alsa-driver-1.0.15, and ran into a problem.

The alsa-kernel/pci/cs5535audio/cs5535audio_pm.c contains:

	if (pci_save_state(pci)) {
		...

and a similar line for pci_restore_state().

But, in include/adriver.h, pci_save_state is #defined to
snd_pci_compat_save_state, which is declared to return void, so the
compiler complains that the void return isn't being ignored.

Now, pci_save_state() appears to be supposed to return status, although
in the 2.4 kernel at least, it returns a constant 0.

Nevertheless, to get things to work, I changed snd_pci_compat_save_state(),
snd_pci_orig_save_state(), and the corresponding restore functions to return
an int with the following patch.  (The other obvious solution would be to
remove the test in cs5535audio_pm.c, but pci_save_state() is *supposed*
to return an int...)

--
Marcus Hall
marcus at tuells.org

---------

Index: alsa-driver/acore/misc_driver.c
===================================================================
RCS file: /usr/local/cvs_repos/almond/alsa/alsa-driver/acore/misc_driver.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- alsa-driver/acore/misc_driver.c	20 Jan 2008 16:52:35 -0000	1.1
+++ alsa-driver/acore/misc_driver.c	20 Jan 2008 17:14:23 -0000	1.2
@@ -105,14 +105,14 @@
 #ifdef CONFIG_PCI
 #ifndef CONFIG_HAVE_NEW_PCI_SAVE_STATE
 #ifdef CONFIG_HAVE_PCI_SAVED_CONFIG
-void snd_pci_compat_save_state(struct pci_dev *pci)
+int snd_pci_compat_save_state(struct pci_dev *pci)
 {
-	snd_pci_orig_save_state(pci, pci->saved_config_space);
+	return snd_pci_orig_save_state(pci, pci->saved_config_space);
 }
 EXPORT_SYMBOL(snd_pci_compat_save_state);
-void snd_pci_compat_restore_state(struct pci_dev *pci)
+int snd_pci_compat_restore_state(struct pci_dev *pci)
 {
-	snd_pci_orig_restore_state(pci, pci->saved_config_space);
+	return snd_pci_orig_restore_state(pci, pci->saved_config_space);
 }
 EXPORT_SYMBOL(snd_pci_compat_restore_state);
 #else /* !CONFIG_HAVE_PCI_SAVED_CONFIG */
@@ -122,7 +122,7 @@
 };
 static struct saved_config_tbl saved_tbl[16];
 
-void snd_pci_compat_save_state(struct pci_dev *pci)
+int snd_pci_compat_save_state(struct pci_dev *pci)
 {
 	int i;
 	/* FIXME: mutex needed for race? */
@@ -130,14 +130,15 @@
 		if (! saved_tbl[i].pci) {
 			saved_tbl[i].pci = pci;
 			snd_pci_orig_save_state(pci, saved_tbl[i].config);
-			return;
+			return 0;
 		}
 	}
 	printk(KERN_DEBUG "snd: no pci config space found!\n");
+	return 1;
 }
 EXPORT_SYMBOL(snd_pci_compat_save_state);
 
-void snd_pci_compat_restore_state(struct pci_dev *pci)
+int snd_pci_compat_restore_state(struct pci_dev *pci)
 {
 	int i;
 	/* FIXME: mutex needed for race? */
@@ -145,10 +146,11 @@
 		if (saved_tbl[i].pci == pci) {
 			saved_tbl[i].pci = NULL;
 			snd_pci_orig_restore_state(pci, saved_tbl[i].config);
-			return;
+			return 0;
 		}
 	}
 	printk(KERN_DEBUG "snd: no saved pci config!\n");
+	return 1;
 }
 EXPORT_SYMBOL(snd_pci_compat_restore_state);
 #endif /* CONFIG_HAVE_PCI_SAVED_CONFIG */
Index: alsa-driver/include/adriver.h
===================================================================
RCS file: /usr/local/cvs_repos/almond/alsa/alsa-driver/include/adriver.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- alsa-driver/include/adriver.h	20 Jan 2008 16:52:37 -0000	1.1
+++ alsa-driver/include/adriver.h	20 Jan 2008 17:14:23 -0000	1.2
@@ -1165,15 +1165,15 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
 #ifdef CONFIG_PCI
 #ifndef CONFIG_HAVE_NEW_PCI_SAVE_STATE
-void snd_pci_compat_save_state(struct pci_dev *pci);
-void snd_pci_compat_restore_state(struct pci_dev *pci);
-static inline void snd_pci_orig_save_state(struct pci_dev *pci, u32 *buffer)
+int snd_pci_compat_save_state(struct pci_dev *pci);
+int snd_pci_compat_restore_state(struct pci_dev *pci);
+static inline int snd_pci_orig_save_state(struct pci_dev *pci, u32 *buffer)
 {
-	pci_save_state(pci, buffer);
+	return pci_save_state(pci, buffer);
 }
-static inline void snd_pci_orig_restore_state(struct pci_dev *pci, u32 *buffer)
+static inline int snd_pci_orig_restore_state(struct pci_dev *pci, u32 *buffer)
 {
-	pci_restore_state(pci, buffer);
+	return pci_restore_state(pci, buffer);
 }
 
 #undef pci_save_state


More information about the Alsa-devel mailing list