···109109 * the default if there is none110110*/111111112112-static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev)112112+static inline struct s3c2410_platform_i2c *113113+s3c24xx_i2c_get_platformdata(struct device *dev)113114{114115 if (dev->platform_data != NULL)115116 return (struct s3c2410_platform_i2c *)dev->platform_data;···130129131130 i2c->msg_ptr = 0;132131 i2c->msg = NULL;133133- i2c->msg_idx ++;132132+ i2c->msg_idx++;134133 i2c->msg_num = 0;135134 if (ret)136135 i2c->msg_idx = ret;···141140static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)142141{143142 unsigned long tmp;144144-143143+145144 tmp = readl(i2c->regs + S3C2410_IICCON);146145 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);147147-148146}149147150148static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)151149{152150 unsigned long tmp;153153-151151+154152 tmp = readl(i2c->regs + S3C2410_IICCON);155153 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);156156-157154}158155159156/* irq enable/disable functions */···159160static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)160161{161162 unsigned long tmp;162162-163163+163164 tmp = readl(i2c->regs + S3C2410_IICCON);164165 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);165166}···167168static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)168169{169170 unsigned long tmp;170170-171171+171172 tmp = readl(i2c->regs + S3C2410_IICCON);172173 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);173174}···175176176177/* s3c24xx_i2c_message_start177178 *178178- * put the start of a message onto the bus 179179+ * put the start of a message onto the bus179180*/180181181181-static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, 182182+static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,182183 struct i2c_msg *msg)183184{184185 unsigned int addr = (msg->addr & 0x7f) << 1;···197198 if (msg->flags & I2C_M_REV_DIR_ADDR)198199 addr ^= 1;199200200200- // todo - check for wether ack wanted or not201201+ /* todo - check for wether ack wanted or not */201202 s3c24xx_i2c_enable_ack(i2c);202203203204 iiccon = readl(i2c->regs + S3C2410_IICCON);204205 writel(stat, i2c->regs + S3C2410_IICSTAT);205205-206206+206207 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);207208 writeb(addr, i2c->regs + S3C2410_IICDS);208208-209209+209210 /* delay here to ensure the data byte has gotten onto the bus210211 * before the transaction is started */211212···213214214215 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);215216 writel(iiccon, i2c->regs + S3C2410_IICCON);216216-217217- stat |= S3C2410_IICSTAT_START;217217+218218+ stat |= S3C2410_IICSTAT_START;218219 writel(stat, i2c->regs + S3C2410_IICSTAT);219220}220221···225226 dev_dbg(i2c->dev, "STOP\n");226227227228 /* stop the transfer */228228- iicstat &= ~ S3C2410_IICSTAT_START;229229+ iicstat &= ~S3C2410_IICSTAT_START;229230 writel(iicstat, i2c->regs + S3C2410_IICSTAT);230230-231231+231232 i2c->state = STATE_STOP;232232-233233+233234 s3c24xx_i2c_master_complete(i2c, ret);234235 s3c24xx_i2c_disable_irq(i2c);235236}···239240240241/* is_lastmsg()241242 *242242- * returns TRUE if the current message is the last in the set 243243+ * returns TRUE if the current message is the last in the set243244*/244245245246static inline int is_lastmsg(struct s3c24xx_i2c *i2c)···287288288289 case STATE_STOP:289290 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);290290- s3c24xx_i2c_disable_irq(i2c); 291291+ s3c24xx_i2c_disable_irq(i2c);291292 goto out_ack;292293293294 case STATE_START:294295 /* last thing we did was send a start condition on the295296 * bus, or started a new i2c message296297 */297297-298298+298299 if (iicstat & S3C2410_IICSTAT_LASTBIT &&299300 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {300301 /* ack was not received... */···320321 if (i2c->state == STATE_READ)321322 goto prepare_read;322323323323- /* fall through to the write state, as we will need to 324324+ /* fall through to the write state, as we will need to324325 * send a byte as well */325326326327 case STATE_WRITE:···337338 }338339 }339340340340- retry_write:341341+ retry_write:341342342343 if (!is_msgend(i2c)) {343344 byte = i2c->msg->buf[i2c->msg_ptr++];···357358 dev_dbg(i2c->dev, "WRITE: Next Message\n");358359359360 i2c->msg_ptr = 0;360360- i2c->msg_idx ++;361361+ i2c->msg_idx++;361362 i2c->msg++;362362-363363+363364 /* check to see if we need to do another message */364365 if (i2c->msg->flags & I2C_M_NOSTART) {365366···373374374375 goto retry_write;375376 } else {376376-377377 /* send the new start */378378 s3c24xx_i2c_message_start(i2c, i2c->msg);379379 i2c->state = STATE_START;···386388 break;387389388390 case STATE_READ:389389- /* we have a byte of data in the data register, do 391391+ /* we have a byte of data in the data register, do390392 * something with it, and then work out wether we are391393 * going to do any more read/write392394 */···394396 byte = readb(i2c->regs + S3C2410_IICDS);395397 i2c->msg->buf[i2c->msg_ptr++] = byte;396398397397- prepare_read:399399+ prepare_read:398400 if (is_msglast(i2c)) {399401 /* last byte of buffer */400402401403 if (is_lastmsg(i2c))402404 s3c24xx_i2c_disable_ack(i2c);403403-405405+404406 } else if (is_msgend(i2c)) {405407 /* ok, we've read the entire buffer, see if there406408 * is anything else we need to do */···426428 /* acknowlegde the IRQ and get back on with the work */427429428430 out_ack:429429- tmp = readl(i2c->regs + S3C2410_IICCON); 431431+ tmp = readl(i2c->regs + S3C2410_IICCON);430432 tmp &= ~S3C2410_IICCON_IRQPEND;431433 writel(tmp, i2c->regs + S3C2410_IICCON);432434 out:···447449 status = readl(i2c->regs + S3C2410_IICSTAT);448450449451 if (status & S3C2410_IICSTAT_ARBITR) {450450- // deal with arbitration loss452452+ /* deal with arbitration loss */451453 dev_err(i2c->dev, "deal with arbitration loss\n");452454 }453455454456 if (i2c->state == STATE_IDLE) {455457 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");456458457457- tmp = readl(i2c->regs + S3C2410_IICCON); 459459+ tmp = readl(i2c->regs + S3C2410_IICCON);458460 tmp &= ~S3C2410_IICCON_IRQPEND;459461 writel(tmp, i2c->regs + S3C2410_IICCON);460462 goto out;461463 }462462-464464+463465 /* pretty much this leaves us with the fact that we've464466 * transmitted or received whatever byte we last sent */465467···482484483485 while (timeout-- > 0) {484486 iicstat = readl(i2c->regs + S3C2410_IICSTAT);485485-487487+486488 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))487489 return 0;488490···500502 * this starts an i2c transfer501503*/502504503503-static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num)505505+static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,506506+ struct i2c_msg *msgs, int num)504507{505508 unsigned long timeout;506509 int ret;···527528 s3c24xx_i2c_enable_irq(i2c);528529 s3c24xx_i2c_message_start(i2c, msgs);529530 spin_unlock_irq(&i2c->lock);530530-531531+531532 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);532533533534 ret = i2c->msg_idx;534535535535- /* having these next two as dev_err() makes life very 536536+ /* having these next two as dev_err() makes life very536537 * noisy when doing an i2cdetect */537538538539 if (timeout == 0)···641642{642643 int diff = freq - wanted;643644644644- return (diff >= -2 && diff <= 2);645645+ return diff >= -2 && diff <= 2;645646}646647647648/* s3c24xx_i2c_clockrate···664665665666 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);666667 clkin /= 1000; /* clkin now in KHz */667667-668668+668669 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",669670 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);670671···772773773774/* s3c24xx_i2c_init774775 *775775- * initialise the controller, set the IO lines and frequency 776776+ * initialise the controller, set the IO lines and frequency776777*/777778778779static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)···791792 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);792793793794 /* write slave address */794794-795795+795796 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);796797797798 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);···876877 goto err_ioarea;877878 }878879879879- dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);880880+ dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",881881+ i2c->regs, i2c->ioarea, res);880882881883 /* setup info block for the i2c core */882884···891891 goto err_iomap;892892893893 /* find the IRQ for this unit (note, this relies on the init call to894894- * ensure no current IRQs pending 894894+ * ensure no current IRQs pending895895 */896896897897 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);···910910 }911911912912 i2c->irq = res;913913-913913+914914 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,915915 (unsigned long)res->start);916916