2 drivers/rtc/rtc-x1205.c | 128 ++++++++++++++++--------------------------------
3 1 file changed, 43 insertions(+), 85 deletions(-)
5 --- a/drivers/rtc/rtc-x1205.c
6 +++ b/drivers/rtc/rtc-x1205.c
9 #include <linux/delay.h>
11 -#define DRV_VERSION "1.0.7"
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.
21 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
23 -/* Insmod parameters */
25 +#define DRV_VERSION "1.0.8"
27 /* offsets into CCR area */
31 #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */
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);
38 -static struct i2c_driver x1205_driver = {
42 - .id = I2C_DRIVERID_X1205,
43 - .attach_adapter = &x1205_attach,
44 - .detach_client = &x1205_detach,
46 +static struct i2c_driver x1205_driver;
49 * In the routines that deal directly with the x1205 hardware, we use
52 static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL);
54 -static int x1205_attach(struct i2c_adapter *adapter)
55 +static int x1205_sysfs_register(struct device *dev)
59 + err = device_create_file(dev, &dev_attr_atrim);
63 + err = device_create_file(dev, &dev_attr_dtrim);
65 + device_remove_file(dev, &dev_attr_atrim);
70 +static void x1205_sysfs_unregister(struct device *dev)
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);
77 -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
79 +static int x1205_probe(struct i2c_client *client)
83 - struct i2c_client *client;
84 struct rtc_device *rtc;
86 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
87 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
89 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
92 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
96 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
99 + if (x1205_validate_client(client) < 0) {
104 - client->addr = address;
105 - client->driver = &x1205_driver;
106 - client->adapter = adapter;
108 - strlcpy(client->name, x1205_driver.driver.name, I2C_NAME_SIZE);
110 - /* Verify the chip is really an X1205 */
112 - if (x1205_validate_client(client) < 0) {
118 - /* Inform the i2c layer */
119 - if ((err = i2c_attach_client(client)))
122 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
124 rtc = rtc_device_register(x1205_driver.driver.name, &client->dev,
125 &x1205_rtc_ops, THIS_MODULE);
128 - err = PTR_ERR(rtc);
132 + return PTR_ERR(rtc);
134 i2c_set_clientdata(client, rtc);
136 @@ -565,45 +533,35 @@
138 dev_err(&client->dev, "couldn't read status\n");
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);
151 - device_remove_file(&client->dev, &dev_attr_atrim);
154 rtc_device_unregister(rtc);
157 - i2c_detach_client(client);
166 -static int x1205_detach(struct i2c_client *client)
167 +static int x1205_remove(struct i2c_client *client)
170 struct rtc_device *rtc = i2c_get_clientdata(client);
173 - rtc_device_unregister(rtc);
175 - if ((err = i2c_detach_client(client)))
180 + rtc_device_unregister(rtc);
181 + x1205_sysfs_unregister(&client->dev);
185 +static struct i2c_driver x1205_driver = {
187 + .name = "rtc-x1205",
189 + .probe = x1205_probe,
190 + .remove = x1205_remove,
193 static int __init x1205_init(void)
195 return i2c_add_driver(&x1205_driver);