Skip to contentSkip to conversation

staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done

PATCH New Emil Renner Berthing 2 participants 4 messages Mar 29, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done

Simplify hdmi_phy_wait_i2c_done so the call to hdmi_readb is only done in one place. This also fixes a checkpatch warning.

---
 drivers/staging/imx-drm/imx-hdmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +1 -4
index da71d8d..cc8d232 100644
@@ -660,13 +660,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec)
 {
-	unsigned char val = 0;
-	val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
-	while (!val) {
+	while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
 		udelay(1000);
 		if (msec-- == 0)
 			return false;
-		val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
 	}
 	return true;
 }
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done

Quoted 18 lines · Emil Renner Berthing

Simplify hdmi_phy_wait_i2c_done so the call to hdmi_readb is only done in one place. This also fixes a checkpatch warning.

---
 drivers/staging/imx-drm/imx-hdmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +0 -1
index da71d8d..cc8d232 100644
@@ -660,13 +660,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec)
 {
-	unsigned char val = 0;

drivers/staging/imx-drm/imx-hdmi.c static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi, · line 669

Quoted 10 lines
drivers/staging/imx-drm/imx-hdmi.c +1 -3
-	val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
-	while (!val) {
+	while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
 		udelay(1000);
 		if (msec-- == 0)
 			return false;
-		val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
 	}
 	return true;
 }

I'd prefer to have the msec check before the delay, not your fault, but while your in the area anyway. That way a wait of 0 ms doesn't wait at all and just checks if it is done.

Troy

#2 lore raw

PATCH 1/1 staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done

Quoted 25 lines · Troy Kisky
Quoted 24 lines · Emil Renner Berthing

Simplify hdmi_phy_wait_i2c_done so the call to hdmi_readb is only done in one place. This also fixes a checkpatch warning.

---
 drivers/staging/imx-drm/imx-hdmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +1 -4
index da71d8d..cc8d232 100644
@@ -660,13 +660,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec)
 {
-     unsigned char val = 0;
-     val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
-     while (!val) {
+     while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
              udelay(1000);
              if (msec-- == 0)
                      return false;
-             val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
Quoted 8 lines

drivers/staging/imx-drm/imx-hdmi.c static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi, · line 669

Quoted 4 lines
drivers/staging/imx-drm/imx-hdmi.c +0 -0
      }
      return true;
 }

I'd prefer to have the msec check before the delay, not your fault, but while your in the area anyway. That way a wait of 0 ms doesn't wait at all and just checks if it is done.

Makes perfect sense. I'll resend the patch although this was mostly to make the Eudyptula scripts happy ;)

/Emil

#3 lore raw

PATCH v2 1/1 staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done

In reply to Emil Renner Berthing

Simplify hdmi_phy_wait_i2c_done so the call to hdmi_readb is only done in one place. Also check for timout before waiting as suggested by Troy Kisky.
This also fixes a checkpatch warning.

---
 drivers/staging/imx-drm/imx-hdmi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +2 -5
index da71d8d..6178ffc 100644
@@ -660,13 +660,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec)
 {
-	unsigned char val = 0;
-	val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
-	while (!val) {
-		udelay(1000);
+	while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
 		if (msec-- == 0)
 			return false;
-		val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3;
+		udelay(1000);
 	}
 	return true;
 }
Signature · 1 line
1.9.1