lkml.org 
[lkml]   [2000]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Fix sg in 2.4.0-test9-pre5 when builtin
Linus,
This patch has been generated in response to the thread:
"[2.4.0-test9-pre5] SCSI still broken, trident/mixer
still broken" on lkml today. Simon Kirby reported that
the SCSI generic (sg) wasn't working in the latest
pre-release when the driver was built into the kernel.

Torben Mathiasen wrote:
>
> On Thu, Sep 21 2000, Douglas Gilbert wrote:
> > Torben Mathiasen wrote:
> > >
> > > Ok, small patch cooked up. Not tested, not compiled. Give
> > > it a try, and if it works please send it off to Linus.
> > > I really need to get some work done on a project...
> >
> > Here is a very similar patch that has been tested
> > [with a USB zip drive using sg (builtin) to read it].
> > It worked and the /proc/scsi/sg directory was
> > properly populated.
> >
>
> Looks good, but you should make the init functions static.

Done. Also added conditionals to make it compile cleanly
when procfs is not present. Tested as builtin and module,
with and without procfs.

Doug Gilbert--- linux/include/scsi/sg.h Sun Jul 16 18:38:11 2000
+++ linux/include/scsi/sg.h3117 Thu Sep 21 20:00:08 2000
@@ -11,9 +11,13 @@
Version 2 and 3 extensions to driver:
* Copyright (C) 1998 - 2000 Douglas Gilbert

- Version: 3.1.16 (20000716)
- This version is for 2.3/2.4 series kernels.
+ Version: 3.1.17 (20000921)
+ This version is for 2.4 series kernels.

+ Changes since 3.1.16 (20000716)
+ - changes for new scsi subsystem initialization
+ - change Scsi_Cmnd usage to Scsi_Request
+ - cleanup for no procfs
Changes since 3.1.15 (20000528)
- further (scatter gather) buffer length changes
Changes since 3.1.14 (20000503)
--- linux/drivers/scsi/sg.c Wed Sep 20 22:06:26 2000
+++ linux/drivers/scsi/sg.c3117 Thu Sep 21 20:13:12 2000
@@ -17,8 +17,11 @@
* any later version.
*
*/
- static char * sg_version_str = "Version: 3.1.16 (20000716)";
- static int sg_version_num = 30116; /* 2 digits for each component */
+#include <linux/config.h>
+#ifdef CONFIG_PROC_FS
+ static char * sg_version_str = "Version: 3.1.17 (20000921)";
+#endif
+ static int sg_version_num = 30117; /* 2 digits for each component */
/*
* D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au), notes:
* - scsi logging is available via SCSI_LOG_TIMEOUT macros. First
@@ -38,7 +41,6 @@
* # cat /proc/scsi/sg/debug
*
*/
-#include <linux/config.h>
#include <linux/module.h>

#include <linux/fs.h>
@@ -235,10 +237,12 @@
static int sg_ms_to_jif(unsigned int msecs);
static unsigned sg_jif_to_ms(int jifs);
static int sg_allow_access(unsigned char opcode, char dev_type);
-static int sg_last_dev(void);
static int sg_build_dir(Sg_request * srp, Sg_fd * sfp, int dxfer_len);
static void sg_unmap_and(Sg_scatter_hold * schp, int free_also);
static Sg_device * sg_get_dev(int dev);
+#ifdef CONFIG_PROC_FS
+static int sg_last_dev(void);
+#endif

static Sg_device ** sg_dev_arr = NULL;

@@ -1298,18 +1302,20 @@
}

#ifdef MODULE
-
MODULE_PARM(def_reserved_size, "i");
MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd");
+#endif /* MODULE */

-int init_module(void) {
+static int __init init_sg(void) {
+#ifdef MODULE
if (def_reserved_size >= 0)
sg_big_buff = def_reserved_size;
+#endif /* MODULE */
sg_template.module = THIS_MODULE;
return scsi_register_module(MODULE_SCSI_DEV, &sg_template);
}

-void cleanup_module( void)
+static void __exit exit_sg( void)
{
#ifdef CONFIG_PROC_FS
sg_proc_cleanup();
@@ -1324,7 +1330,6 @@
}
sg_template.dev_max = 0;
}
-#endif /* MODULE */


#if 0
@@ -1972,6 +1977,7 @@
return resp;
}

+#ifdef CONFIG_PROC_FS
static Sg_request * sg_get_nth_request(Sg_fd * sfp, int nth)
{
Sg_request * resp;
@@ -1985,6 +1991,7 @@
read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
return resp;
}
+#endif

/* always adds to end of list */
static Sg_request * sg_add_request(Sg_fd * sfp)
@@ -2064,6 +2071,7 @@
return res;
}

+#ifdef CONFIG_PROC_FS
static Sg_fd * sg_get_nth_sfp(Sg_device * sdp, int nth)
{
Sg_fd * resp;
@@ -2077,6 +2085,7 @@
read_unlock_irqrestore(&sg_dev_arr_lock, iflags);
return resp;
}
+#endif

static Sg_fd * sg_add_sfp(Sg_device * sdp, int dev)
{
@@ -2410,6 +2419,7 @@
}


+#ifdef CONFIG_PROC_FS
static int sg_last_dev()
{
int k;
@@ -2421,6 +2431,7 @@
read_unlock_irqrestore(&sg_dev_arr_lock, iflags);
return k + 1; /* origin 1 */
}
+#endif

static Sg_device * sg_get_dev(int dev)
{
@@ -2782,3 +2793,7 @@
return 1;
}
#endif /* CONFIG_PROC_FS */
+
+
+module_init(init_sg);
+module_exit(exit_sg);
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.070 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site