提交 3af07bd2 编写于 作者: J Jean Delvare 提交者: Jean Delvare

i2c-parport: Fix a minor race on driver unload

When unloading the driver, we really want to unregister the i2c adapter
before we power it off, rather than the other way around.

Also speed up the bus a bit when we can sense SCL. The slaves will
stretch the line as needed.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 4b4686e7
/* ------------------------------------------------------------------------ * /* ------------------------------------------------------------------------ *
* i2c-parport.c I2C bus over parallel port * * i2c-parport.c I2C bus over parallel port *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> Copyright (C) 2003-2007 Jean Delvare <khali@linux-fr.org>
Based on older i2c-philips-par.c driver Based on older i2c-philips-par.c driver
Copyright (C) 1995-2000 Simon G. Vogl Copyright (C) 1995-2000 Simon G. Vogl
...@@ -137,7 +137,7 @@ static struct i2c_algo_bit_data parport_algo_data = { ...@@ -137,7 +137,7 @@ static struct i2c_algo_bit_data parport_algo_data = {
.setscl = parport_setscl, .setscl = parport_setscl,
.getsda = parport_getsda, .getsda = parport_getsda,
.getscl = parport_getscl, .getscl = parport_getscl,
.udelay = 60, .udelay = 10, /* ~50 kbps */
.timeout = HZ, .timeout = HZ,
}; };
...@@ -168,8 +168,11 @@ static void i2c_parport_attach (struct parport *port) ...@@ -168,8 +168,11 @@ static void i2c_parport_attach (struct parport *port)
strlcpy(adapter->adapter.name, "Parallel port adapter", strlcpy(adapter->adapter.name, "Parallel port adapter",
sizeof(adapter->adapter.name)); sizeof(adapter->adapter.name));
adapter->algo_data = parport_algo_data; adapter->algo_data = parport_algo_data;
if (!adapter_parm[type].getscl.val) /* Slow down if we can't sense SCL */
if (!adapter_parm[type].getscl.val) {
adapter->algo_data.getscl = NULL; adapter->algo_data.getscl = NULL;
adapter->algo_data.udelay = 50; /* ~10 kbps */
}
adapter->algo_data.data = port; adapter->algo_data.data = port;
adapter->adapter.algo_data = &adapter->algo_data; adapter->adapter.algo_data = &adapter->algo_data;
...@@ -211,11 +214,12 @@ static void i2c_parport_detach (struct parport *port) ...@@ -211,11 +214,12 @@ static void i2c_parport_detach (struct parport *port)
for (prev = NULL, adapter = adapter_list; adapter; for (prev = NULL, adapter = adapter_list; adapter;
prev = adapter, adapter = adapter->next) { prev = adapter, adapter = adapter->next) {
if (adapter->pdev->port == port) { if (adapter->pdev->port == port) {
i2c_del_adapter(&adapter->adapter);
/* Un-init if needed (power off...) */ /* Un-init if needed (power off...) */
if (adapter_parm[type].init.val) if (adapter_parm[type].init.val)
line_set(port, 0, &adapter_parm[type].init); line_set(port, 0, &adapter_parm[type].init);
i2c_del_adapter(&adapter->adapter);
parport_unregister_device(adapter->pdev); parport_unregister_device(adapter->pdev);
if (prev) if (prev)
prev->next = adapter->next; prev->next = adapter->next;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册