diff options
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r-- | drivers/i2c/busses/i2c-ali1563.c | 8 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-imx.c | 26 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pca-isa.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pca-platform.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-piix4.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-tiny-usb.c | 12 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-viapro.c | 4 |
7 files changed, 32 insertions, 30 deletions
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index f70f46582c6..4687af40dd5 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -87,9 +87,9 @@ static int ali1563_transaction(struct i2c_adapter * a, int size) | |||
87 | outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); | 87 | outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); |
88 | 88 | ||
89 | timeout = ALI1563_MAX_TIMEOUT; | 89 | timeout = ALI1563_MAX_TIMEOUT; |
90 | do | 90 | do { |
91 | msleep(1); | 91 | msleep(1); |
92 | while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout); | 92 | } while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout); |
93 | 93 | ||
94 | dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, " | 94 | dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, " |
95 | "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", | 95 | "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", |
@@ -157,9 +157,9 @@ static int ali1563_block_start(struct i2c_adapter * a) | |||
157 | outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); | 157 | outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); |
158 | 158 | ||
159 | timeout = ALI1563_MAX_TIMEOUT; | 159 | timeout = ALI1563_MAX_TIMEOUT; |
160 | do | 160 | do { |
161 | msleep(1); | 161 | msleep(1); |
162 | while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout); | 162 | } while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout); |
163 | 163 | ||
164 | dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, " | 164 | dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, " |
165 | "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", | 165 | "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index e3654d683e1..75bf820e7cc 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -226,7 +226,6 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) | |||
226 | temp = readb(i2c_imx->base + IMX_I2C_I2CR); | 226 | temp = readb(i2c_imx->base + IMX_I2C_I2CR); |
227 | temp &= ~(I2CR_MSTA | I2CR_MTX); | 227 | temp &= ~(I2CR_MSTA | I2CR_MTX); |
228 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); | 228 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); |
229 | i2c_imx->stopped = 1; | ||
230 | } | 229 | } |
231 | if (cpu_is_mx1()) { | 230 | if (cpu_is_mx1()) { |
232 | /* | 231 | /* |
@@ -236,8 +235,10 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) | |||
236 | udelay(i2c_imx->disable_delay); | 235 | udelay(i2c_imx->disable_delay); |
237 | } | 236 | } |
238 | 237 | ||
239 | if (!i2c_imx->stopped) | 238 | if (!i2c_imx->stopped) { |
240 | i2c_imx_bus_busy(i2c_imx, 0); | 239 | i2c_imx_bus_busy(i2c_imx, 0); |
240 | i2c_imx->stopped = 1; | ||
241 | } | ||
241 | 242 | ||
242 | /* Disable I2C controller */ | 243 | /* Disable I2C controller */ |
243 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); | 244 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); |
@@ -496,22 +497,23 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
496 | } | 497 | } |
497 | 498 | ||
498 | res_size = resource_size(res); | 499 | res_size = resource_size(res); |
500 | |||
501 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
502 | ret = -EBUSY; | ||
503 | goto fail0; | ||
504 | } | ||
505 | |||
499 | base = ioremap(res->start, res_size); | 506 | base = ioremap(res->start, res_size); |
500 | if (!base) { | 507 | if (!base) { |
501 | dev_err(&pdev->dev, "ioremap failed\n"); | 508 | dev_err(&pdev->dev, "ioremap failed\n"); |
502 | ret = -EIO; | 509 | ret = -EIO; |
503 | goto fail0; | 510 | goto fail1; |
504 | } | 511 | } |
505 | 512 | ||
506 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); | 513 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); |
507 | if (!i2c_imx) { | 514 | if (!i2c_imx) { |
508 | dev_err(&pdev->dev, "can't allocate interface\n"); | 515 | dev_err(&pdev->dev, "can't allocate interface\n"); |
509 | ret = -ENOMEM; | 516 | ret = -ENOMEM; |
510 | goto fail1; | ||
511 | } | ||
512 | |||
513 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
514 | ret = -EBUSY; | ||
515 | goto fail2; | 517 | goto fail2; |
516 | } | 518 | } |
517 | 519 | ||
@@ -582,11 +584,11 @@ fail5: | |||
582 | fail4: | 584 | fail4: |
583 | clk_put(i2c_imx->clk); | 585 | clk_put(i2c_imx->clk); |
584 | fail3: | 586 | fail3: |
585 | release_mem_region(i2c_imx->res->start, resource_size(res)); | ||
586 | fail2: | ||
587 | kfree(i2c_imx); | 587 | kfree(i2c_imx); |
588 | fail1: | 588 | fail2: |
589 | iounmap(base); | 589 | iounmap(base); |
590 | fail1: | ||
591 | release_mem_region(res->start, resource_size(res)); | ||
590 | fail0: | 592 | fail0: |
591 | if (pdata && pdata->exit) | 593 | if (pdata && pdata->exit) |
592 | pdata->exit(&pdev->dev); | 594 | pdata->exit(&pdev->dev); |
@@ -618,8 +620,8 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) | |||
618 | 620 | ||
619 | clk_put(i2c_imx->clk); | 621 | clk_put(i2c_imx->clk); |
620 | 622 | ||
621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
622 | iounmap(i2c_imx->base); | 623 | iounmap(i2c_imx->base); |
624 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
623 | kfree(i2c_imx); | 625 | kfree(i2c_imx); |
624 | return 0; | 626 | return 0; |
625 | } | 627 | } |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index 0ed68e2ccd2..f7346a9bd95 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -75,7 +75,7 @@ static int pca_isa_waitforcompletion(void *pd) | |||
75 | unsigned long timeout; | 75 | unsigned long timeout; |
76 | 76 | ||
77 | if (irq > -1) { | 77 | if (irq > -1) { |
78 | ret = wait_event_interruptible_timeout(pca_wait, | 78 | ret = wait_event_timeout(pca_wait, |
79 | pca_isa_readbyte(pd, I2C_PCA_CON) | 79 | pca_isa_readbyte(pd, I2C_PCA_CON) |
80 | & I2C_PCA_CON_SI, pca_isa_ops.timeout); | 80 | & I2C_PCA_CON_SI, pca_isa_ops.timeout); |
81 | } else { | 81 | } else { |
@@ -96,7 +96,7 @@ static void pca_isa_resetchip(void *pd) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | static irqreturn_t pca_handler(int this_irq, void *dev_id) { | 98 | static irqreturn_t pca_handler(int this_irq, void *dev_id) { |
99 | wake_up_interruptible(&pca_wait); | 99 | wake_up(&pca_wait); |
100 | return IRQ_HANDLED; | 100 | return IRQ_HANDLED; |
101 | } | 101 | } |
102 | 102 | ||
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index c4df9d411cd..5b2213df5ed 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c | |||
@@ -84,7 +84,7 @@ static int i2c_pca_pf_waitforcompletion(void *pd) | |||
84 | unsigned long timeout; | 84 | unsigned long timeout; |
85 | 85 | ||
86 | if (i2c->irq) { | 86 | if (i2c->irq) { |
87 | ret = wait_event_interruptible_timeout(i2c->wait, | 87 | ret = wait_event_timeout(i2c->wait, |
88 | i2c->algo_data.read_byte(i2c, I2C_PCA_CON) | 88 | i2c->algo_data.read_byte(i2c, I2C_PCA_CON) |
89 | & I2C_PCA_CON_SI, i2c->adap.timeout); | 89 | & I2C_PCA_CON_SI, i2c->adap.timeout); |
90 | } else { | 90 | } else { |
@@ -122,7 +122,7 @@ static irqreturn_t i2c_pca_pf_handler(int this_irq, void *dev_id) | |||
122 | if ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) | 122 | if ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) |
123 | return IRQ_NONE; | 123 | return IRQ_NONE; |
124 | 124 | ||
125 | wake_up_interruptible(&i2c->wait); | 125 | wake_up(&i2c->wait); |
126 | 126 | ||
127 | return IRQ_HANDLED; | 127 | return IRQ_HANDLED; |
128 | } | 128 | } |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 1e245e9cad3..e56e4b6823c 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -324,12 +324,12 @@ static int piix4_transaction(void) | |||
324 | else | 324 | else |
325 | msleep(1); | 325 | msleep(1); |
326 | 326 | ||
327 | while ((timeout++ < MAX_TIMEOUT) && | 327 | while ((++timeout < MAX_TIMEOUT) && |
328 | ((temp = inb_p(SMBHSTSTS)) & 0x01)) | 328 | ((temp = inb_p(SMBHSTSTS)) & 0x01)) |
329 | msleep(1); | 329 | msleep(1); |
330 | 330 | ||
331 | /* If the SMBus is still busy, we give up */ | 331 | /* If the SMBus is still busy, we give up */ |
332 | if (timeout >= MAX_TIMEOUT) { | 332 | if (timeout == MAX_TIMEOUT) { |
333 | dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); | 333 | dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); |
334 | result = -ETIMEDOUT; | 334 | result = -ETIMEDOUT; |
335 | } | 335 | } |
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index b1c050ff311..e29b6d5ba8e 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/types.h> | ||
16 | 17 | ||
17 | /* include interfaces to usb layer */ | 18 | /* include interfaces to usb layer */ |
18 | #include <linux/usb.h> | 19 | #include <linux/usb.h> |
@@ -31,8 +32,8 @@ | |||
31 | #define CMD_I2C_IO_END (1<<1) | 32 | #define CMD_I2C_IO_END (1<<1) |
32 | 33 | ||
33 | /* i2c bit delay, default is 10us -> 100kHz */ | 34 | /* i2c bit delay, default is 10us -> 100kHz */ |
34 | static int delay = 10; | 35 | static unsigned short delay = 10; |
35 | module_param(delay, int, 0); | 36 | module_param(delay, ushort, 0); |
36 | MODULE_PARM_DESC(delay, "bit delay in microseconds, " | 37 | MODULE_PARM_DESC(delay, "bit delay in microseconds, " |
37 | "e.g. 10 for 100kHz (default is 100kHz)"); | 38 | "e.g. 10 for 100kHz (default is 100kHz)"); |
38 | 39 | ||
@@ -109,7 +110,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) | |||
109 | 110 | ||
110 | static u32 usb_func(struct i2c_adapter *adapter) | 111 | static u32 usb_func(struct i2c_adapter *adapter) |
111 | { | 112 | { |
112 | u32 func; | 113 | __le32 func; |
113 | 114 | ||
114 | /* get functionality from adapter */ | 115 | /* get functionality from adapter */ |
115 | if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) != | 116 | if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) != |
@@ -118,7 +119,7 @@ static u32 usb_func(struct i2c_adapter *adapter) | |||
118 | return 0; | 119 | return 0; |
119 | } | 120 | } |
120 | 121 | ||
121 | return func; | 122 | return le32_to_cpu(func); |
122 | } | 123 | } |
123 | 124 | ||
124 | /* This is the actual algorithm we define */ | 125 | /* This is the actual algorithm we define */ |
@@ -216,8 +217,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface, | |||
216 | "i2c-tiny-usb at bus %03d device %03d", | 217 | "i2c-tiny-usb at bus %03d device %03d", |
217 | dev->usb_dev->bus->busnum, dev->usb_dev->devnum); | 218 | dev->usb_dev->bus->busnum, dev->usb_dev->devnum); |
218 | 219 | ||
219 | if (usb_write(&dev->adapter, CMD_SET_DELAY, | 220 | if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) { |
220 | cpu_to_le16(delay), 0, NULL, 0) != 0) { | ||
221 | dev_err(&dev->adapter.dev, | 221 | dev_err(&dev->adapter.dev, |
222 | "failure setting delay to %dus\n", delay); | 222 | "failure setting delay to %dus\n", delay); |
223 | retval = -EIO; | 223 | retval = -EIO; |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index e4b1543015a..a84a909e123 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -165,10 +165,10 @@ static int vt596_transaction(u8 size) | |||
165 | do { | 165 | do { |
166 | msleep(1); | 166 | msleep(1); |
167 | temp = inb_p(SMBHSTSTS); | 167 | temp = inb_p(SMBHSTSTS); |
168 | } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); | 168 | } while ((temp & 0x01) && (++timeout < MAX_TIMEOUT)); |
169 | 169 | ||
170 | /* If the SMBus is still busy, we give up */ | 170 | /* If the SMBus is still busy, we give up */ |
171 | if (timeout >= MAX_TIMEOUT) { | 171 | if (timeout == MAX_TIMEOUT) { |
172 | result = -ETIMEDOUT; | 172 | result = -ETIMEDOUT; |
173 | dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); | 173 | dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); |
174 | } | 174 | } |