switch to the production phy ids on the Cambria
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 011-rtc_pcf8563_new_style.patch
1 ---
2 drivers/rtc/rtc-pcf8563.c | 109 +++++++++++++---------------------------------
3 1 file changed, 32 insertions(+), 77 deletions(-)
4
5 --- a/drivers/rtc/rtc-pcf8563.c
6 +++ b/drivers/rtc/rtc-pcf8563.c
7 @@ -18,17 +18,7 @@
8 #include <linux/bcd.h>
9 #include <linux/rtc.h>
10
11 -#define DRV_VERSION "0.4.2"
12 -
13 -/* Addresses to scan: none
14 - * This chip cannot be reliably autodetected. An empty eeprom
15 - * located at 0x51 will pass the validation routine due to
16 - * the way the registers are implemented.
17 - */
18 -static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
19 -
20 -/* Module parameters */
21 -I2C_CLIENT_INSMOD;
22 +#define DRV_VERSION "0.4.3"
23
24 #define PCF8563_REG_ST1 0x00 /* status */
25 #define PCF8563_REG_ST2 0x01
26 @@ -53,8 +43,10 @@
27 #define PCF8563_SC_LV 0x80 /* low voltage */
28 #define PCF8563_MO_C 0x80 /* century */
29
30 +static struct i2c_driver pcf8563_driver;
31 +
32 struct pcf8563 {
33 - struct i2c_client client;
34 + struct rtc_device *rtc;
35 /*
36 * The meaning of MO_C bit varies by the chip type.
37 * From PCF8563 datasheet: this bit is toggled when the years
38 @@ -72,16 +64,13 @@
39 int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
40 };
41
42 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
43 -static int pcf8563_detach(struct i2c_client *client);
44 -
45 /*
46 * In the routines that deal directly with the pcf8563 hardware, we use
47 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
48 */
49 static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
50 {
51 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
52 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
53 unsigned char buf[13] = { PCF8563_REG_ST1 };
54
55 struct i2c_msg msgs[] = {
56 @@ -138,7 +127,7 @@
57
58 static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
59 {
60 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
61 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
62 int i, err;
63 unsigned char buf[9];
64
65 @@ -257,100 +246,66 @@
66 .set_time = pcf8563_rtc_set_time,
67 };
68
69 -static int pcf8563_attach(struct i2c_adapter *adapter)
70 -{
71 - return i2c_probe(adapter, &addr_data, pcf8563_probe);
72 -}
73 -
74 -static struct i2c_driver pcf8563_driver = {
75 - .driver = {
76 - .name = "pcf8563",
77 - },
78 - .id = I2C_DRIVERID_PCF8563,
79 - .attach_adapter = &pcf8563_attach,
80 - .detach_client = &pcf8563_detach,
81 -};
82 -
83 -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
84 +static int pcf8563_probe(struct i2c_client *client)
85 {
86 struct pcf8563 *pcf8563;
87 - struct i2c_client *client;
88 - struct rtc_device *rtc;
89
90 int err = 0;
91
92 - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
93 + dev_dbg(&client->dev, "%s\n", __FUNCTION__);
94
95 - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
96 - err = -ENODEV;
97 - goto exit;
98 - }
99 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
100 + return -ENODEV;
101
102 - if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
103 - err = -ENOMEM;
104 - goto exit;
105 - }
106 -
107 - client = &pcf8563->client;
108 - client->addr = address;
109 - client->driver = &pcf8563_driver;
110 - client->adapter = adapter;
111 -
112 - strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE);
113 + if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL)))
114 + return -ENOMEM;
115
116 /* Verify the chip is really an PCF8563 */
117 - if (kind < 0) {
118 - if (pcf8563_validate_client(client) < 0) {
119 - err = -ENODEV;
120 - goto exit_kfree;
121 - }
122 - }
123 -
124 - /* Inform the i2c layer */
125 - if ((err = i2c_attach_client(client)))
126 + if (pcf8563_validate_client(client) < 0) {
127 + err = -ENODEV;
128 goto exit_kfree;
129 + }
130
131 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
132
133 - rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
134 + pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev,
135 &pcf8563_rtc_ops, THIS_MODULE);
136
137 - if (IS_ERR(rtc)) {
138 - err = PTR_ERR(rtc);
139 - goto exit_detach;
140 + if (IS_ERR(pcf8563->rtc)) {
141 + err = PTR_ERR(pcf8563->rtc);
142 + goto exit_kfree;
143 }
144
145 - i2c_set_clientdata(client, rtc);
146 + i2c_set_clientdata(client, pcf8563);
147
148 return 0;
149
150 -exit_detach:
151 - i2c_detach_client(client);
152 -
153 exit_kfree:
154 kfree(pcf8563);
155
156 -exit:
157 return err;
158 }
159
160 -static int pcf8563_detach(struct i2c_client *client)
161 +static int pcf8563_remove(struct i2c_client *client)
162 {
163 - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
164 - int err;
165 - struct rtc_device *rtc = i2c_get_clientdata(client);
166 + struct pcf8563 *pcf8563 = i2c_get_clientdata(client);
167
168 - if (rtc)
169 - rtc_device_unregister(rtc);
170 -
171 - if ((err = i2c_detach_client(client)))
172 - return err;
173 + if (pcf8563->rtc)
174 + rtc_device_unregister(pcf8563->rtc);
175
176 kfree(pcf8563);
177
178 return 0;
179 }
180
181 +static struct i2c_driver pcf8563_driver = {
182 + .driver = {
183 + .name = "rtc-pcf8563",
184 + },
185 + .probe = pcf8563_probe,
186 + .remove = pcf8563_remove,
187 +};
188 +
189 static int __init pcf8563_init(void)
190 {
191 return i2c_add_driver(&pcf8563_driver);
This page took 0.055861 seconds and 5 git commands to generate.