Commit e608460dee4c2de3a01f67c1bac21adb61d617e3

Authored by Dmitry Torokhov
1 parent ba7376e934

Input: mad16 (OSS) - do not carry around gameport code if gameport core

support is disabled.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

Showing 1 changed file with 23 additions and 7 deletions Side-by-side Diff

... ... @@ -50,9 +50,12 @@
50 50 #include "sb.h"
51 51 #include "mpu401.h"
52 52  
  53 +#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
  54 +#define SUPPORT_JOYSTICK 1
  55 +#endif
  56 +
53 57 static int mad16_conf;
54 58 static int mad16_cdsel;
55   -static struct gameport *gameport;
56 59 static DEFINE_SPINLOCK(lock);
57 60  
58 61 #define C928 1
... ... @@ -902,6 +905,10 @@
902 905 -1, -1, -1, -1
903 906 };
904 907  
  908 +#ifdef SUPPORT_JOYSTICK
  909 +
  910 +static struct gameport *gameport;
  911 +
905 912 static int __devinit mad16_register_gameport(int io_port)
906 913 {
907 914 if (!request_region(io_port, 1, "mad16 gameport")) {
... ... @@ -925,6 +932,20 @@
925 932 return 0;
926 933 }
927 934  
  935 +static inline void mad16_unregister_gameport(void)
  936 +{
  937 + if (gameport) {
  938 + /* the gameport was initialized so we must free it up */
  939 + gameport_unregister_port(gameport);
  940 + gameport = NULL;
  941 + release_region(0x201, 1);
  942 + }
  943 +}
  944 +#else
  945 +static inline int mad16_register_gameport(int io_port) { return -ENOSYS; }
  946 +static inline void mad16_unregister_gameport(void) { }
  947 +#endif
  948 +
928 949 static int __devinit init_mad16(void)
929 950 {
930 951 int dmatype = 0;
... ... @@ -1060,12 +1081,7 @@
1060 1081 {
1061 1082 if (found_mpu)
1062 1083 unload_mad16_mpu(&cfg_mpu);
1063   - if (gameport) {
1064   - /* the gameport was initialized so we must free it up */
1065   - gameport_unregister_port(gameport);
1066   - gameport = NULL;
1067   - release_region(0x201, 1);
1068   - }
  1084 + mad16_unregister_gameport();
1069 1085 unload_mad16(&cfg);
1070 1086 release_region(MC0_PORT, 12);
1071 1087 }