All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 15/15] drm: omapdrm: dsi: Make wait_for_bit_change() return a status
Date: Sun, 11 Feb 2018 15:07:47 +0200	[thread overview]
Message-ID: <20180211130747.13420-16-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20180211130747.13420-1-laurent.pinchart@ideasonboard.com>

The wait_for_bit_change() function returns the value of the bit it
polls. This requires the caller to compare the return value to the
expected bit value. As all the existing callers need is to check whether
the bit has reached the expected value, it's easier to return a boolean
status from the function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 86bd47f23424..41d500eea843 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -524,7 +524,7 @@ static void dsi_completion_handler(void *data, u32 mask)
 	complete((struct completion *)data);
 }
 
-static inline int wait_for_bit_change(struct platform_device *dsidev,
+static inline bool wait_for_bit_change(struct platform_device *dsidev,
 		const struct dsi_reg idx, int bitnum, int value)
 {
 	unsigned long timeout;
@@ -535,21 +535,21 @@ static inline int wait_for_bit_change(struct platform_device *dsidev,
 	t = 100;
 	while (t-- > 0) {
 		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-			return value;
+			return true;
 	}
 
 	/* then loop for 500ms, sleeping for 1ms in between */
 	timeout = jiffies + msecs_to_jiffies(500);
 	while (time_before(jiffies, timeout)) {
 		if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-			return value;
+			return true;
 
 		wait = ns_to_ktime(1000 * 1000);
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_hrtimeout(&wait, HRTIMER_MODE_REL);
 	}
 
-	return !value;
+	return false;
 }
 
 static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
@@ -1252,9 +1252,9 @@ static inline int dsi_if_enable(struct platform_device *dsidev, bool enable)
 	enable = enable ? 1 : 0;
 	REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
 
-	if (wait_for_bit_change(dsidev, DSI_CTRL, 0, enable) != enable) {
-			DSSERR("Failed to set dsi_if_enable to %d\n", enable);
-			return -EIO;
+	if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
+		DSSERR("Failed to set dsi_if_enable to %d\n", enable);
+		return -EIO;
 	}
 
 	return 0;
@@ -1441,7 +1441,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
 	/* XXX PLL does not come out of reset without this... */
 	dispc_pck_free_enable(1);
 
-	if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
 		DSSERR("PLL not coming out of reset.\n");
 		r = -ENODEV;
 		dispc_pck_free_enable(0);
@@ -2187,7 +2187,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	 * I/O. */
 	dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
 
-	if (wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
 		DSSERR("CIO SCP Clock domain not coming out of reset.\n");
 		r = -EIO;
 		goto err_scp_clk_dom;
@@ -2235,7 +2235,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 	if (r)
 		goto err_cio_pwr;
 
-	if (wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1) != 1) {
+	if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
 		DSSERR("CIO PWR clock domain not coming out of reset.\n");
 		r = -ENODEV;
 		goto err_cio_pwr_dom;
@@ -2376,7 +2376,7 @@ static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev)
 	r = FLD_MOD(r, 1, 15, 15);	/* FORCE_TX_STOP_MODE_IO */
 	dsi_write_reg(dsidev, DSI_TIMING1, r);
 
-	if (wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0) != 0) {
+	if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
 		DSSERR("TX_STOP bit not going down\n");
 		return -EIO;
 	}
@@ -2518,10 +2518,9 @@ static int dsi_vc_enable(struct platform_device *dsidev, int channel,
 
 	REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
 
-	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel),
-		0, enable) != enable) {
-			DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
-			return -EIO;
+	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
+		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
+		return -EIO;
 	}
 
 	return 0;
@@ -2573,7 +2572,7 @@ static int dsi_vc_config_source(struct platform_device *dsidev, int channel,
 	dsi_vc_enable(dsidev, channel, 0);
 
 	/* VC_BUSY */
-	if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0) != 0) {
+	if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0)) {
 		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
 		return -EIO;
 	}
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-02-11 13:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-11 13:07 [PATCH v2 00/15] omapdrm: Miscellaneous fixes and cleanups Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 01/15] drm: omapdrm: Use kernel integer types Laurent Pinchart
2018-02-12  6:46   ` Tomi Valkeinen
2018-02-12  6:51     ` Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 02/15] drm: omapdrm: Use unsigned int type Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 03/15] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 04/15] drm: omapdrm: displays: Remove OF node check in connector drivers Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 05/15] drm: omapdrm: displays: Remove OF node check in encoder drivers Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 06/15] drm: omapdrm: displays: Remove OF node check in panel drivers Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 07/15] drm: omapdrm: displays: Get connector source at connect time Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 08/15] drm: omapdrm: displays: Get panel " Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 09/15] drm: omapdrm: displays: Get encoder " Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 10/15] drm: omapdrm: dss: Make omapdss_default_get_timings static Laurent Pinchart
2018-02-11 17:03   ` Sebastian Reichel
2018-02-11 13:07 ` [PATCH v2 11/15] drm: omapdrm: dss: Don't export functions internal to omapdss-base Laurent Pinchart
2018-02-11 17:07   ` Sebastian Reichel
2018-02-11 13:07 ` [PATCH v2 12/15] drm: omapdrm: dss: Move initialization code from component bind to probe Laurent Pinchart
2018-02-11 17:19   ` Sebastian Reichel
2018-02-11 13:07 ` [PATCH v2 13/15] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function Laurent Pinchart
2018-02-11 13:07 ` [PATCH v2 14/15] drm: omapdrm: dss: Remove unused functions prototypes Laurent Pinchart
2018-02-11 13:07 ` Laurent Pinchart [this message]
2018-02-12  7:08 ` [PATCH v2 00/15] omapdrm: Miscellaneous fixes and cleanups Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180211130747.13420-16-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.