public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Daniel Kurtz <djkurtz@chromium.org>
Cc: Keith Packard <keithp@keithp.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Benson Leung <bleung@chromium.org>,
	Yufeng Shen <miletus@chromium.org>
Subject: Re: [PATCH 01/11 v3] drm/i915/intel_i2c: cleanup
Date: Mon, 26 Mar 2012 17:29:35 +0200	[thread overview]
Message-ID: <20120326152935.GW4014@phenom.ffwll.local> (raw)
In-Reply-To: <1332772010-19619-2-git-send-email-djkurtz@chromium.org>

On Mon, Mar 26, 2012 at 10:26:40PM +0800, Daniel Kurtz wrote:
> 80 col, spaces around operators and other basic cleanup.
> Some info message cleanup.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

On reconsideration, nacked. You desperately try to squeeze a function with
already 5 indent levels (not counting indentation due to function
arguments and overflow) with already 100+ lines of code into 80 columns.

Please do the right thing and split out a few of helper functions. I
suggest you split out the read and write code, i.e.

if (msgs[i].flags & I2C_M_RD)
	gmbus_xfer_read()
else
	gmbus_xfer_write

This way you get 3 levels of tab space of room and I won't have to
complain as much that some of your later patches make gmbus_xfer way too
bug.

Yours, Daniel

