From: Andrew Morton - Basic coding-syle fixes. - ocores_xfer() doesn't seem to correctly handle a -ERESTARTSYS from wait_event_interruptible_timeout(). - ocores_i2c_probe() might be ioremap()ping and release_mem_region()ing one byte too many. - ditto ocores_i2c_remove() Cc: Peter Korsgaard Cc: Jean Delvare Cc: Greg KH Signed-off-by: Andrew Morton --- drivers/i2c/busses/i2c-ocores.c | 58 ++++++++++-------------------- include/linux/i2c-ocores.h | 1 i2c/busses/Kconfig | 0 i2c/busses/Makefile | 0 4 files changed, 20 insertions(+), 39 deletions(-) diff -puN drivers/i2c/busses/i2c-ocores.c~opencores-i2c-bus-driver-tidy drivers/i2c/busses/i2c-ocores.c --- 25/drivers/i2c/busses/i2c-ocores.c~opencores-i2c-bus-driver-tidy Fri Apr 21 14:11:41 2006 +++ 25-akpm/drivers/i2c/busses/i2c-ocores.c Fri Apr 21 14:11:41 2006 @@ -62,12 +62,12 @@ struct ocores_i2c { #define STATE_READ 3 #define STATE_ERROR 4 -static __inline__ void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) +static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) { iowrite8(value, i2c->base + reg * i2c->regstep); } -static __inline__ u8 oc_getreg(struct ocores_i2c *i2c, int reg) +static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) { return ioread8(i2c->base + reg * i2c->regstep); } @@ -77,8 +77,7 @@ static void ocores_process(struct ocores struct i2c_msg *msg = i2c->msg; u8 stat = oc_getreg(i2c, OCI2C_STATUS); - if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) - { + if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) { /* stop has been sent */ oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK); wake_up_interruptible(&i2c->wait); @@ -86,41 +85,34 @@ static void ocores_process(struct ocores } /* error? */ - if (stat & OCI2C_STAT_ARBLOST) - { + if (stat & OCI2C_STAT_ARBLOST) { i2c->state = STATE_ERROR; oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); return; } - if ((i2c->state == STATE_START) || (i2c->state == STATE_WRITE)) - { + if ((i2c->state == STATE_START) || (i2c->state == STATE_WRITE)) { i2c->state = (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; - if (stat & OCI2C_STAT_NACK) - { + if (stat & OCI2C_STAT_NACK) { i2c->state = STATE_ERROR; oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); return; } - } - else + } else msg->buf[i2c->pos++] = oc_getreg(i2c, OCI2C_DATA); /* end of msg? */ - if (i2c->pos == msg->len) - { + if (i2c->pos == msg->len) { i2c->nmsgs--; i2c->msg++; i2c->pos = 0; msg = i2c->msg; - if (i2c->nmsgs) /* end? */ - { + if (i2c->nmsgs) { /* end? */ /* send start? */ - if (!(msg->flags & I2C_M_NOSTART)) - { + if (!(msg->flags & I2C_M_NOSTART)) { u8 addr = (msg->addr << 1); if (msg->flags & I2C_M_RD) @@ -131,26 +123,20 @@ static void ocores_process(struct ocores oc_setreg(i2c, OCI2C_DATA, addr); oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); return; - } - else + } else i2c->state = (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; - } - else - { + } else { i2c->state = STATE_DONE; oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); return; } } - if (i2c->state == STATE_READ) - { + if (i2c->state == STATE_READ) { oc_setreg(i2c, OCI2C_CMD, i2c->pos == (msg->len-1) ? OCI2C_CMD_READ_NACK : OCI2C_CMD_READ_ACK); - } - else - { + } else { oc_setreg(i2c, OCI2C_DATA, msg->buf[i2c->pos++]); oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_WRITE); } @@ -228,8 +214,8 @@ static struct i2c_adapter ocores_adapter static int __devinit ocores_i2c_probe(struct platform_device *pdev) { - struct ocores_i2c* i2c; - struct ocores_i2c_platform_data* pdata; + struct ocores_i2c *i2c; + struct ocores_i2c_platform_data *pdata; struct resource *res, *res2; int ret; @@ -257,8 +243,7 @@ static int __devinit ocores_i2c_probe(st } i2c->base = ioremap(res->start, res->end - res->start + 1); - if (!i2c->base) - { + if (!i2c->base) { dev_err(&pdev->dev, "Unable to map registers\n"); ret = -EIO; goto map_failed; @@ -268,10 +253,8 @@ static int __devinit ocores_i2c_probe(st ocores_init(i2c, pdata); init_waitqueue_head(&i2c->wait); - ret = request_irq(res2->start, ocores_isr, 0, - pdev->name, i2c); - if (ret) - { + ret = request_irq(res2->start, ocores_isr, 0, pdev->name, i2c); + if (ret) { dev_err(&pdev->dev, "Cannot claim IRQ\n"); goto request_irq_failed; } @@ -284,8 +267,7 @@ static int __devinit ocores_i2c_probe(st /* add i2c adapter to i2c tree */ ret = i2c_add_adapter(&i2c->adap); - if (ret) - { + if (ret) { dev_err(&pdev->dev, "Failed to add adapter\n"); goto add_adapter_failed; } diff -puN drivers/i2c/busses/Kconfig~opencores-i2c-bus-driver-tidy drivers/i2c/busses/Kconfig diff -puN drivers/i2c/busses/Makefile~opencores-i2c-bus-driver-tidy drivers/i2c/busses/Makefile diff -puN include/linux/i2c-ocores.h~opencores-i2c-bus-driver-tidy include/linux/i2c-ocores.h --- 25/include/linux/i2c-ocores.h~opencores-i2c-bus-driver-tidy Fri Apr 21 14:11:41 2006 +++ 25-akpm/include/linux/i2c-ocores.h Fri Apr 21 14:11:41 2006 @@ -17,4 +17,3 @@ struct ocores_i2c_platform_data { }; #endif /* _LINUX_I2C_OCORES_H */ - _