Add the PS3 specific utility bl-option, a helper sctipt
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 012-rtc_x1205_new_style.patch
1 ---
2 drivers/rtc/rtc-x1205.c | 128 ++++++++++++++++--------------------------------
3 1 file changed, 43 insertions(+), 85 deletions(-)
4
5 --- a/drivers/rtc/rtc-x1205.c
6 +++ b/drivers/rtc/rtc-x1205.c
7 @@ -22,20 +22,7 @@
8 #include <linux/rtc.h>
9 #include <linux/delay.h>
10
11 -#define DRV_VERSION "1.0.7"
12 -
13 -/* Addresses to scan: none. This chip is located at
14 - * 0x6f and uses a two bytes register addressing.
15 - * Two bytes need to be written to read a single register,
16 - * while most other chips just require one and take the second
17 - * one as the data to be written. To prevent corrupting
18 - * unknown chips, the user must explicitly set the probe parameter.
19 - */
20 -
21 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
22 -
23 -/* Insmod parameters */
24 -I2C_CLIENT_INSMOD;
25 +#define DRV_VERSION "1.0.8"
26
27 /* offsets into CCR area */
28
29 @@ -91,19 +78,7 @@
30
31 #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */
32
33 -/* Prototypes */
34 -static int x1205_attach(struct i2c_adapter *adapter);
35 -static int x1205_detach(struct i2c_client *client);
36 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind);
37 -
38 -static struct i2c_driver x1205_driver = {
39 - .driver = {
40 - .name = "x1205",
41 - },
42 - .id = I2C_DRIVERID_X1205,
43 - .attach_adapter = &x1205_attach,
44 - .detach_client = &x1205_detach,
45 -};
46 +static struct i2c_driver x1205_driver;
47
48 /*
49 * In the routines that deal directly with the x1205 hardware, we use
50 @@ -497,58 +472,51 @@
51 }
52 static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
53
54 -static int x1205_attach(struct i2c_adapter *adapter)
55 +static int x1205_sysfs_register(struct device *dev)
56 +{
57 + int err;
58 +
59 + err = device_create_file(dev, &dev_attr_atrim);
60 + if (err)
61 + return err;
62 +
63 + err = device_create_file(dev, &dev_attr_dtrim);
64 + if (err)
65 + device_remove_file(dev, &dev_attr_atrim);
66 +
67 + return err;
68 +}
69 +
70 +static void x1205_sysfs_unregister(struct device *dev)
71 {
72 - return i2c_probe(adapter, &addr_data, x1205_probe);
73 + device_remove_file(dev, &dev_attr_atrim);
74 + device_remove_file(dev, &dev_attr_dtrim);
75 }
76
77 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
78 +
79 +static int x1205_probe(struct i2c_client *client)
80 {
81 int err = 0;
82 unsigned char sr;
83 - struct i2c_client *client;
84 struct rtc_device *rtc;
85
86 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
87 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
88
89 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
90 - err = -ENODEV;
91 - goto exit;
92 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
93 + return -ENODEV;
94 }
95
96 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
97 - err = -ENOMEM;
98 - goto exit;
99 + if (x1205_validate_client(client) < 0) {
100 + return -ENODEV;
101 }
102
103 - /* I2C client */
104 - client->addr = address;
105 - client->driver = &x1205_driver;
106 - client->adapter = adapter;
107 -
108 - strlcpy(client->name, x1205_driver.driver.name, I2C_NAME_SIZE);
109 -
110 - /* Verify the chip is really an X1205 */
111 - if (kind < 0) {
112 - if (x1205_validate_client(client) < 0) {
113 - err = -ENODEV;
114 - goto exit_kfree;
115 - }
116 - }
117 -
118 - /* Inform the i2c layer */
119 - if ((err = i2c_attach_client(client)))
120 - goto exit_kfree;
121 -
122 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
123
124 rtc = rtc_device_register(x1205_driver.driver.name, &client->dev,
125 &x1205_rtc_ops, THIS_MODULE);
126
127 - if (IS_ERR(rtc)) {
128 - err = PTR_ERR(rtc);
129 - goto exit_detach;
130 - }
131 + if (IS_ERR(rtc))
132 + return PTR_ERR(rtc);
133
134 i2c_set_clientdata(client, rtc);
135
136 @@ -565,45 +533,35 @@
137 else
138 dev_err(&client->dev, "couldn't read status\n");
139
140 - err = device_create_file(&client->dev, &dev_attr_atrim);
141 - if (err) goto exit_devreg;
142 - err = device_create_file(&client->dev, &dev_attr_dtrim);
143 - if (err) goto exit_atrim;
144 + err = x1205_sysfs_register(&client->dev);
145 + if (err)
146 + goto exit_devreg;
147
148 return 0;
149
150 -exit_atrim:
151 - device_remove_file(&client->dev, &dev_attr_atrim);
152 -
153 exit_devreg:
154 rtc_device_unregister(rtc);
155
156 -exit_detach:
157 - i2c_detach_client(client);
158 -
159 -exit_kfree:
160 - kfree(client);
161 -
162 -exit:
163 return err;
164 }
165
166 -static int x1205_detach(struct i2c_client *client)
167 +static int x1205_remove(struct i2c_client *client)
168 {
169 - int err;
170 struct rtc_device *rtc = i2c_get_clientdata(client);
171
172 - if (rtc)
173 - rtc_device_unregister(rtc);
174 -
175 - if ((err = i2c_detach_client(client)))
176 - return err;
177 -
178 - kfree(client);
179 -
180 + rtc_device_unregister(rtc);
181 + x1205_sysfs_unregister(&client->dev);
182 return 0;
183 }
184
185 +static struct i2c_driver x1205_driver = {
186 + .driver = {
187 + .name = "rtc-x1205",
188 + },
189 + .probe = x1205_probe,
190 + .remove = x1205_remove,
191 +};
192 +
193 static int __init x1205_init(void)
194 {
195 return i2c_add_driver(&x1205_driver);
This page took 0.057189 seconds and 5 git commands to generate.