ftape-setup.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/config.h>
  24. #include <linux/string.h>
  25. #include <linux/errno.h>
  26. #include <linux/mm.h>
  27. #include <linux/ftape.h>
  28. #include <linux/init.h>
  29. #include "../lowlevel/ftape-tracing.h"
  30. #include "../lowlevel/fdc-io.h"
  31. static struct param_table {
  32. const char *name;
  33. int *var;
  34. int def_param;
  35. int min;
  36. int max;
  37. } config_params[] __initdata = {
  38. #ifndef CONFIG_FT_NO_TRACE_AT_ALL
  39. { "tracing", &ftape_tracing, 3, ft_t_bug, ft_t_any},
  40. #endif
  41. { "ioport", &ft_fdc_base, CONFIG_FT_FDC_BASE, 0x0, 0xfff},
  42. { "irq", &ft_fdc_irq, CONFIG_FT_FDC_IRQ, 2, 15},
  43. { "dma", &ft_fdc_dma, CONFIG_FT_FDC_DMA, 0, 3},
  44. { "threshold", &ft_fdc_threshold, CONFIG_FT_FDC_THR, 1, 16},
  45. { "datarate", &ft_fdc_rate_limit, CONFIG_FT_FDC_MAX_RATE, 500, 2000},
  46. { "fc10", &ft_probe_fc10, CONFIG_FT_PROBE_FC10, 0, 1},
  47. { "mach2", &ft_mach2, CONFIG_FT_MACH2, 0, 1}
  48. };
  49. static int __init ftape_setup(char *str)
  50. {
  51. int i;
  52. int param;
  53. int ints[2];
  54. TRACE_FUN(ft_t_flow);
  55. str = get_options(str, ARRAY_SIZE(ints), ints);
  56. if (str) {
  57. for (i=0; i < NR_ITEMS(config_params); i++) {
  58. if (strcmp(str,config_params[i].name) == 0){
  59. if (ints[0]) {
  60. param = ints[1];
  61. } else {
  62. param = config_params[i].def_param;
  63. }
  64. if (param < config_params[i].min ||
  65. param > config_params[i].max) {
  66. TRACE(ft_t_err,
  67. "parameter %s out of range %d ... %d",
  68. config_params[i].name,
  69. config_params[i].min,
  70. config_params[i].max);
  71. goto out;
  72. }
  73. if(config_params[i].var) {
  74. TRACE(ft_t_info, "%s=%d", str, param);
  75. *config_params[i].var = param;
  76. }
  77. goto out;
  78. }
  79. }
  80. }
  81. if (str) {
  82. TRACE(ft_t_err, "unknown ftape option [%s]", str);
  83. TRACE(ft_t_err, "allowed options are:");
  84. for (i=0; i < NR_ITEMS(config_params); i++) {
  85. TRACE(ft_t_err, " %s",config_params[i].name);
  86. }
  87. } else {
  88. TRACE(ft_t_err, "botched ftape option");
  89. }
  90. out:
  91. TRACE_EXIT 1;
  92. }
  93. __setup("ftape=", ftape_setup);