ftape-setup.c 3.0 KB

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