提交 90e6b26d 编写于 作者: D Daniel Kurtz 提交者: Daniel Vetter

drm/i915/intel_i2c: reuse GMBUS2 value read in polling loop

Save the GMBUS2 value read while polling for state changes, and then
reuse this value when determining for which reason the loops were exited.
This is a small optimization which saves a couple of bus accesses for
memory mapped IO registers.

To avoid "assigning in if clause" checkpatch errors", use a ret variable
to store the wait_for macro return value.
Signed-off-by: NDaniel Kurtz <djkurtz@chromium.org>
Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 56f9eac0
...@@ -219,13 +219,16 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg, ...@@ -219,13 +219,16 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
GMBUS_SLAVE_READ | GMBUS_SW_RDY); GMBUS_SLAVE_READ | GMBUS_SW_RDY);
POSTING_READ(GMBUS2 + reg_offset); POSTING_READ(GMBUS2 + reg_offset);
do { do {
int ret;
u32 val, loop = 0; u32 val, loop = 0;
u32 gmbus2;
if (wait_for(I915_READ(GMBUS2 + reg_offset) & ret = wait_for((gmbus2 = I915_READ(GMBUS2 + reg_offset)) &
(GMBUS_SATOER | GMBUS_HW_RDY), (GMBUS_SATOER | GMBUS_HW_RDY),
50)) 50);
if (ret)
return -ETIMEDOUT; return -ETIMEDOUT;
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER) if (gmbus2 & GMBUS_SATOER)
return -ENXIO; return -ENXIO;
val = I915_READ(GMBUS3 + reg_offset); val = I915_READ(GMBUS3 + reg_offset);
...@@ -260,6 +263,9 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg) ...@@ -260,6 +263,9 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg)
GMBUS_SLAVE_WRITE | GMBUS_SW_RDY); GMBUS_SLAVE_WRITE | GMBUS_SW_RDY);
POSTING_READ(GMBUS2 + reg_offset); POSTING_READ(GMBUS2 + reg_offset);
while (len) { while (len) {
int ret;
u32 gmbus2;
val = loop = 0; val = loop = 0;
do { do {
val |= *buf++ << (8 * loop); val |= *buf++ << (8 * loop);
...@@ -268,11 +274,12 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg) ...@@ -268,11 +274,12 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg)
I915_WRITE(GMBUS3 + reg_offset, val); I915_WRITE(GMBUS3 + reg_offset, val);
POSTING_READ(GMBUS2 + reg_offset); POSTING_READ(GMBUS2 + reg_offset);
if (wait_for(I915_READ(GMBUS2 + reg_offset) & ret = wait_for((gmbus2 = I915_READ(GMBUS2 + reg_offset)) &
(GMBUS_SATOER | GMBUS_HW_RDY), (GMBUS_SATOER | GMBUS_HW_RDY),
50)) 50);
if (ret)
return -ETIMEDOUT; return -ETIMEDOUT;
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER) if (gmbus2 & GMBUS_SATOER)
return -ENXIO; return -ENXIO;
} }
return 0; return 0;
...@@ -342,6 +349,8 @@ gmbus_xfer(struct i2c_adapter *adapter, ...@@ -342,6 +349,8 @@ gmbus_xfer(struct i2c_adapter *adapter,
I915_WRITE(GMBUS0 + reg_offset, bus->reg0); I915_WRITE(GMBUS0 + reg_offset, bus->reg0);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
u32 gmbus2;
if (gmbus_is_index_read(msgs, i, num)) { if (gmbus_is_index_read(msgs, i, num)) {
ret = gmbus_xfer_index_read(dev_priv, &msgs[i]); ret = gmbus_xfer_index_read(dev_priv, &msgs[i]);
i += 1; /* set i to the index of the read xfer */ i += 1; /* set i to the index of the read xfer */
...@@ -356,11 +365,12 @@ gmbus_xfer(struct i2c_adapter *adapter, ...@@ -356,11 +365,12 @@ gmbus_xfer(struct i2c_adapter *adapter,
if (ret == -ENXIO) if (ret == -ENXIO)
goto clear_err; goto clear_err;
if (wait_for(I915_READ(GMBUS2 + reg_offset) & ret = wait_for((gmbus2 = I915_READ(GMBUS2 + reg_offset)) &
(GMBUS_SATOER | GMBUS_HW_WAIT_PHASE), (GMBUS_SATOER | GMBUS_HW_WAIT_PHASE),
50)) 50);
if (ret)
goto timeout; goto timeout;
if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER) if (gmbus2 & GMBUS_SATOER)
goto clear_err; goto clear_err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册