1 From: Alessandro Zummo <alessandro.zummo@towertech.it>
2 Date: Thu, 16 Oct 2008 05:03:10 +0000 (-0700)
3 Subject: rtc-ds1672 new style driver
4 X-Git-Tag: v2.6.28-rc1~429
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=1716b0fea36c2be628440c1050182a1a1e9caae7
7 rtc-ds1672 new style driver
9 New style conversion and reformatting as per indent --linux-style
11 Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
12 Cc: David Brownell <david-b@pacbell.net>
13 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
14 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
17 --- a/drivers/rtc/rtc-ds1672.c
18 +++ b/drivers/rtc/rtc-ds1672.c
20 * published by the Free Software Foundation.
23 -#include <linux/module.h>
24 #include <linux/i2c.h>
25 #include <linux/rtc.h>
27 -#define DRV_VERSION "0.3"
29 -/* Addresses to scan: none. This chip cannot be detected. */
30 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
32 -/* Insmod parameters */
34 +#define DRV_VERSION "0.4"
38 @@ -29,8 +22,7 @@ I2C_CLIENT_INSMOD;
40 #define DS1672_REG_CONTROL_EOSC 0x80
43 -static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind);
44 +static struct i2c_driver ds1672_driver;
47 * In the routines that deal directly with the ds1672 hardware, we use
48 @@ -44,8 +36,8 @@ static int ds1672_get_datetime(struct i2
51 struct i2c_msg msgs[] = {
52 - { client->addr, 0, 1, &addr }, /* setup read ptr */
53 - { client->addr, I2C_M_RD, 4, buf }, /* read date */
54 + {client->addr, 0, 1, &addr}, /* setup read ptr */
55 + {client->addr, I2C_M_RD, 4, buf}, /* read date */
58 /* read date registers */
59 @@ -80,7 +72,7 @@ static int ds1672_set_mmss(struct i2c_cl
60 buf[2] = (secs & 0x0000FF00) >> 8;
61 buf[3] = (secs & 0x00FF0000) >> 16;
62 buf[4] = (secs & 0xFF000000) >> 24;
63 - buf[5] = 0; /* set control reg to enable counting */
64 + buf[5] = 0; /* set control reg to enable counting */
66 xfer = i2c_master_send(client, buf, 6);
68 @@ -127,8 +119,8 @@ static int ds1672_get_control(struct i2c
69 unsigned char addr = DS1672_REG_CONTROL;
71 struct i2c_msg msgs[] = {
72 - { client->addr, 0, 1, &addr }, /* setup read ptr */
73 - { client->addr, I2C_M_RD, 1, status }, /* read control */
74 + {client->addr, 0, 1, &addr}, /* setup read ptr */
75 + {client->addr, I2C_M_RD, 1, status}, /* read control */
78 /* read control register */
79 @@ -141,7 +133,8 @@ static int ds1672_get_control(struct i2c
82 /* following are the sysfs callback functions */
83 -static ssize_t show_control(struct device *dev, struct device_attribute *attr, char *buf)
84 +static ssize_t show_control(struct device *dev, struct device_attribute *attr,
87 struct i2c_client *client = to_i2c_client(dev);
89 @@ -152,85 +145,46 @@ static ssize_t show_control(struct devic
92 return sprintf(buf, "%s\n", (control & DS1672_REG_CONTROL_EOSC)
93 - ? "disabled" : "enabled");
94 + ? "disabled" : "enabled");
97 static DEVICE_ATTR(control, S_IRUGO, show_control, NULL);
99 static const struct rtc_class_ops ds1672_rtc_ops = {
100 - .read_time = ds1672_rtc_read_time,
101 - .set_time = ds1672_rtc_set_time,
102 - .set_mmss = ds1672_rtc_set_mmss,
103 + .read_time = ds1672_rtc_read_time,
104 + .set_time = ds1672_rtc_set_time,
105 + .set_mmss = ds1672_rtc_set_mmss,
108 -static int ds1672_attach(struct i2c_adapter *adapter)
110 - return i2c_probe(adapter, &addr_data, ds1672_probe);
113 -static int ds1672_detach(struct i2c_client *client)
114 +static int ds1672_remove(struct i2c_client *client)
117 struct rtc_device *rtc = i2c_get_clientdata(client);
121 rtc_device_unregister(rtc);
123 - if ((err = i2c_detach_client(client)))
131 -static struct i2c_driver ds1672_driver = {
135 - .id = I2C_DRIVERID_DS1672,
136 - .attach_adapter = &ds1672_attach,
137 - .detach_client = &ds1672_detach,
140 -static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
141 +static int ds1672_probe(struct i2c_client *client,
142 + const struct i2c_device_id *id)
146 - struct i2c_client *client;
147 struct rtc_device *rtc;
149 - dev_dbg(&adapter->dev, "%s\n", __func__);
151 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
156 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
160 + dev_dbg(&client->dev, "%s\n", __func__);
163 - client->addr = address;
164 - client->driver = &ds1672_driver;
165 - client->adapter = adapter;
167 - strlcpy(client->name, ds1672_driver.driver.name, I2C_NAME_SIZE);
169 - /* Inform the i2c layer */
170 - if ((err = i2c_attach_client(client)))
172 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
175 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
177 rtc = rtc_device_register(ds1672_driver.driver.name, &client->dev,
178 - &ds1672_rtc_ops, THIS_MODULE);
179 + &ds1672_rtc_ops, THIS_MODULE);
182 - err = PTR_ERR(rtc);
186 + return PTR_ERR(rtc);
188 i2c_set_clientdata(client, rtc);
190 @@ -241,7 +195,7 @@ static int ds1672_probe(struct i2c_adapt
192 if (control & DS1672_REG_CONTROL_EOSC)
193 dev_warn(&client->dev, "Oscillator not enabled. "
194 - "Set time to enable.\n");
195 + "Set time to enable.\n");
197 /* Register sysfs hooks */
198 err = device_create_file(&client->dev, &dev_attr_control);
199 @@ -250,19 +204,19 @@ static int ds1672_probe(struct i2c_adapt
205 rtc_device_unregister(rtc);
208 - i2c_detach_client(client);
217 +static struct i2c_driver ds1672_driver = {
219 + .name = "rtc-ds1672",
221 + .probe = &ds1672_probe,
222 + .remove = &ds1672_remove,
225 static int __init ds1672_init(void)
227 return i2c_add_driver(&ds1672_driver);