linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Ajay Gupta <ajaykuee@gmail.com>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
	linux-i2c@vger.kernel.org, Ajay Gupta <ajayg@nvidia.com>
Subject: Re: [PATCH 1/4] i2c: nvidia-gpu: add runtime pm support
Date: Sun, 19 May 2019 16:47:04 +0200	[thread overview]
Message-ID: <20190519144704.GB7291@kunai> (raw)
In-Reply-To: <20190517163818.5007-2-ajayg@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

> diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
> index 1c8f708f212b..9d347583f8dc 100644
> --- a/drivers/i2c/busses/i2c-nvidia-gpu.c
> +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
> @@ -175,6 +175,7 @@ static int gpu_i2c_master_xfer(struct i2c_adapter *adap,
>  	 * The controller supports maximum 4 byte read due to known
>  	 * limitation of sending STOP after every read.
>  	 */
> +	pm_runtime_get_sync(i2cd->dev);
>  	for (i = 0; i < num; i++) {
>  		if (msgs[i].flags & I2C_M_RD) {
>  			/* program client address before starting read */
> @@ -189,7 +190,7 @@ static int gpu_i2c_master_xfer(struct i2c_adapter *adap,
>  			status = gpu_i2c_start(i2cd);
>  			if (status < 0) {
>  				if (i == 0)
> -					return status;
> +					goto exit;
>  				goto stop;

Hmm, goto here, goto there... OK, the code didn't have a good flow even
before this patch.

>  			}
>  
> @@ -206,13 +207,18 @@ static int gpu_i2c_master_xfer(struct i2c_adapter *adap,
>  	}
>  	status = gpu_i2c_stop(i2cd);
>  	if (status < 0)
> -		return status;
> +		goto exit;
>  
> +	pm_runtime_mark_last_busy(i2cd->dev);
> +	pm_runtime_put_autosuspend(i2cd->dev);
>  	return i;
>  stop:
>  	status2 = gpu_i2c_stop(i2cd);
>  	if (status2 < 0)
>  		dev_err(i2cd->dev, "i2c stop failed %d\n", status2);
> +exit:
> +	pm_runtime_mark_last_busy(i2cd->dev);
> +	pm_runtime_put_autosuspend(i2cd->dev);
>  	return status;
>  }

I am not nacking this, yet the use of goto here seems too much for my
taste. If you could try refactoring the whole code (dunno, maybe using a
flag when to use stop?), I'd appreciate this.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-05-19 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 16:38 [PATCH 0/4] usb: typec: ucsi: ccg: add runtime pm support Ajay Gupta
2019-05-17 16:38 ` [PATCH 1/4] i2c: nvidia-gpu: " Ajay Gupta
2019-05-19 14:47   ` Wolfram Sang [this message]
2019-05-20 17:02     ` Ajay Gupta
2019-05-20 17:17       ` Wolfram Sang
2019-05-17 16:38 ` [PATCH 2/4] usb: typec: ucsi: ccg: enable " Ajay Gupta
2019-05-17 16:38 ` [PATCH 3/4] i2c: nvidia-gpu: resume ccgx i2c client Ajay Gupta
2019-05-19 14:48   ` Wolfram Sang
2019-05-20 17:08     ` Ajay Gupta
2019-05-17 16:38 ` [PATCH 4/4] usb: typec: ucsi: ccg: add runtime pm workaround Ajay Gupta

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=20190519144704.GB7291@kunai \
    --to=wsa@the-dreams.de \
    --cc=ajayg@nvidia.com \
    --cc=ajaykuee@gmail.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-usb@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).