Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1875 → Rev 1963

/drivers/video/drm/i2c/i2c-algo-bit.c
43,7 → 43,6
do {} while (0)
#endif /* DEBUG */
 
 
/* ----- global variables --------------------------------------------- */
 
static int bit_test; /* see if the line-setting functions work */
165,8 → 164,8
setsda(adap, sb);
udelay((adap->udelay + 1) / 2);
if (sclhi(adap) < 0) { /* timed out */
// bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
// "timeout at bit #%d\n", (int)c, i);
bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
"timeout at bit #%d\n", (int)c, i);
return -ETIMEDOUT;
}
/* FIXME do arbitration here:
179,8 → 178,8
}
sdahi(adap);
if (sclhi(adap) < 0) { /* timeout */
// bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
// "timeout at ack\n", (int)c);
bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
"timeout at ack\n", (int)c);
return -ETIMEDOUT;
}
 
188,8 → 187,8
* NAK (usually to report problems with the data we wrote).
*/
ack = !getsda(adap); /* ack: sda is pulled low -> success */
// bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
// ack ? "A" : "NA");
bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
ack ? "A" : "NA");
 
scllo(adap);
return ack;
227,10 → 226,18
* Sanity check for the adapter hardware - check the reaction of
* the bus lines only if it seems to be idle.
*/
static int test_bus(struct i2c_algo_bit_data *adap, char *name)
static int test_bus(struct i2c_adapter *i2c_adap)
{
int scl, sda;
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
const char *name = i2c_adap->name;
int scl, sda, ret;
 
if (adap->pre_xfer) {
ret = adap->pre_xfer(i2c_adap);
if (ret < 0)
return -ENODEV;
}
 
if (adap->getscl == NULL)
pr_info("%s: Testing SDA only, SCL is not readable\n", name);
 
292,11 → 299,19
"while pulling SCL high!\n", name);
goto bailout;
}
 
if (adap->post_xfer)
adap->post_xfer(i2c_adap);
 
pr_info("%s: Test OK\n", name);
return 0;
bailout:
sdahi(adap);
sclhi(adap);
 
if (adap->post_xfer)
adap->post_xfer(i2c_adap);
 
return -ENODEV;
}
 
429,11 → 444,11
msg->len += inval;
}
 
// bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n",
// inval,
// (flags & I2C_M_NO_RD_ACK)
// ? "(no ack/nak)"
// : (count ? "A" : "NA"));
bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n",
inval,
(flags & I2C_M_NO_RD_ACK)
? "(no ack/nak)"
: (count ? "A" : "NA"));
 
if (!(flags & I2C_M_NO_RD_ACK)) {
inval = acknak(i2c_adap, count);
516,6 → 531,13
int i, ret;
unsigned short nak_ok;
 
//ENTER();
if (adap->pre_xfer) {
ret = adap->pre_xfer(i2c_adap);
if (ret < 0)
return ret;
}
 
bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
i2c_start(adap);
for (i = 0; i < num; i++) {
564,6 → 586,10
bailout:
bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
i2c_stop(adap);
// LEAVE();
 
if (adap->post_xfer)
adap->post_xfer(i2c_adap);
return ret;
}
 
586,15 → 612,17
/*
* registering functions to load algorithms at runtime
*/
static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
static int __i2c_bit_add_bus(struct i2c_adapter *adap,
int (*add_adapter)(struct i2c_adapter *))
{
struct i2c_algo_bit_data *bit_adap = adap->algo_data;
int ret;
 
// if (bit_test) {
// int ret = test_bus(bit_adap, adap->name);
// if (ret < 0)
// return -ENODEV;
// }
if (bit_test) {
ret = test_bus(adap);
if (ret < 0)
return -ENODEV;
}
 
/* register new adapter to i2c module... */
adap->algo = &i2c_bit_algo;
605,12 → 633,7
 
int i2c_bit_add_bus(struct i2c_adapter *adap)
{
int err;
return __i2c_bit_add_bus(adap, NULL);
}
 
err = i2c_bit_prepare_bus(adap);
if (err)
return err;
 
return 0; //i2c_add_adapter(adap);
}
 
/drivers/video/drm/i2c/i2c-core.c
64,27 → 64,12
*/
 
if (adap->algo->master_xfer) {
#ifdef DEBUG
for (ret = 0; ret < num; ret++) {
dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
"len=%d%s\n", ret, (msgs[ret].flags & I2C_M_RD)
? 'R' : 'W', msgs[ret].addr, msgs[ret].len,
(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
}
#endif
 
// if (in_atomic() || irqs_disabled()) {
// ret = mutex_trylock(&adap->bus_lock);
// if (!ret)
// /* I2C activity is ongoing. */
// return -EAGAIN;
// } else {
// mutex_lock_nested(&adap->bus_lock, adap->level);
// }
 
/* Retry automatically on arbitration loss */
// orig_jiffies = jiffies;
orig_jiffies = 0;
for (ret = 0, try = 0; try <= adap->retries; try++) {
 
ret = adap->algo->master_xfer(adap, msgs, num);
if (ret != -EAGAIN)
break;
93,7 → 78,6
delay(1);
}
// mutex_unlock(&adap->bus_lock);
 
return ret;
} else {
// dev_dbg(&adap->dev, "I2C level transfers not supported\n");
103,6 → 87,42
EXPORT_SYMBOL(i2c_transfer);
 
 
/**
* i2c_new_device - instantiate an i2c device
* @adap: the adapter managing the device
* @info: describes one I2C device; bus_num is ignored
* Context: can sleep
*
* Create an i2c device. Binding is handled through driver model
* probe()/remove() methods. A driver may be bound to this device when we
* return from this function, or any later moment (e.g. maybe hotplugging will
* load the driver module). This call is not appropriate for use by mainboard
* initialization logic, which usually runs during an arch_initcall() long
* before any i2c_adapter could exist.
*
* This returns the new i2c client, which may be saved for later use with
* i2c_unregister_device(); or NULL to indicate an error.
*/
struct i2c_client *
i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
{
struct i2c_client *client;
int status;
 
client = kzalloc(sizeof *client, GFP_KERNEL);
if (!client)
return NULL;
 
client->adapter = adap;
 
client->flags = info->flags;
client->addr = info->addr;
client->irq = info->irq;
 
strlcpy(client->name, info->type, sizeof(client->name));
 
return client;
}