Messages in this thread Patch in this message | | | Date | Tue, 27 Apr 1999 03:38:41 -0400 | From | kernel@whitesta ... | Subject | Re: [PATCH]: aha1542.c, support for insmod parameters |
| |
I have done the same thing myself but I think my patch is a little cleaner, though it currently does not support setting the dma speed..
Comments below...
On Mon, Apr 26, 1999 at 09:54:24PM -0400, Eddie Mansu wrote: > > I've got an aha1542 SCSI card using a non-standard base address, > but I'm loading the driver as a module.. Previously, this driver didn't > support insmod parameters, and that sucked, so I added them.. Currently, > this only supports one card. I had no need to add support for more, and > the people I talked to had no real need for more than one when loading as > a module. > I'd appreciate any comments/feedback about this patch. Please > send them to spackle@one.net, I won't see them otherwise. > > Here we go: > <snip> > +/* These are used with insmod parameters */ > +static int aha1542[NUMPARMS] = { > + 0x0, /* base address */ > + 0, /* buson */ > + 0, /* busoff */ > + 0, /* dmaspeed */ > +};
This is IMHO ugly, we can name them now, why don't we? > + > +static int base_address = 0; > + > +static int allowed_base_address[] = {0x130,0x134,0x230,0x234,0x330,0x334}; > +static int buson = 0; > +static int allowed_buson[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15}; > +static int busoff = 0; > +static int allowed_busoff[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, > + 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, > + 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, > + 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64}; > +static int dmaspeed = 0; > +static int allowed_dmaspeed[] = {5,6,7,8,10};
LOTS of checking which is not done if compiled into the kernel, perhaps it should be added if its really needed, however I don't see the point, and there are much cleaner ways then this..
<snip> > /* Eventually this will go into an include file, but this will be later */ > Scsi_Host_Template driver_template = AHA1542; > > -#include "scsi_module.c" > -#endif > +int init_module(void) {
Why not just copy the code from above where the boot prams are handled?
<snip>
> Again, please E-Mail to spackle@one.net; I may not see the replies posted > to the list. Thanks.
Done..
Attached is my patch, a bit smaller, but it does not support the dma speed setting..
Zephaniah E. Hull. > > Eddie Mansu > spackle@one.net diff -ru linux/drivers/scsi/aha1542.c linux-2.2.5-1542/drivers/scsi/aha1542.c --- linux/drivers/scsi/aha1542.c Wed Oct 7 18:52:55 1998 +++ linux-2.2.5-1542/drivers/scsi/aha1542.c Thu Apr 8 10:21:43 1999 @@ -3,6 +3,7 @@ * * Copyright (C) 1992 Tommy Thorn * Copyright (C) 1993, 1994, 1995 Eric Youngdale + * Copyright (C) 1999 Zephaniah E. Hull * * Modified by Eric Youngdale * Use request_irq and request_dma to help prevent unexpected conflicts @@ -18,6 +19,8 @@ * 1-Jan-97 * Modified by Bjorn L. Thordarson and Einar Thor Einarsson * Recognize that DMA0 is valid DMA channel -- 13-Jul-98 + * Modified by Zephaniah E. Hull + * Added ioport, buson, and busoff module options -- 8-Apr-98 */ #include <linux/module.h> @@ -73,12 +76,11 @@ #define MAXBOARDS 2 /* Increase this and the sizes of the arrays below, if you need more.. */ -static unsigned int bases[MAXBOARDS]={0x330, 0x334}; +static unsigned int io_port[MAXBOARDS]={0x330, 0x334}; /* set by aha1542_setup according to the command line */ -static int setup_called[MAXBOARDS] = {0,0}; -static int setup_buson[MAXBOARDS] = {0,0}; -static int setup_busoff[MAXBOARDS] = {0,0}; +static int buson[MAXBOARDS] = {0,0}; +static int busoff[MAXBOARDS] = {0,0}; static int setup_dmaspeed[MAXBOARDS] = {-1,-1}; static char *setup_str[MAXBOARDS] = {(char *)NULL,(char *)NULL}; @@ -898,12 +900,11 @@ printk("aha1542: Wrong parameters may cause system malfunction.. We try anyway..\n"); } - setup_called[setup_idx]=ints[0]; setup_str[setup_idx]=str; setup_portbase = ints[0] >= 1 ? ints[1] : 0; /* Preserve the default value.. */ - setup_buson [setup_idx] = ints[0] >= 2 ? ints[2] : 7; - setup_busoff [setup_idx] = ints[0] >= 3 ? ints[3] : 5; + buson [setup_idx] = ints[0] >= 2 ? ints[2] : 7; + busoff [setup_idx] = ints[0] >= 3 ? ints[3] : 5; if (ints[0] >= 4) { int atbt = -1; switch (ints[4]) { @@ -932,7 +933,7 @@ } if (setup_portbase != 0) - bases[setup_idx] = setup_portbase; + io_port[setup_idx] = setup_portbase; ++setup_idx; } @@ -954,8 +955,8 @@ tpnt->proc_dir = &proc_scsi_aha1542; - for(indx = 0; indx < sizeof(bases)/sizeof(bases[0]); indx++) - if(bases[indx] != 0 && !check_region(bases[indx], 4)) { + for(indx = 0; indx < sizeof(io_port)/sizeof(io_port[0]); indx++) + if(io_port[indx] != 0 && !check_region(io_port[indx], 4)) { shpnt = scsi_register(tpnt, sizeof(struct aha1542_hostdata)); @@ -966,21 +967,22 @@ goto unregister; } - if(!aha1542_test_port(bases[indx], shpnt)) goto unregister; + if(!aha1542_test_port(io_port[indx], shpnt)) goto unregister; - base_io = bases[indx]; + base_io = io_port[indx]; /* Set the Bus on/off-times as not to ruin floppy performance */ { unchar oncmd[] = {CMD_BUSON_TIME, 7}; unchar offcmd[] = {CMD_BUSOFF_TIME, 5}; - if(setup_called[indx]) - { - oncmd[1] = setup_buson[indx]; - offcmd[1] = setup_busoff[indx]; - } + if (buson[indx]) { + oncmd[1] = buson[indx]; + } + if (busoff[indx]) { + offcmd[1] = busoff[indx]; + } aha1542_intr_reset(base_io); aha1542_out(base_io, oncmd, 2); @@ -1085,7 +1087,7 @@ aha1542_command(0, cmd, buffer, 512); } #endif - request_region(bases[indx], 4,"aha1542"); /* Register the IO ports that we use */ + request_region(io_port[indx], 4,"aha1542"); /* Register the IO ports that we use */ count++; continue; unregister: @@ -1590,6 +1592,9 @@ #ifdef MODULE /* Eventually this will go into an include file, but this will be later */ Scsi_Host_Template driver_template = AHA1542; +MODULE_PARM(io_port, "1-" __MODULE_STRING(MAXBOARDS) "i"); +MODULE_PARM(buson, "1-" __MODULE_STRING(MAXBOARDS) "i"); +MODULE_PARM(busoff, "1-" __MODULE_STRING(MAXBOARDS) "i"); #include "scsi_module.c" #endif | |