Skip to content

Commit 07da037

Browse files
Jean DelvareJean Delvare
authored andcommitted
i2c-parport: Various cleanups
* Fix white space. * Rename labels to something meaningful. * Prefix defines with PORT_ to avoid collision with macros from <linux/parport.h>. * Add const markers where possible. Signed-off-by: Jean Delvare <khali@linux-fr.org>
1 parent 8eacfce commit 07da037

3 files changed

Lines changed: 55 additions & 59 deletions

File tree

‎drivers/i2c/busses/i2c-parport-light.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* i2c-parport-light.c I2C bus over parallel port *
33
* ------------------------------------------------------------------------ *
44
Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
5-
5+
66
Based on older i2c-velleman.c driver
77
Copyright (C) 1995-2000 Simon G. Vogl
88
With some changes from:
99
Frodo Looijaard <frodol@dds.nl>
1010
Kyösti Mälkki <kmalkki@cc.hut.fi>
11-
11+
1212
This program is free software; you can redistribute it and/or modify
1313
it under the terms of the GNU General Public License as published by
1414
the Free Software Foundation; either version 2 of the License, or
@@ -114,7 +114,7 @@ static struct i2c_algo_bit_data parport_algo_data = {
114114
.getscl = parport_getscl,
115115
.udelay = 50,
116116
.timeout = HZ,
117-
};
117+
};
118118

119119
/* ----- Driver registration ---------------------------------------------- */
120120

@@ -132,7 +132,7 @@ static struct i2c_smbus_alert_setup alert_data = {
132132
static struct i2c_client *ara;
133133
static struct lineop parport_ctrl_irq = {
134134
.val = (1 << 4),
135-
.port = CTRL,
135+
.port = PORT_CTRL,
136136
};
137137

138138
static int __devinit i2c_parport_probe(struct platform_device *pdev)
@@ -245,7 +245,7 @@ static int __init i2c_parport_init(void)
245245
if (irq != 0)
246246
pr_info(DRVNAME ": using irq %d\n", irq);
247247

248-
if (!adapter_parm[type].getscl.val)
248+
if (!adapter_parm[type].getscl.val)
249249
parport_algo_data.getscl = NULL;
250250

251251
/* Sets global pdev as a side effect */

‎drivers/i2c/busses/i2c-parport.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* i2c-parport.c I2C bus over parallel port *
33
* ------------------------------------------------------------------------ *
44
Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org>
5-
5+
66
Based on older i2c-philips-par.c driver
77
Copyright (C) 1995-2000 Simon G. Vogl
88
With some changes from:
99
Frodo Looijaard <frodol@dds.nl>
1010
Kyösti Mälkki <kmalkki@cc.hut.fi>
11-
11+
1212
This program is free software; you can redistribute it and/or modify
1313
it under the terms of the GNU General Public License as published by
1414
the Free Software Foundation; either version 2 of the License, or
@@ -78,13 +78,13 @@ static unsigned char port_read_control(struct parport *p)
7878
return parport_read_control(p);
7979
}
8080

81-
static void (*port_write[])(struct parport *, unsigned char) = {
81+
static void (* const port_write[])(struct parport *, unsigned char) = {
8282
port_write_data,
8383
NULL,
8484
port_write_control,
8585
};
8686

87-
static unsigned char (*port_read[])(struct parport *) = {
87+
static unsigned char (* const port_read[])(struct parport *) = {
8888
port_read_data,
8989
port_read_status,
9090
port_read_control,
@@ -147,7 +147,7 @@ static const struct i2c_algo_bit_data parport_algo_data = {
147147
.getscl = parport_getscl,
148148
.udelay = 10, /* ~50 kbps */
149149
.timeout = HZ,
150-
};
150+
};
151151

152152
/* ----- I2c and parallel port call-back functions and structures --------- */
153153

@@ -164,10 +164,10 @@ void i2c_parport_irq(void *data)
164164
"SMBus alert received but no ARA client!\n");
165165
}
166166