> ---
>  drivers/gpu/drm/i915/intel_i2c.c |   32 +++++++++++++++++++++-----------
>  1 files changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
> index 0713cc2..86b1861 100644
> --- a/drivers/gpu/drm/i915/intel_i2c.c
> +++ b/drivers/gpu/drm/i915/intel_i2c.c
> @@ -230,13 +230,16 @@ gmbus_xfer(struct i2c_adapter *adapter,
>  				   (len << GMBUS_BYTE_COUNT_SHIFT) |
>  				   (msgs[i].addr << GMBUS_SLAVE_ADDR_SHIFT) |
>  				   GMBUS_SLAVE_READ | GMBUS_SW_RDY);
> -			POSTING_READ(GMBUS2+reg_offset);
> +			POSTING_READ(GMBUS2 + reg_offset);
>  			do {
>  				u32 val, loop = 0;
>  
> -				if (wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_RDY), 50))
> +				if (wait_for(I915_READ(GMBUS2 + reg_offset) &
> +					     (GMBUS_SATOER | GMBUS_HW_RDY),
> +					     50))
>  					goto timeout;
> -				if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
> +				if (I915_READ(GMBUS2 + reg_offset) &
> +				    GMBUS_SATOER)
>  					goto clear_err;
>  
>  				val = I915_READ(GMBUS3 + reg_offset);
> @@ -260,12 +263,15 @@ gmbus_xfer(struct i2c_adapter *adapter,
>  				   (msgs[i].len << GMBUS_BYTE_COUNT_SHIFT) |
>  				   (msgs[i].addr << GMBUS_SLAVE_ADDR_SHIFT) |
>  				   GMBUS_SLAVE_WRITE | GMBUS_SW_RDY);
> -			POSTING_READ(GMBUS2+reg_offset);
> +			POSTING_READ(GMBUS2 + reg_offset);
>  
>  			while (len) {
> -				if (wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_RDY), 50))
> +				if (wait_for(I915_READ(GMBUS2 + reg_offset) &
> +					     (GMBUS_SATOER | GMBUS_HW_RDY),
> +					     50))
>  					goto timeout;
> -				if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
> +				if (I915_READ(GMBUS2 + reg_offset) &
> +				    GMBUS_SATOER)
>  					goto clear_err;
>  
>  				val = loop = 0;
> @@ -274,11 +280,14 @@ gmbus_xfer(struct i2c_adapter *adapter,
>  				} while (--len && ++loop < 4);
>  
>  				I915_WRITE(GMBUS3 + reg_offset, val);
> -				POSTING_READ(GMBUS2+reg_offset);
> +				POSTING_READ(GMBUS2 + reg_offset);
>  			}
>  		}
>  
> -		if (i + 1 < num && wait_for(I915_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_WAIT_PHASE), 50))
> +		if (i + 1 < num &&
> +		    wait_for(I915_READ(GMBUS2 + reg_offset) &
> +			     (GMBUS_SATOER | GMBUS_HW_WAIT_PHASE),
> +			     50))
>  			goto timeout;
>  		if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
>  			goto clear_err;
> @@ -300,14 +309,15 @@ done:
>  	 * till then let it sleep.
>  	 */
>  	if (wait_for((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0, 10))
> -		DRM_INFO("GMBUS timed out waiting for idle\n");
> +		DRM_INFO("GMBUS [%s] timed out waiting for idle\n",
> +			 bus->adapter.name);
>  	I915_WRITE(GMBUS0 + reg_offset, 0);
>  	ret = i;
>  	goto out;
>  
>  timeout:
> -	DRM_INFO("GMBUS timed out, falling back to bit banging on pin %d [%s]\n",
> -		 bus->reg0 & 0xff, bus->adapter.name);
> +	DRM_INFO("GMBUS [%s] timed out, falling back to bit banging on pin %d\n",
> +		 bus->adapter.name, bus->reg0 & 0xff);
>  	I915_WRITE(GMBUS0 + reg_offset, 0);
>  
>  	/* Hardware may not support GMBUS over these pins? Try GPIO bitbanging instead. */
> -- 
> 1.7.7.3
> 

-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2012-03-26 15:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 14:26 [PATCH 00/11 v3] fix gmbus writes and related issues Daniel Kurtz
2012-03-26 14:26 ` [PATCH 01/11 v3] drm/i915/intel_i2c: cleanup Daniel Kurtz
2012-03-26 15:29   ` Daniel Vetter [this message]
2012-03-26 14:26 ` [PATCH 02/11 v3] drm/i915/intel_i2c: assign HDMI port D to pin pair 6 Daniel Kurtz
2012-03-26 14:47   ` Daniel Vetter
2012-03-26 15:08     ` Daniel Vetter
2012-03-26 17:49       ` Daniel Kurtz
2012-03-27  7:54         ` Daniel Vetter
2012-03-26 14:26 ` [PATCH 03/11 v3] drm/i915/intel_i2c: use i2c pre/post_xfer functions to setup gpio xfers Daniel Kurtz
2012-03-26 14:49   ` Daniel Vetter
2012-03-26 17:58     ` Daniel Kurtz
2012-03-26 19:06       ` Daniel Vetter
2012-03-26 14:26 ` [PATCH 04/11 v3] drm/i915/intel_i2c: cleanup gmbus/gpio pin assignments Daniel Kurtz
2012-03-26 15:10   ` Daniel Vetter
2012-03-26 15:20   ` Daniel Vetter
2012-03-26 14:26 ` [PATCH 05/11 v3] drm/i915/intel_i2c: allocate gmbus array as part of drm_i915_private Daniel Kurtz
2012-03-26 15:10   ` Daniel Vetter
2012-03-26 15:20   ` Daniel Vetter
2012-03-26 14:26 ` [PATCH 06/11 v3] drm/i915/intel_i2c: refactor using intel_gmbus_get_adapter Daniel Kurtz
2012-03-26 15:22   ` Daniel Vetter
2012-03-26 14:26 ` [PATCH 07/11 v3] drm/i915/intel_i2c: handle zero-length writes Daniel Kurtz
2012-03-26 14:26 ` [PATCH 08/11 v3] drm/i915/intel_i2c: always wait for IDLE before clearing NAK Daniel Kurtz
2012-03-26 14:26 ` [PATCH 09/11 v3] drm/i915/intel_i2c: use WAIT cycle, not STOP Daniel Kurtz
2012-03-26 14:26 ` [PATCH 10/11 v3] drm/i915/intel_i2c: use INDEX cycles for i2c read transactions Daniel Kurtz
2012-03-26 14:26 ` [PATCH 11/11 v3] drm/i915/intel_i2c: reuse GMBUS2 value read in polling loop Daniel Kurtz
2012-03-26 15:33 ` [PATCH 00/11 v3] fix gmbus writes and related issues Daniel Vetter

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=20120326152935.GW4014@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=bleung@chromium.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=djkurtz@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=keithp@keithp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miletus@chromium.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox