| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /*  | 
 | 2 |  * Copyright (C) 1996, 1997 Claus-Justus Heine. | 
 | 3 |  | 
 | 4 |  This program is free software; you can redistribute it and/or modify | 
 | 5 |  it under the terms of the GNU General Public License as published by | 
 | 6 |  the Free Software Foundation; either version 2, or (at your option) | 
 | 7 |  any later version. | 
 | 8 |  | 
 | 9 |  This program is distributed in the hope that it will be useful, | 
 | 10 |  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 11 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 12 |  GNU General Public License for more details. | 
 | 13 |  | 
 | 14 |  You should have received a copy of the GNU General Public License | 
 | 15 |  along with this program; see the file COPYING.  If not, write to | 
 | 16 |  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 
 | 17 |  | 
 | 18 |  * | 
 | 19 |  * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-setup.c,v $ | 
 | 20 |  * $Revision: 1.7 $ | 
 | 21 |  * $Date: 1997/10/10 09:57:06 $ | 
 | 22 |  * | 
 | 23 |  *      This file contains the code for processing the kernel command | 
 | 24 |  *      line options for the QIC-40/80/3010/3020 floppy-tape driver | 
 | 25 |  *      "ftape" for Linux. | 
 | 26 |  */ | 
 | 27 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/string.h> | 
 | 29 | #include <linux/errno.h> | 
 | 30 | #include <linux/mm.h> | 
 | 31 |  | 
 | 32 | #include <linux/ftape.h> | 
 | 33 | #include <linux/init.h> | 
 | 34 | #include "../lowlevel/ftape-tracing.h" | 
 | 35 | #include "../lowlevel/fdc-io.h" | 
 | 36 |  | 
 | 37 | static struct param_table { | 
 | 38 | 	const char *name; | 
 | 39 | 	int *var; | 
 | 40 | 	int def_param; | 
 | 41 | 	int min; | 
 | 42 | 	int max; | 
 | 43 | } config_params[] __initdata = { | 
 | 44 | #ifndef CONFIG_FT_NO_TRACE_AT_ALL | 
 | 45 | 	{ "tracing",   &ftape_tracing,     3,              ft_t_bug, ft_t_any}, | 
 | 46 | #endif | 
 | 47 | 	{ "ioport",    &ft_fdc_base,       CONFIG_FT_FDC_BASE,     0x0, 0xfff}, | 
 | 48 | 	{ "irq",       &ft_fdc_irq,        CONFIG_FT_FDC_IRQ,        2,    15}, | 
 | 49 | 	{ "dma",       &ft_fdc_dma,        CONFIG_FT_FDC_DMA,        0,     3}, | 
 | 50 | 	{ "threshold", &ft_fdc_threshold,  CONFIG_FT_FDC_THR,         1,    16}, | 
 | 51 | 	{ "datarate",  &ft_fdc_rate_limit, CONFIG_FT_FDC_MAX_RATE, 500,  2000}, | 
 | 52 | 	{ "fc10",      &ft_probe_fc10,     CONFIG_FT_PROBE_FC10,     0,     1}, | 
 | 53 | 	{ "mach2",     &ft_mach2,          CONFIG_FT_MACH2,          0,     1} | 
 | 54 | }; | 
 | 55 |  | 
 | 56 | static int __init ftape_setup(char *str) | 
 | 57 | { | 
 | 58 | 	int i; | 
 | 59 | 	int param; | 
 | 60 | 	int ints[2]; | 
 | 61 |  | 
 | 62 | 	TRACE_FUN(ft_t_flow); | 
 | 63 |  | 
 | 64 | 	str = get_options(str, ARRAY_SIZE(ints), ints); | 
 | 65 | 	if (str) { | 
 | 66 | 		for (i=0; i < NR_ITEMS(config_params); i++) { | 
 | 67 | 			if (strcmp(str,config_params[i].name) == 0){ | 
 | 68 | 				if (ints[0]) { | 
 | 69 | 					param = ints[1]; | 
 | 70 | 				} else { | 
 | 71 | 					param = config_params[i].def_param; | 
 | 72 | 				} | 
 | 73 | 				if (param < config_params[i].min || | 
 | 74 | 				    param > config_params[i].max) { | 
 | 75 | 					TRACE(ft_t_err, | 
 | 76 | 					"parameter %s out of range %d ... %d", | 
 | 77 | 					      config_params[i].name, | 
 | 78 | 					      config_params[i].min, | 
 | 79 | 					      config_params[i].max); | 
 | 80 | 					goto out; | 
 | 81 | 				} | 
 | 82 | 				if(config_params[i].var) { | 
 | 83 | 					TRACE(ft_t_info, "%s=%d", str, param); | 
 | 84 | 					*config_params[i].var = param; | 
 | 85 | 				} | 
 | 86 | 				goto out; | 
 | 87 | 			} | 
 | 88 | 		} | 
 | 89 | 	} | 
 | 90 | 	if (str) { | 
 | 91 | 		TRACE(ft_t_err, "unknown ftape option [%s]", str); | 
 | 92 | 		 | 
 | 93 | 		TRACE(ft_t_err, "allowed options are:"); | 
 | 94 | 		for (i=0; i < NR_ITEMS(config_params); i++) { | 
 | 95 | 			TRACE(ft_t_err, " %s",config_params[i].name); | 
 | 96 | 		} | 
 | 97 | 	} else { | 
 | 98 | 		TRACE(ft_t_err, "botched ftape option"); | 
 | 99 | 	} | 
 | 100 |  out: | 
 | 101 | 	TRACE_EXIT 1; | 
 | 102 | } | 
 | 103 |  | 
 | 104 | __setup("ftape=", ftape_setup); |