2 drivers/rtc/rtc-x1205.c | 128 ++++++++++++++++--------------------------------
3 1 file changed, 43 insertions(+), 85 deletions(-)
5 Index: linux-2.6.25-rc6-armeb/drivers/rtc/rtc-x1205.c
6 ===================================================================
7 --- linux-2.6.25-rc6-armeb.orig/drivers/rtc/rtc-x1205.c 2008-03-20 10:24:13.000000000 +1030
8 +++ linux-2.6.25-rc6-armeb/drivers/rtc/rtc-x1205.c 2008-03-20 10:24:23.000000000 +1030
10 #include <linux/rtc.h>
11 #include <linux/delay.h>
13 -#define DRV_VERSION "1.0.7"
15 -/* Addresses to scan: none. This chip is located at
16 - * 0x6f and uses a two bytes register addressing.
17 - * Two bytes need to be written to read a single register,
18 - * while most other chips just require one and take the second
19 - * one as the data to be written. To prevent corrupting
20 - * unknown chips, the user must explicitly set the probe parameter.
23 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
25 -/* Insmod parameters */
27 +#define DRV_VERSION "1.0.8"
29 /* offsets into CCR area */
33 #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */
36 -static int x1205_attach(struct i2c_adapter *adapter);
37 -static int x1205_detach(struct i2c_client *client);
38 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind);
40 -static struct i2c_driver x1205_driver = {
44 - .id = I2C_DRIVERID_X1205,
45 - .attach_adapter = &x1205_attach,
46 - .detach_client = &x1205_detach,
48 +static struct i2c_driver x1205_driver;
51 * In the routines that deal directly with the x1205 hardware, we use
54 static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
56 -static int x1205_attach(struct i2c_adapter *adapter)
57 +static int x1205_sysfs_register(struct device *dev)
61 + err = device_create_file(dev, &dev_attr_atrim);
65 + err = device_create_file(dev, &dev_attr_dtrim);
67 + device_remove_file(dev, &dev_attr_atrim);
72 +static void x1205_sysfs_unregister(struct device *dev)
74 - return i2c_probe(adapter, &addr_data, x1205_probe);
75 + device_remove_file(dev, &dev_attr_atrim);
76 + device_remove_file(dev, &dev_attr_dtrim);
79 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
81 +static int x1205_probe(struct i2c_client *client)
85 - struct i2c_client *client;
86 struct rtc_device *rtc;
88 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
89 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
91 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
94 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
98 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
101 + if (x1205_validate_client(client) < 0) {
106 - client->addr = address;
107 - client->driver = &x1205_driver;
108 - client->adapter = adapter;
110 - strlcpy(client->name, x1205_driver.driver.name, I2C_NAME_SIZE);
112 - /* Verify the chip is really an X1205 */
114 - if (x1205_validate_client(client) < 0) {
120 - /* Inform the i2c layer */
121 - if ((err = i2c_attach_client(client)))
124 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
126 rtc = rtc_device_register(x1205_driver.driver.name, &client->dev,
127 &x1205_rtc_ops, THIS_MODULE);
130 - err = PTR_ERR(rtc);
134 + return PTR_ERR(rtc);
136 i2c_set_clientdata(client, rtc);
138 @@ -565,45 +533,35 @@
140 dev_err(&client->dev, "couldn't read status\n");
142 - err = device_create_file(&client->dev, &dev_attr_atrim);
143 - if (err) goto exit_devreg;
144 - err = device_create_file(&client->dev, &dev_attr_dtrim);
145 - if (err) goto exit_atrim;
146 + err = x1205_sysfs_register(&client->dev);
153 - device_remove_file(&client->dev, &dev_attr_atrim);
156 rtc_device_unregister(rtc);
159 - i2c_detach_client(client);
168 -static int x1205_detach(struct i2c_client *client)
169 +static int x1205_remove(struct i2c_client *client)
172 struct rtc_device *rtc = i2c_get_clientdata(client);
175 - rtc_device_unregister(rtc);
177 - if ((err = i2c_detach_client(client)))
182 + rtc_device_unregister(rtc);
183 + x1205_sysfs_unregister(&client->dev);
187 +static struct i2c_driver x1205_driver = {
189 + .name = "rtc-x1205",
191 + .probe = x1205_probe,
192 + .remove = x1205_remove,
195 static int __init x1205_init(void)
197 return i2c_add_driver(&x1205_driver);