Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207117
b: refs/heads/master
c: 0e0aff2
h: refs/heads/master
i:
  207115: 3467fb2
v: v3
  • Loading branch information
Jesper Nilsson committed Aug 4, 2010
1 parent dc60065 commit 4e31863
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60362158e2419b20cc04d43a6ffa60c1845775dc
refs/heads/master: 0e0aff21261aba52ee37b59fcf48202230fc7377
39 changes: 13 additions & 26 deletions trunk/arch/cris/arch-v10/drivers/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ static const char i2c_name[] = "i2c";

#define SDABIT CONFIG_ETRAX_I2C_DATA_PORT
#define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT
#define i2c_enable()
#define i2c_disable()
#define i2c_enable()
#define i2c_disable()

/* enable or disable output-enable, to select output or input on the i2c bus */

Expand Down Expand Up @@ -90,7 +90,7 @@ static const char i2c_name[] = "i2c";

#define i2c_dir_out() \
*R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \
REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1);
REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1);
#define i2c_dir_in() \
*R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \
REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0);
Expand Down Expand Up @@ -188,7 +188,7 @@ i2c_outbyte(unsigned char x)
} else {
i2c_data(I2C_DATA_LOW);
}

i2c_delay(CLOCK_LOW_TIME/2);
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_HIGH_TIME);
Expand Down Expand Up @@ -415,7 +415,7 @@ i2c_sendnack(void)
*#
*#--------------------------------------------------------------------------*/
int
i2c_writereg(unsigned char theSlave, unsigned char theReg,
i2c_writereg(unsigned char theSlave, unsigned char theReg,
unsigned char theValue)
{
int error, cntr = 3;
Expand Down Expand Up @@ -467,7 +467,7 @@ i2c_writereg(unsigned char theSlave, unsigned char theReg,
* enable interrupt again
*/
local_irq_restore(flags);

} while(error && cntr--);

i2c_delay(CLOCK_LOW_TIME);
Expand Down Expand Up @@ -503,7 +503,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
* generate start condition
*/
i2c_start();

/*
* send slave address
*/
Expand Down Expand Up @@ -554,7 +554,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
* enable interrupt again
*/
local_irq_restore(flags);

} while(error && cntr--);

spin_unlock(&i2c_lock);
Expand All @@ -577,8 +577,7 @@ i2c_release(struct inode *inode, struct file *filp)
/* Main device API. ioctl's to write or read to/from i2c registers.
*/

static int
i2c_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
static long i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) {
return -EINVAL;
Expand All @@ -587,7 +586,7 @@ i2c_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
switch (_IOC_NR(cmd)) {
case I2C_WRITEREG:
/* write to an i2c slave */
D(printk("i2cw %d %d %d\n",
D(printk(KERN_DEBUG "i2cw %d %d %d\n",
I2C_ARGSLAVE(arg),
I2C_ARGREG(arg),
I2C_ARGVALUE(arg)));
Expand All @@ -599,32 +598,20 @@ i2c_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
{
unsigned char val;
/* read from an i2c slave */
D(printk("i2cr %d %d ",
D(printk(KERN_DEBUG "i2cr %d %d ",
I2C_ARGSLAVE(arg),
I2C_ARGREG(arg)));
val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg));
D(printk("= %d\n", val));
D(printk(KERN_DEBUG "= %d\n", val));
return val;
}
}
default:
return -EINVAL;

}

return 0;
}

static long i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
long ret;

lock_kernel();
ret = i2c_ioctl_unlocked(file, cmd, arg);
unlock_kernel();

return ret;
}

static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = i2c_ioctl,
Expand Down

0 comments on commit 4e31863

Please sign in to comment.