diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-parport.c')
-rw-r--r-- | drivers/i2c/busses/i2c-parport.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 66696a40c7b5..8c953707253f 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------ * | 1 | /* ------------------------------------------------------------------------ * |
2 | * i2c-parport.c I2C bus over parallel port * | 2 | * i2c-parport.c I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2007 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | Based on older i2c-philips-par.c driver | 6 | Based on older i2c-philips-par.c driver |
7 | Copyright (C) 1995-2000 Simon G. Vogl | 7 | Copyright (C) 1995-2000 Simon G. Vogl |
@@ -137,19 +137,12 @@ static struct i2c_algo_bit_data parport_algo_data = { | |||
137 | .setscl = parport_setscl, | 137 | .setscl = parport_setscl, |
138 | .getsda = parport_getsda, | 138 | .getsda = parport_getsda, |
139 | .getscl = parport_getscl, | 139 | .getscl = parport_getscl, |
140 | .udelay = 60, | 140 | .udelay = 10, /* ~50 kbps */ |
141 | .timeout = HZ, | 141 | .timeout = HZ, |
142 | }; | 142 | }; |
143 | 143 | ||
144 | /* ----- I2c and parallel port call-back functions and structures --------- */ | 144 | /* ----- I2c and parallel port call-back functions and structures --------- */ |
145 | 145 | ||
146 | static struct i2c_adapter parport_adapter = { | ||
147 | .owner = THIS_MODULE, | ||
148 | .class = I2C_CLASS_HWMON, | ||
149 | .id = I2C_HW_B_LP, | ||
150 | .name = "Parallel port adapter", | ||
151 | }; | ||
152 | |||
153 | static void i2c_parport_attach (struct parport *port) | 146 | static void i2c_parport_attach (struct parport *port) |
154 | { | 147 | { |
155 | struct i2c_par *adapter; | 148 | struct i2c_par *adapter; |
@@ -169,10 +162,17 @@ static void i2c_parport_attach (struct parport *port) | |||
169 | } | 162 | } |
170 | 163 | ||
171 | /* Fill the rest of the structure */ | 164 | /* Fill the rest of the structure */ |
172 | adapter->adapter = parport_adapter; | 165 | adapter->adapter.owner = THIS_MODULE; |
166 | adapter->adapter.class = I2C_CLASS_HWMON; | ||
167 | adapter->adapter.id = I2C_HW_B_LP; | ||
168 | strlcpy(adapter->adapter.name, "Parallel port adapter", | ||
169 | sizeof(adapter->adapter.name)); | ||
173 | adapter->algo_data = parport_algo_data; | 170 | adapter->algo_data = parport_algo_data; |
174 | if (!adapter_parm[type].getscl.val) | 171 | /* Slow down if we can't sense SCL */ |
172 | if (!adapter_parm[type].getscl.val) { | ||
175 | adapter->algo_data.getscl = NULL; | 173 | adapter->algo_data.getscl = NULL; |
174 | adapter->algo_data.udelay = 50; /* ~10 kbps */ | ||
175 | } | ||
176 | adapter->algo_data.data = port; | 176 | adapter->algo_data.data = port; |
177 | adapter->adapter.algo_data = &adapter->algo_data; | 177 | adapter->adapter.algo_data = &adapter->algo_data; |
178 | 178 | ||
@@ -214,11 +214,12 @@ static void i2c_parport_detach (struct parport *port) | |||
214 | for (prev = NULL, adapter = adapter_list; adapter; | 214 | for (prev = NULL, adapter = adapter_list; adapter; |
215 | prev = adapter, adapter = adapter->next) { | 215 | prev = adapter, adapter = adapter->next) { |
216 | if (adapter->pdev->port == port) { | 216 | if (adapter->pdev->port == port) { |
217 | i2c_del_adapter(&adapter->adapter); | ||
218 | |||
217 | /* Un-init if needed (power off...) */ | 219 | /* Un-init if needed (power off...) */ |
218 | if (adapter_parm[type].init.val) | 220 | if (adapter_parm[type].init.val) |
219 | line_set(port, 0, &adapter_parm[type].init); | 221 | line_set(port, 0, &adapter_parm[type].init); |
220 | 222 | ||
221 | i2c_del_adapter(&adapter->adapter); | ||
222 | parport_unregister_device(adapter->pdev); | 223 | parport_unregister_device(adapter->pdev); |
223 | if (prev) | 224 | if (prev) |
224 | prev->next = adapter->next; | 225 | prev->next = adapter->next; |