From: Geert Uytterhoeven Mac ESP SCSI: Update argument parsing (from Matthias Urlichs) drivers/scsi/mac_esp.c | 119 +++++++++++++++++++++++++------------------------ 1 files changed, 63 insertions(+), 56 deletions(-) diff -puN drivers/scsi/mac_esp.c~68k-359 drivers/scsi/mac_esp.c --- 25/drivers/scsi/mac_esp.c~68k-359 2004-01-01 13:42:44.000000000 -0800 +++ 25-akpm/drivers/scsi/mac_esp.c 2004-01-01 13:42:44.000000000 -0800 @@ -151,92 +151,98 @@ irqreturn_t fake_drq(int irq, void *dev_ #define DRIVER_SETUP /* - * Function : mac_esp_setup(char *str, int *ints) + * Function : mac_esp_setup(char *str) * * Purpose : booter command line initialization of the overrides array, * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. + * Inputs : str - parameters, separated by commas. * * Currently unused in the new driver; need to add settable parameters to the * detect function. * */ -static int __init mac_esp_setup(char *str, int *ints) { +static int __init mac_esp_setup(char *str) { #ifdef DRIVER_SETUP /* Format of mac53c9x parameter is: * mac53c9x=,,,,,,, * Negative values mean don't change. */ - /* Grmbl... the standard parameter parsing can't handle negative numbers - * :-( So let's do it ourselves! - */ + char *this_opt; + long opt; - int i = ints[0]+1, fact; + this_opt = strsep (&str, ","); + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + + if (opt >= 0 && opt <= 2) + setup_num_esps = opt; + else if (opt > 2) + printk( "mac_esp_setup: invalid number of hosts %ld !\n", opt ); - while( str && (isdigit(*str) || *str == '-') && i <= 10) { - if (*str == '-') - fact = -1, ++str; - else - fact = 1; - ints[i++] = simple_strtoul( str, NULL, 0 ) * fact; - if ((str = strchr( str, ',' )) != NULL) - ++str; + this_opt = strsep (&str, ","); } - ints[0] = i-1; + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); - if (ints[0] < 1) { - printk( "mac_esp_setup: no arguments!\n" ); - return 0; + if (opt > 0) + setup_disconnect = opt; + + this_opt = strsep (&str, ","); } + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); - if (ints[0] >= 1) { - if (ints[1] > 0) - /* no limits on this, just > 0 */ - if (ints[1] >= 0 && ints[1] <= 2) - setup_num_esps = ints[1]; - else if (ints[1] > 2) - printk( "mac_esp_setup: invalid number of hosts %d !\n", ints[1] ); - } - if (ints[0] >= 2) { - if (ints[2] > 0) - setup_disconnect = ints[2]; - } - if (ints[0] >= 3) { - if (ints[3] >= 0) { - setup_nosync = ints[3]; - } + if (opt >= 0) + setup_nosync = opt; + + this_opt = strsep (&str, ","); + } + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + + if (opt > 0) + setup_can_queue = opt; + + this_opt = strsep (&str, ","); } - if (ints[0] >= 4) { - if (ints[4] > 0) - /* no limits on this, just > 0 */ - setup_can_queue = ints[4]; - } - if (ints[0] >= 5) { - if (ints[5] > 0) - setup_cmd_per_lun = ints[5]; - } - if (ints[0] >= 6) { - if (ints[6] >= 0) { - setup_sg_tablesize = ints[6]; + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + + if (opt > 0) + setup_cmd_per_lun = opt; + + this_opt = strsep (&str, ","); + } + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + + if (opt >= 0) { + setup_sg_tablesize = opt; /* Must be <= SG_ALL (255) */ if (setup_sg_tablesize > SG_ALL) setup_sg_tablesize = SG_ALL; } + + this_opt = strsep (&str, ","); } - if (ints[0] >= 7) { + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + /* Must be between 0 and 7 */ - if (ints[7] >= 0 && ints[7] <= 7) - setup_hostid = ints[7]; - else if (ints[7] > 7) - printk( "mac_esp_setup: invalid host ID %d !\n", ints[7] ); + if (opt >= 0 && opt <= 7) + setup_hostid = opt; + else if (opt > 7) + printk( "mac_esp_setup: invalid host ID %ld !\n", opt); + + this_opt = strsep (&str, ","); } #ifdef SUPPORT_TAGS - if (ints[0] >= 8) { - if (ints[8] >= 0) - setup_use_tagged_queuing = !!ints[8]; + if(this_opt) { + opt = simple_strtol( this_opt, NULL, 0 ); + if (opt >= 0) + setup_use_tagged_queuing = !!opt; } #endif #endif @@ -245,6 +251,7 @@ static int __init mac_esp_setup(char *st __setup("mac53c9x=", mac_esp_setup); + /* * ESP address 'detection' */ _