public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-mtd@lists.infradead.org
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
	Richard Weinberger <richard@nod.at>,
	linux-kernel@vger.kernel.org,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 2/3] mtd: use min_t() to refactor mtd_ooblayout_{get, set}_bytes()
Date: Sat, 12 Nov 2016 22:27:47 +0100	[thread overview]
Message-ID: <b1d59ca4-17c1-872e-fe2e-1471ebd678a4@gmail.com> (raw)
In-Reply-To: <1478657290-9430-3-git-send-email-yamada.masahiro@socionext.com>

On 11/09/2016 03:08 AM, Masahiro Yamada wrote:
> I hope this will make the code a little more readable.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Marek Vasut <marek.vasut@gmail.com>

> ---
> 
>  drivers/mtd/mtdcore.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index cf85f2b..ca6a89a 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1283,7 +1283,7 @@ static int mtd_ooblayout_get_bytes(struct mtd_info *mtd, u8 *buf,
>  	while (!ret) {
>  		int cnt;
>  
> -		cnt = oobregion.length > nbytes ? nbytes : oobregion.length;
> +		cnt = min_t(int, nbytes, oobregion.length);
>  		memcpy(buf, oobbuf + oobregion.offset, cnt);
>  		buf += cnt;
>  		nbytes -= cnt;
> @@ -1326,7 +1326,7 @@ static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf,
>  	while (!ret) {
>  		int cnt;
>  
> -		cnt = oobregion.length > nbytes ? nbytes : oobregion.length;
> +		cnt = min_t(int, nbytes, oobregion.length);
>  		memcpy(oobbuf + oobregion.offset, buf, cnt);
>  		buf += cnt;
>  		nbytes -= cnt;
> 


-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-11-12 21:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09  2:08 [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs Masahiro Yamada
2016-11-09  2:08 ` [PATCH 1/3] mtd: remove unneeded initializer in mtd_ooblayout_{get, set}_bytes() Masahiro Yamada
2016-11-12 21:25   ` Marek Vasut
2016-11-09  2:08 ` [PATCH 2/3] mtd: use min_t() to refactor " Masahiro Yamada
2016-11-12 21:27   ` Marek Vasut [this message]
2016-11-09  2:08 ` [PATCH 3/3] mtd: remove unneeded initializer in mtd_ooblayout_count_bytes() Masahiro Yamada
2016-11-12 21:28   ` Marek Vasut
2016-11-20  9:42 ` [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs Boris Brezillon

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=b1d59ca4-17c1-872e-fe2e-1471ebd678a4@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=yamada.masahiro@socionext.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox