public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs
@ 2016-11-09  2:08 Masahiro Yamada
  2016-11-09  2:08 ` [PATCH 1/3] mtd: remove unneeded initializer in mtd_ooblayout_{get, set}_bytes() Masahiro Yamada
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Masahiro Yamada @ 2016-11-09  2:08 UTC (permalink / raw)
  To: linux-mtd
  Cc: Masahiro Yamada, linux-kernel, Boris Brezillon, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse,
	Cyrille Pitchen

 - Remove unnecessary initializers
 - Use min_t() helper

Masahiro Yamada (3):
  mtd: remove unneeded initializer in mtd_ooblayout_{get,set}_bytes()
  mtd: use min_t() to refactor mtd_ooblayout_{get,set}_bytes()
  mtd: remove unneeded initializer in mtd_ooblayout_count_bytes()

 drivers/mtd/mtdcore.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] mtd: remove unneeded initializer in mtd_ooblayout_{get, set}_bytes()
  2016-11-09  2:08 [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs Masahiro Yamada
@ 2016-11-09  2:08 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2016-11-09  2:08 UTC (permalink / raw)
  To: linux-mtd
  Cc: Masahiro Yamada, linux-kernel, Boris Brezillon, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse,
	Cyrille Pitchen

There is no need to initialize oobregion and section since they will
be filled by mtd_ooblayout_find_region().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mtd/mtdcore.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index d46e4ad..cf85f2b 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1274,8 +1274,8 @@ static int mtd_ooblayout_get_bytes(struct mtd_info *mtd, u8 *buf,
 					    int section,
 					    struct mtd_oob_region *oobregion))
 {
-	struct mtd_oob_region oobregion = { };
-	int section = 0, ret;
+	struct mtd_oob_region oobregion;
+	int section, ret;
 
 	ret = mtd_ooblayout_find_region(mtd, start, &section,
 					&oobregion, iter);
@@ -1317,8 +1317,8 @@ static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf,
 					    int section,
 					    struct mtd_oob_region *oobregion))
 {
-	struct mtd_oob_region oobregion = { };
-	int section = 0, ret;
+	struct mtd_oob_region oobregion;
+	int section, ret;
 
 	ret = mtd_ooblayout_find_region(mtd, start, &section,
 					&oobregion, iter);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] mtd: use min_t() to refactor mtd_ooblayout_{get, set}_bytes()
  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-09  2:08 ` Masahiro Yamada
  2016-11-12 21:27   ` Marek Vasut
  2016-11-09  2:08 ` [PATCH 3/3] mtd: remove unneeded initializer in mtd_ooblayout_count_bytes() Masahiro Yamada
  2016-11-20  9:42 ` [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs Boris Brezillon
  3 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2016-11-09  2:08 UTC (permalink / raw)
  To: linux-mtd
  Cc: Masahiro Yamada, linux-kernel, Boris Brezillon, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse,
	Cyrille Pitchen

I hope this will make the code a little more readable.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.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;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] mtd: remove unneeded initializer in mtd_ooblayout_count_bytes()
  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-09  2:08 ` [PATCH 2/3] mtd: use min_t() to refactor " Masahiro Yamada