167-
static void i2c_parport_attach (struct parport *port)
167+
static void i2c_parport_attach(struct parport *port)
168168
{
169169
struct i2c_par *adapter;
170-
170+
171171
adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
172172
if (adapter == NULL) {
173173
printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
@@ -180,7 +180,7 @@ static void i2c_parport_attach (struct parport *port)
180180
NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter);
181181
if (!adapter->pdev) {
182182
printk(KERN_ERR "i2c-parport: Unable to register with parport\n");
183-
goto ERROR0;
183+
goto err_free;
184184
}
185185

186186
/* Fill the rest of the structure */
@@ -200,7 +200,7 @@ static void i2c_parport_attach (struct parport *port)
200200

201201
if (parport_claim_or_block(adapter->pdev) < 0) {
202202
printk(KERN_ERR "i2c-parport: Could not claim parallel port\n");
203-
goto ERROR1;
203+
goto err_unregister;
204204
}
205205

206206
/* Reset hardware to a sane state (SCL and SDA high) */
@@ -215,7 +215,7 @@ static void i2c_parport_attach (struct parport *port)
215215

216216
if (i2c_bit_add_bus(&adapter->adapter) < 0) {
217217
printk(KERN_ERR "i2c-parport: Unable to register with I2C\n");
218-
goto ERROR1;
218+
goto err_unregister;
219219
}
220220

221221
/* Setup SMBus alert if supported */
@@ -234,16 +234,16 @@ static void i2c_parport_attach (struct parport *port)
234234
mutex_lock(&adapter_list_lock);
235235
list_add_tail(&adapter->node, &adapter_list);
236236
mutex_unlock(&adapter_list_lock);
237-
return;
237+
return;
238238

239-
ERROR1:
239+
err_unregister:
240240
parport_release(adapter->pdev);
241241
parport_unregister_device(adapter->pdev);
242-
ERROR0:
242+
err_free:
243243
kfree(adapter);
244244
}
245245

246-
static void i2c_parport_detach (struct parport *port)
246+
static void i2c_parport_detach(struct parport *port)
247247
{
248248
struct i2c_par *adapter, *_n;
249249

@@ -260,7 +260,7 @@ static void i2c_parport_detach (struct parport *port)
260260
/* Un-init if needed (power off...) */
261261
if (adapter_parm[type].init.val)
262262
line_set(port, 0, &adapter_parm[type].init);
263-
263+
264264
parport_release(adapter->pdev);
265265
parport_unregister_device(adapter->pdev);
266266
list_del(&adapter->node);

‎drivers/i2c/busses/i2c-parport.h‎

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* i2c-parport.h I2C bus over parallel port *
33
* ------------------------------------------------------------------------ *
44
Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
5-
5+
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
88
the Free Software Foundation; either version 2 of the License, or
@@ -18,13 +18,9 @@
1818
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1919
* ------------------------------------------------------------------------ */
2020

21-
#ifdef DATA
22-
#undef DATA
23-
#endif
24-
25-
#define DATA 0
26-
#define STAT 1
27-
#define CTRL 2
21+
#define PORT_DATA 0
22+
#define PORT_STAT 1
23+
#define PORT_CTRL 2
2824

2925
struct lineop {
3026
u8 val;
@@ -41,61 +37,61 @@ struct adapter_parm {
4137
unsigned int smbus_alert:1;
4238
};
4339

44-
static struct adapter_parm adapter_parm[] = {
40+
static const struct adapter_parm adapter_parm[] = {
4541
/* type 0: Philips adapter */
4642
{
47-
.setsda = { 0x80, DATA, 1 },
48-
.setscl = { 0x08, CTRL, 0 },
49-
.getsda = { 0x80, STAT, 0 },
50-
.getscl = { 0x08, STAT, 0 },
43+
.setsda = { 0x80, PORT_DATA, 1 },
44+
.setscl = { 0x08, PORT_CTRL, 0 },
45+
.getsda = { 0x80, PORT_STAT, 0 },
46+
.getscl = { 0x08, PORT_STAT, 0 },
5147
},
5248
/* type 1: home brew teletext adapter */
5349
{
54-
.setsda = { 0x02, DATA, 0 },
55-
.setscl = { 0x01, DATA, 0 },
56-
.getsda = { 0x80, STAT, 1 },
50+
.setsda = { 0x02, PORT_DATA, 0 },
51+
.setscl = { 0x01, PORT_DATA, 0 },
52+
.getsda = { 0x80, PORT_STAT, 1 },
5753
},
5854
/* type 2: Velleman K8000 adapter */
5955
{
60-
.setsda = { 0x02, CTRL, 1 },
61-
.setscl = { 0x08, CTRL, 1 },
62-
.getsda = { 0x10, STAT, 0 },
56+
.setsda = { 0x02, PORT_CTRL, 1 },
57+
.setscl = { 0x08, PORT_CTRL, 1 },
58+
.getsda = { 0x10, PORT_STAT, 0 },
6359
},
6460
/* type 3: ELV adapter */
6561
{
66-
.setsda = { 0x02, DATA, 1 },
67-
.setscl = { 0x01, DATA, 1 },
68-
.getsda = { 0x40, STAT, 1 },
69-
.getscl = { 0x08, STAT, 1 },
62+
.setsda = { 0x02, PORT_DATA, 1 },
63+
.setscl = { 0x01, PORT_DATA, 1 },
64+
.getsda = { 0x40, PORT_STAT, 1 },
65+
.getscl = { 0x08, PORT_STAT, 1 },
7066
},
7167
/* type 4: ADM1032 evaluation board */
7268
{
73-
.setsda = { 0x02, DATA, 1 },
74-
.setscl = { 0x01, DATA, 1 },
75-
.getsda = { 0x10, STAT, 1 },
76-
.init = { 0xf0, DATA, 0 },
69+
.setsda = { 0x02, PORT_DATA, 1 },
70+
.setscl = { 0x01, PORT_DATA, 1 },
71+
.getsda = { 0x10, PORT_STAT, 1 },
72+
.init = { 0xf0, PORT_DATA, 0 },
7773
.smbus_alert = 1,
7874
},
7975
/* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */
8076
{
81-
.setsda = { 0x02, DATA, 1 },
82-
.setscl = { 0x01, DATA, 1 },
83-
.getsda = { 0x10, STAT, 1 },
77+
.setsda = { 0x02, PORT_DATA, 1 },
78+
.setscl = { 0x01, PORT_DATA, 1 },
79+
.getsda = { 0x10, PORT_STAT, 1 },
8480
},
8581
/* type 6: Barco LPT->DVI (K5800236) adapter */
8682
{
87-
.setsda = { 0x02, DATA, 1 },
88-
.setscl = { 0x01, DATA, 1 },
89-
.getsda = { 0x20, STAT, 0 },
90-
.getscl = { 0x40, STAT, 0 },
91-
.init = { 0xfc, DATA, 0 },
83+
.setsda = { 0x02, PORT_DATA, 1 },
84+
.setscl = { 0x01, PORT_DATA, 1 },
85+
.getsda = { 0x20, PORT_STAT, 0 },
86+
.getscl = { 0x40, PORT_STAT, 0 },
87+
.init = { 0xfc, PORT_DATA, 0 },
9288
},
9389
/* type 7: One For All JP1 parallel port adapter */
9490
{
95-
.setsda = { 0x01, DATA, 0 },
96-
.setscl = { 0x02, DATA, 0 },
97-
.getsda = { 0x80, STAT, 1 },
98-
.init = { 0x04, DATA, 1 },
91+
.setsda = { 0x01, PORT_DATA, 0 },
92+
.setscl = { 0x02, PORT_DATA, 0 },
93+
.getsda = { 0x80, PORT_STAT, 1 },
94+
.init = { 0x04, PORT_DATA, 1 },
9995
},
10096
};
10197

0 commit comments

Comments
 (0)