All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH 4/7] eeprom: at24: simplify functions at24_read/write a little
Date: Fri, 1 Dec 2017 11:14:51 +0100	[thread overview]
Message-ID: <CAMRc=Mf6qmhC5P=UzgRop23W8dibouBARtOxUYhOgeSA4uVPMA@mail.gmail.com> (raw)
In-Reply-To: <1b2f8ac8-02ae-d615-8c23-6d90f52be555@gmail.com>

2017-11-30 7:49 GMT+01:00 Heiner Kallweit <hkallweit1@gmail.com>:
> Simplify functions at24_read/write a little.
>

Please be more specific in your commit message - it's not obvious at
first glance what you're actually simplifying.

Thanks,
Bartosz

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/misc/eeprom/at24.c | 40 ++++++++++++++++------------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index d56be71f1..837f1d88c 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -374,24 +374,20 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
>         mutex_lock(&at24->lock);
>
>         while (count) {
> -               int     status;
> +               ret = at24_regmap_read(at24, buf, off, count);
> +               if (ret < 0)
> +                       goto out;
>
> -               status = at24_regmap_read(at24, buf, off, count);
> -               if (status < 0) {
> -                       mutex_unlock(&at24->lock);
> -                       pm_runtime_put(&client->dev);
> -                       return status;
> -               }
> -               buf += status;
> -               off += status;
> -               count -= status;
> +               buf += ret;
> +               off += ret;
> +               count -= ret;
>         }
> -
> +out:
>         mutex_unlock(&at24->lock);
>
>         pm_runtime_put(&client->dev);
>
> -       return 0;
> +       return ret < 0 ? ret : 0;
>  }
>
>  static int at24_write(void *priv, unsigned int off, void *val, size_t count)
> @@ -424,24 +420,20 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
>         mutex_lock(&at24->lock);
>
>         while (count) {
> -               int status;
> +               ret = at24_regmap_write(at24, buf, off, count);
> +               if (ret < 0)
> +                       goto out;
>
> -               status = at24_regmap_write(at24, buf, off, count);
> -               if (status < 0) {
> -                       mutex_unlock(&at24->lock);
> -                       pm_runtime_put(&client->dev);
> -                       return status;
> -               }
> -               buf += status;
> -               off += status;
> -               count -= status;
> +               buf += ret;
> +               off += ret;
> +               count -= ret;
>         }
> -
> +out:
>         mutex_unlock(&at24->lock);
>
>         pm_runtime_put(&client->dev);
>
> -       return 0;
> +       return ret < 0 ? ret : 0;
>  }
>
>  static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip)
> --
> 2.15.0
>
>

  reply	other threads:[~2017-12-01 10:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30  6:40 [PATCH 0/7] eeprom: at24: series with smaller improvements Heiner Kallweit
2017-11-30  6:48 ` [PATCH 1/7] eeprom: at24: don't explicitely include header files which are implicitely included Heiner Kallweit
2017-11-30 15:56   ` Peter Rosin
2017-11-30 19:32     ` Heiner Kallweit
2017-12-01 10:09       ` Bartosz Golaszewski
2017-11-30  6:49 ` [PATCH 2/7] eeprom: at24: consider that SERIAL and MAC flags imply read-only Heiner Kallweit
2017-12-01 10:10   ` Bartosz Golaszewski
2017-12-02 22:00     ` Heiner Kallweit
2017-12-03 21:20       ` Bartosz Golaszewski
2017-11-30  6:49 ` [PATCH 3/7] eeprom: at24: simplify probe a little by replacing &client->dev Heiner Kallweit
2017-12-01 10:14   ` Bartosz Golaszewski
2017-11-30  6:49 ` [PATCH 4/7] eeprom: at24: simplify functions at24_read/write a little Heiner Kallweit
2017-12-01 10:14   ` Bartosz Golaszewski [this message]
2017-11-30  6:49 ` [PATCH 5/7] eeprom: at24: zero-initialize variable chip in probe Heiner Kallweit
2017-11-30  6:49 ` [PATCH 6/7] eeprom: at24: don't check chip.byte_len for power of two Heiner Kallweit
2017-11-30  6:49 ` [PATCH 7/7] eeprom: at24: don't check page_size for read-only chips and reorder checks Heiner Kallweit

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='CAMRc=Mf6qmhC5P=UzgRop23W8dibouBARtOxUYhOgeSA4uVPMA@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=hkallweit1@gmail.com \
    --cc=linux-i2c@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 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.