@ 2016-11-09  2:08 ` 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
  3 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2016-11-09  2:08 UTC (permalink / raw)
  To: linux-mtd
  Cc: Masahiro Yamada, linux-kernel, Boris Brezillon, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse,
	Cyrille Pitchen

There is no need to initialize oobregion since it will be filled by
the iterator.

This function is called with mtd_ooblayout_free or mtd_ooblayout_ecc
for the iterator; both of them calls memset() to clear the oobregion.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mtd/mtdcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index ca6a89a..ca661ce 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1354,7 +1354,7 @@ static int mtd_ooblayout_count_bytes(struct mtd_info *mtd,
 					    int section,
 					    struct mtd_oob_region *oobregion))
 {
-	struct mtd_oob_region oobregion = { };
+	struct mtd_oob_region oobregion;
 	int section = 0, ret, nbytes = 0;
 
 	while (1) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mtd: remove unneeded initializer in mtd_ooblayout_{get, set}_bytes()
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2016-11-12 21:25 UTC (permalink / raw)
  To: Masahiro Yamada, linux-mtd
  Cc: Boris Brezillon, Richard Weinberger, linux-kernel,
	Cyrille Pitchen, Brian Norris, David Woodhouse

On 11/09/2016 03:08 AM, Masahiro Yamada wrote:
> There is no need to initialize oobregion and section since they will
> be filled by mtd_ooblayout_find_region().
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

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

> ---
> 
>  drivers/mtd/mtdcore.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index d46e4ad..cf85f2b 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1274,8 +1274,8 @@ static int mtd_ooblayout_get_bytes(struct mtd_info *mtd, u8 *buf,
>  					    int section,
>  					    struct mtd_oob_region *oobregion))
>  {
> -	struct mtd_oob_region oobregion = { };
> -	int section = 0, ret;
> +	struct mtd_oob_region oobregion;
> +	int section, ret;
>  
>  	ret = mtd_ooblayout_find_region(mtd, start, &section,
>  					&oobregion, iter);
> @@ -1317,8 +1317,8 @@ static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf,
>  					    int section,
>  					    struct mtd_oob_region *oobregion))
>  {
> -	struct mtd_oob_region oobregion = { };
> -	int section = 0, ret;
> +	struct mtd_oob_region oobregion;
> +	int section, ret;
>  
>  	ret = mtd_ooblayout_find_region(mtd, start, &section,
>  					&oobregion, iter);
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mtd: use min_t() to refactor mtd_ooblayout_{get, set}_bytes()
  2016-11-09  2:08 ` [PATCH 2/3] mtd: use min_t() to refactor " Masahiro Yamada
@ 2016-11-12 21:27   ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2016-11-12 21:27 UTC (permalink / raw)
  To: Masahiro Yamada, linux-mtd
  Cc: Boris Brezillon, Richard Weinberger, linux-kernel,
	Cyrille Pitchen, Brian Norris, David Woodhouse

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] mtd: remove unneeded initializer in mtd_ooblayout_count_bytes()
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2016-11-12 21:28 UTC (permalink / raw)
  To: Masahiro Yamada, linux-mtd
  Cc: Boris Brezillon, Richard Weinberger, linux-kernel,
	Cyrille Pitchen, Brian Norris, David Woodhouse

On 11/09/2016 03:08 AM, Masahiro Yamada wrote:
> There is no need to initialize oobregion since it will be filled by
> the iterator.
> 
> This function is called with mtd_ooblayout_free or mtd_ooblayout_ecc
> for the iterator; both of them calls memset() to clear the oobregion.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

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

> ---
> 
>  drivers/mtd/mtdcore.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index ca6a89a..ca661ce 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1354,7 +1354,7 @@ static int mtd_ooblayout_count_bytes(struct mtd_info *mtd,
>  					    int section,
>  					    struct mtd_oob_region *oobregion))
>  {
> -	struct mtd_oob_region oobregion = { };
> +	struct mtd_oob_region oobregion;
>  	int section = 0, ret, nbytes = 0;
>  
>  	while (1) {
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs
  2016-11-09  2:08 [PATCH 0/3] mtd: some minor cleanups for ooblayout APIs Masahiro Yamada
                   ` (2 preceding siblings ...)
  2016-11-09  2:08 ` [PATCH 3/3] mtd: remove unneeded initializer in mtd_ooblayout_count_bytes() Masahiro Yamada
@ 2016-11-20  9:42 ` Boris Brezillon
  3 siblings, 0 replies; 8+ messages in thread
From: Boris Brezillon @ 2016-11-20  9:42 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mtd, linux-kernel, Marek Vasut, Brian Norris,
	Richard Weinberger, David Woodhouse, Cyrille Pitchen

On Wed,  9 Nov 2016 11:08:07 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

>  - Remove unnecessary initializers
>  - Use min_t() helper

Applied.

Thanks,

Boris

> 
> Masahiro Yamada (3):
>   mtd: remove unneeded initializer in mtd_ooblayout_{get,set}_bytes()
>   mtd: use min_t() to refactor mtd_ooblayout_{get,set}_bytes()
>   mtd: remove unneeded initializer in mtd_ooblayout_count_bytes()
> 
>  drivers/mtd/mtdcore.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-20  9:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox