Skip to contentSkip to conversation

drivers/cdrom/isp16.c: small cleanups

PATCH In review Adrian Bunk 3 participants 5 messages Jan 29, 2005 – Jan 30, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/cdrom/isp16.c: small cleanups

This patch makes the needlessly global function isp16_init static.

As a result, it turned out that both this function and some other code are only required #ifdef MODULE.

---

 drivers/cdrom/isp16.c |   13 ++++++++-----
 drivers/cdrom/isp16.h |    1 -
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/cdrom/isp16.h renamed from drivers/cdrom/isp16.h.old +0 -1
@@ -71,4 +71,3 @@
 #define ISP16_IO_BASE 0xF8D
 #define ISP16_IO_SIZE 5  /* ports used from 0xF8D up to 0xF91 */
 
-int isp16_init(void);
drivers/cdrom/isp16.c renamed from drivers/cdrom/isp16.c.old +8 -5
@@ -58,6 +58,7 @@
 #include <asm/io.h>
 #include "isp16.h"
 
+#ifdef MODULE
 static short isp16_detect(void);
 static short isp16_c928__detect(void);
 static short isp16_c929__detect(void);
@@ -66,6 +67,7 @@
 static short isp16_type;	/* dependent on type of interface card */
 static u_char isp16_ctrl;
 static u_short isp16_enable_port;
+#endif  /*  MODULE  */
 
 static int isp16_cdrom_base = ISP16_CDROM_IO_BASE;
 static int isp16_cdrom_irq = ISP16_CDROM_IRQ;
@@ -106,13 +108,13 @@
 
 __setup("isp16=", isp16_setup);
 
-#endif				/* MODULE */
+#else				/* MODULE */
 
 /*
  *  ISP16 initialisation.
  *
  */
-int __init isp16_init(void)
+static int __init isp16_init(void)
 {
 	u_char expected_drive;
 
@@ -366,15 +368,16 @@
 	return 0;
 }
 
+module_init(isp16_init);
+
+#endif
+
 void __exit isp16_exit(void)
 {
 	release_region(ISP16_IO_BASE, ISP16_IO_SIZE);
 	printk(KERN_INFO "ISP16: module released.\n");
 }
 
-#ifdef MODULE
-module_init(isp16_init);
-#endif
 module_exit(isp16_exit);
 
 MODULE_LICENSE("GPL");
#1 lore raw

Hi,

Quoted 4 lines · Adrian Bunk

This patch makes the needlessly global function isp16_init static.

As a result, it turned out that both this function and some other code are only required #ifdef MODULE.

Your patch is correct but it is wrong. ;)

#ifdefs around isp16_init() need to be removed as otherwise this driver is not initialized in built-in case.

Bartlomiej

Quoted 70 lines

---

 drivers/cdrom/isp16.c |   13 ++++++++-----
 drivers/cdrom/isp16.h |    1 -
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/cdrom/isp16.h 2005-01-29 16:47:11.000000000 +0100 renamed from drivers/cdrom/isp16.h.old 2005-01-29 16:46:18.000000000 +0100 +0 -1
@@ -71,4 +71,3 @@
 #define ISP16_IO_BASE 0xF8D
 #define ISP16_IO_SIZE 5  /* ports used from 0xF8D up to 0xF91 */
 
-int isp16_init(void);
drivers/cdrom/isp16.c 2005-01-29 17:46:38.000000000 +0100 renamed from drivers/cdrom/isp16.c.old 2005-01-29 16:47:19.000000000 +0100 +8 -5
@@ -58,6 +58,7 @@
 #include <asm/io.h>
 #include "isp16.h"
 
+#ifdef MODULE
 static short isp16_detect(void);
 static short isp16_c928__detect(void);
 static short isp16_c929__detect(void);
@@ -66,6 +67,7 @@
 static short isp16_type;       /* dependent on type of interface card */
 static u_char isp16_ctrl;
 static u_short isp16_enable_port;
+#endif  /*  MODULE  */
 
 static int isp16_cdrom_base = ISP16_CDROM_IO_BASE;
 static int isp16_cdrom_irq = ISP16_CDROM_IRQ;
