kernel: add a default for CONFIG_NEW_GPIO
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 294-eeprom_new_notifier.patch
1 diff -uprN linux-2.6.23.orig/drivers/i2c/chips/eeprom.c linux-2.6.23/drivers/i2c/chips/eeprom.c
2 --- linux-2.6.23.orig/drivers/i2c/chips/eeprom.c 2007-10-09 15:31:38.000000000 -0500
3 +++ linux-2.6.23/drivers/i2c/chips/eeprom.c 2007-10-11 00:57:25.000000000 -0500
4 @@ -33,6 +33,8 @@
5 #include <linux/jiffies.h>
6 #include <linux/i2c.h>
7 #include <linux/mutex.h>
8 +#include <linux/notifier.h>
9 +#include <linux/eeprom.h>
10
11 /* Addresses to scan */
12 static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
13 @@ -41,26 +43,7 @@ static unsigned short normal_i2c[] = { 0
14 /* Insmod parameters */
15 I2C_CLIENT_INSMOD_1(eeprom);
16
17 -
18 -/* Size of EEPROM in bytes */
19 -#define EEPROM_SIZE 256
20 -
21 -/* possible types of eeprom devices */
22 -enum eeprom_nature {
23 - UNKNOWN,
24 - VAIO,
25 -};
26 -
27 -/* Each client has this additional data */
28 -struct eeprom_data {
29 - struct i2c_client client;
30 - struct mutex update_lock;
31 - u8 valid; /* bitfield, bit!=0 if slice is valid */
32 - unsigned long last_updated[8]; /* In jiffies, 8 slices */
33 - u8 data[EEPROM_SIZE]; /* Register values */
34 - enum eeprom_nature nature;
35 -};
36 -
37 +ATOMIC_NOTIFIER_HEAD(eeprom_chain);
38
39 static int eeprom_attach_adapter(struct i2c_adapter *adapter);
40 static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind);
41 @@ -191,6 +174,7 @@ static int eeprom_detect(struct i2c_adap
42 data->valid = 0;
43 mutex_init(&data->update_lock);
44 data->nature = UNKNOWN;
45 + data->attr = &eeprom_attr;
46
47 /* Tell the I2C layer a new client has arrived */
48 if ((err = i2c_attach_client(new_client)))
49 @@ -214,6 +198,9 @@ static int eeprom_detect(struct i2c_adap
50 if (err)
51 goto exit_detach;
52
53 + /* call the notifier chain */
54 + atomic_notifier_call_chain(&eeprom_chain, EEPROM_REGISTER, data);
55 +
56 return 0;
57
58 exit_detach:
59 @@ -239,6 +226,41 @@ static int eeprom_detach_client(struct i
60 return 0;
61 }
62
63 +/**
64 + * register_eeprom_notifier - register a 'user' of EEPROM devices.
65 + * @nb: pointer to notifier info structure
66 + *
67 + * Registers a callback function to be called upon detection
68 + * of an EEPROM device. Detection invokes the 'add' callback
69 + * with the kobj of the mutex and a bin_attribute which allows
70 + * read from the EEPROM. The intention is that the notifier
71 + * will be able to read system configuration from the notifier.
72 + *
73 + * Only EEPROMs detected *after* the addition of the notifier
74 + * are notified. I.e. EEPROMs already known to the system
75 + * will not be notified - add the notifier from board level
76 + * code!
77 + */
78 +int register_eeprom_notifier(struct notifier_block *nb)
79 +{
80 + return atomic_notifier_chain_register(&eeprom_chain, nb);
81 +}
82 +
83 +/**
84 + * unregister_eeprom_notifier - unregister a 'user' of EEPROM devices.
85 + * @old: pointer to notifier info structure
86 + *
87 + * Removes a callback function from the list of 'users' to be
88 + * notified upon detection of EEPROM devices.
89 + */
90 +int unregister_eeprom_notifier(struct notifier_block *nb)
91 +{
92 + return atomic_notifier_chain_unregister(&eeprom_chain, nb);
93 +}
94 +
95 +EXPORT_SYMBOL_GPL(register_eeprom_notifier);
96 +EXPORT_SYMBOL_GPL(unregister_eeprom_notifier);
97 +
98 static int __init eeprom_init(void)
99 {
100 return i2c_add_driver(&eeprom_driver);
101 diff -uprN linux-2.6.23.orig/include/linux/eeprom.h linux-2.6.23/include/linux/eeprom.h
102 --- linux-2.6.23.orig/include/linux/eeprom.h 1969-12-31 18:00:00.000000000 -0600
103 +++ linux-2.6.23/include/linux/eeprom.h 2007-10-11 00:57:25.000000000 -0500
104 @@ -0,0 +1,71 @@
105 +#ifndef _LINUX_EEPROM_H
106 +#define _LINUX_EEPROM_H
107 +/*
108 + * EEPROM notifier header
109 + *
110 + * Copyright (C) 2006 John Bowler
111 + */
112 +
113 +/*
114 + * This program is free software; you can redistribute it and/or modify
115 + * it under the terms of the GNU General Public License as published by
116 + * the Free Software Foundation; either version 2 of the License, or
117 + * (at your option) any later version.
118 + *
119 + * This program is distributed in the hope that it will be useful,
120 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
121 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122 + * GNU General Public License for more details.
123 + *
124 + * You should have received a copy of the GNU General Public License
125 + * along with this program; if not, write to the Free Software
126 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
127 + */
128 +
129 +#ifndef __KERNEL__
130 +#error This is a kernel header
131 +#endif
132 +
133 +#include <linux/list.h>
134 +#include <linux/kobject.h>
135 +#include <linux/sysfs.h>
136 +
137 +/* Size of EEPROM in bytes */
138 +#define EEPROM_SIZE 256
139 +
140 +/* possible types of eeprom devices */
141 +enum eeprom_nature {
142 + UNKNOWN,
143 + VAIO,
144 +};
145 +
146 +/* Each client has this additional data */
147 +struct eeprom_data {
148 + struct i2c_client client;
149 + struct mutex update_lock;
150 + u8 valid; /* bitfield, bit!=0 if slice is valid */
151 + unsigned long last_updated[8]; /* In jiffies, 8 slices */
152 + u8 data[EEPROM_SIZE]; /* Register values */
153 + enum eeprom_nature nature;
154 + struct bin_attribute *attr;
155 +};
156 +
157 +/*
158 + * This is very basic.
159 + *
160 + * If an EEPROM is detected on the I2C bus (this only works for
161 + * I2C EEPROMs) the notifier chain is called with
162 + * both the I2C information and the kobject for the sysfs
163 + * device which has been registers. It is then possible to
164 + * read from the device via the bin_attribute::read method
165 + * to extract configuration information.
166 + *
167 + * Register the notifier in the board level code, there is no
168 + * need to unregister it but you can if you want (it will save
169 + * a little bit or kernel memory to do so).
170 + */
171 +
172 +extern int register_eeprom_notifier(struct notifier_block *nb);
173 +extern int unregister_eeprom_notifier(struct notifier_block *nb);
174 +
175 +#endif /* _LINUX_EEPROM_H */
176 diff -uprN linux-2.6.23.orig/include/linux/notifier.h linux-2.6.23/include/linux/notifier.h
177 --- linux-2.6.23.orig/include/linux/notifier.h 2007-10-09 15:31:38.000000000 -0500
178 +++ linux-2.6.23/include/linux/notifier.h 2007-10-11 00:57:25.000000000 -0500
179 @@ -231,5 +231,8 @@ static inline int notifier_to_errno(int
180 #define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */
181 #define PM_POST_SUSPEND 0x0004 /* Suspend finished */
182
183 +/* eeprom notifier chain */
184 +#define EEPROM_REGISTER 0x0001
185 +
186 #endif /* __KERNEL__ */
187 #endif /* _LINUX_NOTIFIER_H */
This page took 0.056367 seconds and 5 git commands to generate.