Rev 1125 | Rev 3031 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1125 | Rev 1963 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | * one (discarding status on the second message) or errno |
62 | * one (discarding status on the second message) or errno |
63 | * (discarding status on the first one). |
63 | * (discarding status on the first one). |
64 | */ |
64 | */ |
Line 65... | Line 65... | ||
65 | 65 | ||
66 | if (adap->algo->master_xfer) { |
- | |
67 | #ifdef DEBUG |
- | |
68 | for (ret = 0; ret < num; ret++) { |
- | |
69 | dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " |
- | |
70 | "len=%d%s\n", ret, (msgs[ret].flags & I2C_M_RD) |
- | |
71 | ? 'R' : 'W', msgs[ret].addr, msgs[ret].len, |
- | |
72 | (msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : ""); |
- | |
73 | } |
- | |
Line 74... | Line -... | ||
74 | #endif |
- | |
75 | - | ||
76 | // if (in_atomic() || irqs_disabled()) { |
- | |
77 | // ret = mutex_trylock(&adap->bus_lock); |
- | |
78 | // if (!ret) |
- | |
79 | // /* I2C activity is ongoing. */ |
- | |
80 | // return -EAGAIN; |
- | |
81 | // } else { |
- | |
Line 82... | Line 66... | ||
82 | // mutex_lock_nested(&adap->bus_lock, adap->level); |
66 | if (adap->algo->master_xfer) { |
83 | // } |
67 | |
84 | 68 | ||
- | 69 | /* Retry automatically on arbitration loss */ |
|
85 | /* Retry automatically on arbitration loss */ |
70 | orig_jiffies = 0; |
86 | // orig_jiffies = jiffies; |
71 | for (ret = 0, try = 0; try <= adap->retries; try++) { |
87 | for (ret = 0, try = 0; try <= adap->retries; try++) { |
72 | |
88 | ret = adap->algo->master_xfer(adap, msgs, num); |
73 | ret = adap->algo->master_xfer(adap, msgs, num); |
89 | if (ret != -EAGAIN) |
74 | if (ret != -EAGAIN) |
90 | break; |
75 | break; |
91 | // if (time_after(jiffies, orig_jiffies + adap->timeout)) |
76 | // if (time_after(jiffies, orig_jiffies + adap->timeout)) |
92 | // break; |
77 | // break; |
93 | delay(1); |
- | |
94 | } |
78 | delay(1); |
95 | // mutex_unlock(&adap->bus_lock); |
79 | } |
96 | 80 | // mutex_unlock(&adap->bus_lock); |
|
97 | return ret; |
81 | return ret; |
98 | } else { |
82 | } else { |
99 | // dev_dbg(&adap->dev, "I2C level transfers not supported\n"); |
83 | // dev_dbg(&adap->dev, "I2C level transfers not supported\n"); |
100 | return -EOPNOTSUPP; |
84 | return -EOPNOTSUPP; |
Line -... | Line 85... | ||
- | 85 | } |
|
- | 86 | } |
|
- | 87 | EXPORT_SYMBOL(i2c_transfer); |
|
- | 88 | ||
- | 89 | ||
- | 90 | /** |
|
- | 91 | * i2c_new_device - instantiate an i2c device |
|
- | 92 | * @adap: the adapter managing the device |
|
- | 93 | * @info: describes one I2C device; bus_num is ignored |
|
- | 94 | * Context: can sleep |
|
- | 95 | * |
|
- | 96 | * Create an i2c device. Binding is handled through driver model |
|
- | 97 | * probe()/remove() methods. A driver may be bound to this device when we |
|
- | 98 | * return from this function, or any later moment (e.g. maybe hotplugging will |
|
- | 99 | * load the driver module). This call is not appropriate for use by mainboard |
|
- | 100 | * initialization logic, which usually runs during an arch_initcall() long |
|
- | 101 | * before any i2c_adapter could exist. |
|
- | 102 | * |
|
- | 103 | * This returns the new i2c client, which may be saved for later use with |
|
- | 104 | * i2c_unregister_device(); or NULL to indicate an error. |
|
- | 105 | */ |
|
- | 106 | struct i2c_client * |
|
- | 107 | i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) |
|
- | 108 | { |
|
- | 109 | struct i2c_client *client; |
|
- | 110 | int status; |
|
- | 111 | ||
- | 112 | client = kzalloc(sizeof *client, GFP_KERNEL); |
|
- | 113 | if (!client) |
|
- | 114 | return NULL; |
|
- | 115 | ||
- | 116 | client->adapter = adap; |
|
- | 117 | ||
- | 118 | client->flags = info->flags; |
|
- | 119 | client->addr = info->addr; |
|
- | 120 | client->irq = info->irq; |