@@ -106,13 +108,13 @@
 
 __setup("isp16=", isp16_setup);
 
-#endif                         /* MODULE */
+#else                          /* MODULE */
 
 /*
  *  ISP16 initialisation.
  *
  */
-int __init isp16_init(void)
+static int __init isp16_init(void)
 {
        u_char expected_drive;
 
@@ -366,15 +368,16 @@
        return 0;
 }
 
+module_init(isp16_init);
+
+#endif
+
 void __exit isp16_exit(void)
 {
        release_region(ISP16_IO_BASE, ISP16_IO_SIZE);
        printk(KERN_INFO "ISP16: module released.\n");
 }
 
-#ifdef MODULE
-module_init(isp16_init);
-#endif
 module_exit(isp16_exit);
 
 MODULE_LICENSE("GPL");
#2 lore raw
Quoted 5 lines · Bartlomiej Zolnierkiewicz

Hi,

Quoted 2 lines · Adrian Bunk

This patch makes the needlessly global function isp16_init static.

Quoted 7 lines
Quoted 2 lines

As a result, it turned out that both this function and some other code are only required #ifdef MODULE.

Your patch is correct but it is wrong. ;)

#ifdefs around isp16_init() need to be removed as otherwise this driver is not initialized in built-in case.

It's somehow initialized via isp16_setup.

Quoted 1 line

Bartlomiej

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw
Quoted 9 lines · Adrian Bunk
Quoted 8 lines · Bartlomiej Zolnierkiewicz

Hi,

Quoted 4 lines · Adrian Bunk

This patch makes the needlessly global function isp16_init static.

As a result, it turned out that both this function and some other code are only required #ifdef MODULE.

Quoted 6 lines
Quoted 4 lines

Your patch is correct but it is wrong. ;)

#ifdefs around isp16_init() need to be removed as otherwise this driver is not initialized in built-in case.

It's somehow initialized via isp16_setup.

Could you explain?

AFAICS isp16_setup() only handles "isp16=" boot parameter.

#4 lore raw
Quoted 9 lines · Bartlomiej Zolnierkiewicz
Quoted 8 lines · Adrian Bunk
Quoted 7 lines · Bartlomiej Zolnierkiewicz

Hi,

Quoted 4 lines · Adrian Bunk

This patch makes the needlessly global function isp16_init static.

As a result, it turned out that both this function and some other code are only required #ifdef MODULE.

... assuming that driver had not been broken to start with

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Your patch is correct but it is wrong. ;)

#ifdefs around isp16_init() need to be removed as otherwise this driver is not initialized in built-in case.

... assuming that driver is initialized in built-in case

Quoted 1 line
Quoted 1 line

It's somehow initialized via isp16_setup.

... assuming that magic exists, which would follow from the original assumptions

Quoted 3 lines

Could you explain?

AFAICS isp16_setup() only handles "isp16=" boot parameter.

Simple: driver is broken. And "obvious" transformations of that sort are safe only when they are applied to correct code. Otherwise you end up with obfuscation of original breakage.

Trivial check of history shows that
a) until 2.5.1-pre1 isp16_init() had been called from blk_dev_init()
b) in 2.5.1-pre2 Jens had taken that call out, but forgot to remove
ifdef in isp16.c
c) nobody had cared since then.

Fix follows.

drivers/cdrom/isp16.c +2 -4
diff -u RC11-rc2-bk6-base/drivers/cdrom/isp16.c RC11-rc2-bk6-current/drivers/cdrom/isp16.c
@@ -112,7 +112,7 @@
  *  ISP16 initialisation.
  *
  */
-int __init isp16_init(void)
+static int __init isp16_init(void)
 {
 	u_char expected_drive;
 
@@ -366,15 +366,13 @@
 	return 0;
 }
 
-void __exit isp16_exit(void)
+static void __exit isp16_exit(void)
 {
 	release_region(ISP16_IO_BASE, ISP16_IO_SIZE);
 	printk(KERN_INFO "ISP16: module released.\n");
 }
 
-#ifdef MODULE
 module_init(isp16_init);
-#endif
 module_exit(isp16_exit);
 
 MODULE_LICENSE("GPL");