root/lm-sensors/trunk/kernel/busses/i2c-isa.c @ 583

Revision 583, 3.9 KB (checked in by frodo, 14 years ago)

`functionality' support for all bus drivers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware
3            monitoring
4    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21/* This implements an i2c algorithm/adapter for ISA bus. Not that this is
22   on first sight very useful; almost no functionality is preserved.
23   Except that it makes writing drivers for chips which can be on both
24   the SMBus and the ISA bus very much easier. See lm78.c for an example
25   of this. */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29
30#include <linux/i2c.h>
31
32#include "compat.h"
33
34#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,53)
35#include <linux/init.h>
36#else
37#define __init
38#define __initdata
39#endif
40
41#include "version.h"
42#include "i2c-isa.h"
43
44static void isa_inc_use (struct i2c_adapter *adapter);
45static void isa_dec_use (struct i2c_adapter *adapter);
46static u32 isa_func(struct i2c_adapter *adapter);
47
48#ifdef MODULE
49static
50#else
51extern
52#endif
53       int __init i2c_isa_init(void);
54static int __init isa_cleanup(void);
55
56#ifdef MODULE
57extern int init_module(void);
58extern int cleanup_module(void);
59#endif /* MODULE */
60
61/* This is the actual algorithm we define */
62static struct i2c_algorithm isa_algorithm = {
63  /* name */            "ISA bus algorithm",
64  /* id */              I2C_ALGO_ISA,
65  /* master_xfer */     NULL,
66  /* smbus_access */    NULL,
67  /* slave_send */      NULL,
68  /* slave_rcv */       NULL,
69  /* algo_control */    NULL,
70  /* functionality */   &isa_func,
71};
72
73/* There can only be one... */
74static struct i2c_adapter isa_adapter = {
75  /* name */            "ISA main adapter",
76  /* id */              I2C_ALGO_ISA | I2C_HW_ISA,
77  /* algorithm */       &isa_algorithm,
78  /* algo_data */       NULL,
79  /* inc_use */         &isa_inc_use,
80  /* dec_use */         &isa_dec_use,
81  /* data */            NULL,
82  /* Other fields not initialized */
83};
84
85/* Used in isa_init/cleanup */
86static int __initdata isa_initialized;
87
88void isa_inc_use (struct i2c_adapter *adapter)
89{
90#ifdef MODULE
91  MOD_INC_USE_COUNT;
92#endif
93}
94
95void isa_dec_use (struct i2c_adapter *adapter)
96{
97#ifdef MODULE
98  MOD_DEC_USE_COUNT;
99#endif
100}
101
102/* We can't do a thing... */
103static u32 isa_func(struct i2c_adapter *adapter)
104{
105  return 0;
106}
107
108int __init i2c_isa_init(void)
109{
110  int res;
111  printk("i2c-isa.o version %s (%s)\n",LM_VERSION,LM_DATE);
112#ifdef DEBUG
113  if (isa_initialized) {
114    printk("i2c-isa.o: Oops, isa_init called a second time!\n");
115    return -EBUSY;
116  }
117#endif
118  isa_initialized = 0;
119  if ((res = i2c_add_adapter(&isa_adapter))) {
120    printk("i2c-isa.o: Adapter registration failed, "
121           "module i2c-isa.o is not inserted\n.");
122    isa_cleanup();
123    return res;
124  }
125  isa_initialized++;
126  printk("i2c-isa.o: ISA bus access for i2c modules initialized.\n");
127  return 0;
128}
129
130int __init isa_cleanup(void)
131{
132  int res;
133  if (isa_initialized >= 1)
134  {
135    if ((res = i2c_del_adapter(&isa_adapter))) {
136      printk("i2c-isa.o: Adapter deregistration failed, module not removed.\n");
137      return res;
138    } else
139      isa_initialized--;
140  }
141  return 0;
142}
143
144EXPORT_NO_SYMBOLS;
145
146#ifdef MODULE
147
148MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
149MODULE_DESCRIPTION("ISA bus access through i2c");
150
151int init_module(void)
152{
153  return i2c_isa_init();
154}
155
156int cleanup_module(void)
157{
158  return isa_cleanup();
159}
160
161#endif /* MODULE */
162
Note: See TracBrowser for help on using the browser.