diff options
author | Stig Telfer <stig@lizardlogic.co.uk> | 2005-10-07 18:23:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 17:02:10 -0400 |
commit | fe3d6a99782d5345b1927e872d77d1778668094b (patch) | |
tree | d275d3abee80c0ec19193350ede05308697b51fe | |
parent | 3634ff6a32e90d9db0ec19297e80059143c1aa7f (diff) |
[PATCH] i2c: Big i2c-elektor cleanup
Cleanups to the i2c-elektor driver:
* Set the i2c_adapter name field to "i2c-elektor" and use this string
in all resource requests and printks.
* Change space-padding for tab indentation, kill trailing white space,
remove space before comma.
* Use dev_info, pr_info and pr_debug instead of printk.
* Lines chopped to 80 columns.
Signed-off-by: Stig Telfer <stig@lizardlogic.co.uk>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/i2c/busses/i2c-elektor.c | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 75b4b442a636..59f8308c2356 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -22,7 +22,7 @@ | |||
22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
23 | Frodo Looijaard <frodol@dds.nl> */ | 23 | Frodo Looijaard <frodol@dds.nl> */ |
24 | 24 | ||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -53,7 +53,7 @@ static int clock = 0x1c; | |||
53 | static int own = 0x55; | 53 | static int own = 0x55; |
54 | static int mmapped; | 54 | static int mmapped; |
55 | 55 | ||
56 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - | 56 | /* vdovikin: removed static struct i2c_pcf_isa gpi; code - |
57 | this module in real supports only one device, due to missing arguments | 57 | this module in real supports only one device, due to missing arguments |
58 | in some functions, called from the algo-pcf module. Sometimes it's | 58 | in some functions, called from the algo-pcf module. Sometimes it's |
59 | need to be rewriten - but for now just remove this for simpler reading */ | 59 | need to be rewriten - but for now just remove this for simpler reading */ |
@@ -62,6 +62,8 @@ static wait_queue_head_t pcf_wait; | |||
62 | static int pcf_pending; | 62 | static int pcf_pending; |
63 | static spinlock_t lock; | 63 | static spinlock_t lock; |
64 | 64 | ||
65 | static struct i2c_adapter pcf_isa_ops; | ||
66 | |||
65 | /* ----- local functions ---------------------------------------------- */ | 67 | /* ----- local functions ---------------------------------------------- */ |
66 | 68 | ||
67 | static void pcf_isa_setbyte(void *data, int ctl, int val) | 69 | static void pcf_isa_setbyte(void *data, int ctl, int val) |
@@ -73,7 +75,7 @@ static void pcf_isa_setbyte(void *data, int ctl, int val) | |||
73 | val |= I2C_PCF_ENI; | 75 | val |= I2C_PCF_ENI; |
74 | } | 76 | } |
75 | 77 | ||
76 | pr_debug("i2c-elektor: Write %p 0x%02X\n", address, val); | 78 | pr_debug("%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val); |
77 | iowrite8(val, address); | 79 | iowrite8(val, address); |
78 | #ifdef __alpha__ | 80 | #ifdef __alpha__ |
79 | /* API UP2000 needs some hardware fudging to make the write stick */ | 81 | /* API UP2000 needs some hardware fudging to make the write stick */ |
@@ -86,7 +88,7 @@ static int pcf_isa_getbyte(void *data, int ctl) | |||
86 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; | 88 | u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem; |
87 | int val = ioread8(address); | 89 | int val = ioread8(address); |
88 | 90 | ||
89 | pr_debug("i2c-elektor: Read %p 0x%02X\n", address, val); | 91 | pr_debug("%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val); |
90 | return (val); | 92 | return (val); |
91 | } | 93 | } |
92 | 94 | ||
@@ -142,39 +144,40 @@ static int pcf_isa_init(void) | |||
142 | { | 144 | { |
143 | spin_lock_init(&lock); | 145 | spin_lock_init(&lock); |
144 | if (!mmapped) { | 146 | if (!mmapped) { |
145 | if (!request_region(base, 2, "i2c (isa bus adapter)")) { | 147 | if (!request_region(base, 2, pcf_isa_ops.name)) { |
146 | printk(KERN_ERR | 148 | printk(KERN_ERR "%s: requested I/O region (%#x:2) is " |
147 | "i2c-elektor: requested I/O region (0x%X:2) " | 149 | "in use\n", pcf_isa_ops.name, base); |
148 | "is in use.\n", base); | ||
149 | return -ENODEV; | 150 | return -ENODEV; |
150 | } | 151 | } |
151 | base_iomem = ioport_map(base, 2); | 152 | base_iomem = ioport_map(base, 2); |
152 | if (!base_iomem) { | 153 | if (!base_iomem) { |
153 | printk(KERN_ERR "i2c-elektor: remap of I/O region " | 154 | printk(KERN_ERR "%s: remap of I/O region %#x failed\n", |
154 | "%#x failed\n", base); | 155 | pcf_isa_ops.name, base); |
155 | release_region(base, 2); | 156 | release_region(base, 2); |
156 | return -ENODEV; | 157 | return -ENODEV; |
157 | } | 158 | } |
158 | } else { | 159 | } else { |
159 | if (!request_mem_region(base, 2, "i2c-elektor")) { | 160 | if (!request_mem_region(base, 2, pcf_isa_ops.name)) { |
160 | printk(KERN_ERR "i2c-elektor: requested memory region " | 161 | printk(KERN_ERR "%s: requested memory region (%#x:2) " |
161 | "(%#x:2) is in use\n", base); | 162 | "is in use\n", pcf_isa_ops.name, base); |
162 | return -ENODEV; | 163 | return -ENODEV; |
163 | } | 164 | } |
164 | base_iomem = ioremap(base, 2); | 165 | base_iomem = ioremap(base, 2); |
165 | if (base_iomem == NULL) { | 166 | if (base_iomem == NULL) { |
166 | printk(KERN_ERR "i2c-elektor: remap of memory region " | 167 | printk(KERN_ERR "%s: remap of memory region %#x " |
167 | "%#x failed\n", base); | 168 | "failed\n", pcf_isa_ops.name, base); |
168 | release_mem_region(base, 2); | 169 | release_mem_region(base, 2); |
169 | return -ENODEV; | 170 | return -ENODEV; |
170 | } | 171 | } |
171 | } | 172 | } |
172 | pr_debug("i2c-elektor: registers %#x remapped to %p\n", base, | 173 | pr_debug("%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base, |
173 | base_iomem); | 174 | base_iomem); |
174 | 175 | ||
175 | if (irq > 0) { | 176 | if (irq > 0) { |
176 | if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", NULL) < 0) { | 177 | if (request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name, |
177 | printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq); | 178 | NULL) < 0) { |
179 | printk(KERN_ERR "%s: Request irq%d failed\n", | ||
180 | pcf_isa_ops.name, irq); | ||
178 | irq = 0; | 181 | irq = 0; |
179 | } else | 182 | } else |
180 | enable_irq(irq); | 183 | enable_irq(irq); |
@@ -202,45 +205,49 @@ static struct i2c_adapter pcf_isa_ops = { | |||
202 | .class = I2C_CLASS_HWMON, | 205 | .class = I2C_CLASS_HWMON, |
203 | .id = I2C_HW_P_ELEK, | 206 | .id = I2C_HW_P_ELEK, |
204 | .algo_data = &pcf_isa_data, | 207 | .algo_data = &pcf_isa_data, |
205 | .name = "PCF8584 ISA adapter", | 208 | .name = "i2c-elektor", |
206 | }; | 209 | }; |
207 | 210 | ||
208 | static int __init i2c_pcfisa_init(void) | 211 | static int __init i2c_pcfisa_init(void) |
209 | { | 212 | { |
210 | #ifdef __alpha__ | 213 | #ifdef __alpha__ |
211 | /* check to see we have memory mapped PCF8584 connected to the | 214 | /* check to see we have memory mapped PCF8584 connected to the |
212 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ | 215 | Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ |
213 | if (base == 0) { | 216 | if (base == 0) { |
214 | struct pci_dev *cy693_dev; | 217 | struct pci_dev *cy693_dev; |
215 | 218 | ||
216 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, | 219 | cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, |
217 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); | 220 | PCI_DEVICE_ID_CONTAQ_82C693, NULL); |
218 | if (cy693_dev) { | 221 | if (cy693_dev) { |
219 | unsigned char config; | 222 | unsigned char config; |
220 | /* yeap, we've found cypress, let's check config */ | 223 | /* yeap, we've found cypress, let's check config */ |
221 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { | 224 | if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { |
222 | 225 | ||
223 | pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config); | 226 | pr_debug("%s: found cy82c693, config " |
227 | "register 0x47 = 0x%02x\n", | ||
228 | pcf_isa_ops.name, config); | ||
224 | 229 | ||
225 | /* UP2000 board has this register set to 0xe1, | 230 | /* UP2000 board has this register set to 0xe1, |
226 | but the most significant bit as seems can be | 231 | but the most significant bit as seems can be |
227 | reset during the proper initialisation | 232 | reset during the proper initialisation |
228 | sequence if guys from API decides to do that | 233 | sequence if guys from API decides to do that |
229 | (so, we can even enable Tsunami Pchip | 234 | (so, we can even enable Tsunami Pchip |
230 | window for the upper 1 Gb) */ | 235 | window for the upper 1 Gb) */ |
231 | 236 | ||
232 | /* so just check for ROMCS at 0xe0000, | 237 | /* so just check for ROMCS at 0xe0000, |
233 | ROMCS enabled for writes | 238 | ROMCS enabled for writes |
234 | and external XD Bus buffer in use. */ | 239 | and external XD Bus buffer in use. */ |
235 | if ((config & 0x7f) == 0x61) { | 240 | if ((config & 0x7f) == 0x61) { |
236 | /* seems to be UP2000 like board */ | 241 | /* seems to be UP2000 like board */ |
237 | base = 0xe0000; | 242 | base = 0xe0000; |
238 | mmapped = 1; | 243 | mmapped = 1; |
239 | /* UP2000 drives ISA with | 244 | /* UP2000 drives ISA with |
240 | 8.25 MHz (PCI/4) clock | 245 | 8.25 MHz (PCI/4) clock |
241 | (this can be read from cypress) */ | 246 | (this can be read from cypress) */ |
242 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; | 247 | clock = I2C_PCF_CLK | I2C_PCF_TRNS90; |
243 | printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n"); | 248 | pr_info("%s: found API UP2000 like " |
249 | "board, will probe PCF8584 " | ||
250 | "later\n", pcf_isa_ops.name); | ||
244 | } | 251 | } |
245 | } | 252 | } |
246 | pci_dev_put(cy693_dev); | 253 | pci_dev_put(cy693_dev); |
@@ -250,12 +257,11 @@ static int __init i2c_pcfisa_init(void) | |||
250 | 257 | ||
251 | /* sanity checks for mmapped I/O */ | 258 | /* sanity checks for mmapped I/O */ |
252 | if (mmapped && base < 0xc8000) { | 259 | if (mmapped && base < 0xc8000) { |
253 | printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); | 260 | printk(KERN_ERR "%s: incorrect base address (%#x) specified " |
261 | "for mmapped I/O\n", pcf_isa_ops.name, base); | ||
254 | return -ENODEV; | 262 | return -ENODEV; |
255 | } | 263 | } |
256 | 264 | ||
257 | printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n"); | ||
258 | |||
259 | if (base == 0) { | 265 | if (base == 0) { |
260 | base = DEFAULT_BASE; | 266 | base = DEFAULT_BASE; |
261 | } | 267 | } |
@@ -265,8 +271,8 @@ static int __init i2c_pcfisa_init(void) | |||
265 | return -ENODEV; | 271 | return -ENODEV; |
266 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) | 272 | if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) |
267 | goto fail; | 273 | goto fail; |
268 | 274 | ||
269 | printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base); | 275 | dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base); |
270 | 276 | ||
271 | return 0; | 277 | return 0; |
272 | 278 | ||
@@ -278,7 +284,7 @@ static int __init i2c_pcfisa_init(void) | |||
278 | 284 | ||
279 | if (!mmapped) { | 285 | if (!mmapped) { |
280 | ioport_unmap(base_iomem); | 286 | ioport_unmap(base_iomem); |
281 | release_region(base , 2); | 287 | release_region(base, 2); |
282 | } else { | 288 | } else { |
283 | iounmap(base_iomem); | 289 | iounmap(base_iomem); |
284 | release_mem_region(base, 2); | 290 | release_mem_region(base, 2); |
@@ -297,7 +303,7 @@ static void i2c_pcfisa_exit(void) | |||
297 | 303 | ||
298 | if (!mmapped) { | 304 | if (!mmapped) { |
299 | ioport_unmap(base_iomem); | 305 | ioport_unmap(base_iomem); |
300 | release_region(base , 2); | 306 | release_region(base, 2); |
301 | } else { | 307 | } else { |
302 | iounmap(base_iomem); | 308 | iounmap(base_iomem); |
303 | release_mem_region(base, 2); | 309 | release_mem_region(base, 2); |