All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libmtd: don't print an error message for devices without ecc support
@ 2018-09-19  8:29 David Oberhollenzer
  2018-09-19 21:45 ` Chris Packham
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-09-19  8:29 UTC (permalink / raw)
  To: linux-mtd; +Cc: Chris.Packham, xiaolei.li, David Oberhollenzer

The libmtd library tries to obtain the available OOB size via the sysfs
with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram),
the fallback path is always taken and prints an error message to stderr
since the ioctl fails.

This patch fixes the fallback path by suppressing the error message if
errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that).

Fixes: a10353584f93 ("libmtd: Add support to access OOB available size")
Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 lib/libmtd_legacy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index 97fef04..2b7f65f 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -235,6 +235,8 @@ int legacy_get_mtd_oobavail(const char *node)
 
 	ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
 	if (ret < 0) {
+		if (errno == EOPNOTSUPP)
+			goto out_close;
 		sys_errmsg("ECCGETLAYOUT ioctl request failed");
 		goto out_close;
 	}
-- 
2.17.1

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

* Re: [PATCH] libmtd: don't print an error message for devices without ecc support
  2018-09-19  8:29 [PATCH] libmtd: don't print an error message for devices without ecc support David Oberhollenzer
@ 2018-09-19 21:45 ` Chris Packham
  2018-09-20  0:59 ` xiaolei li
  2018-10-02 12:06 ` David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2018-09-19 21:45 UTC (permalink / raw)
  To: David Oberhollenzer, linux-mtd; +Cc: xiaolei.li

Hi David,

On 19/09/18 20:39, David Oberhollenzer wrote:
> The libmtd library tries to obtain the available OOB size via the sysfs
> with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram),
> the fallback path is always taken and prints an error message to stderr
> since the ioctl fails.
> 
> This patch fixes the fallback path by suppressing the error message if
> errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that).
> 
> Fixes: a10353584f93 ("libmtd: Add support to access OOB available size")
> Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>

Thanks for the fix. Works well for me on nand, spi-nor and plat-ram

Tested-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>

> ---
>   lib/libmtd_legacy.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
> index 97fef04..2b7f65f 100644
> --- a/lib/libmtd_legacy.c
> +++ b/lib/libmtd_legacy.c
> @@ -235,6 +235,8 @@ int legacy_get_mtd_oobavail(const char *node)
>   
>   	ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
>   	if (ret < 0) {
> +		if (errno == EOPNOTSUPP)
> +			goto out_close;
>   		sys_errmsg("ECCGETLAYOUT ioctl request failed");
>   		goto out_close;
>   	}
> 

By the way, the incoming email got flagged by my IS department. Not sure 
if that's a false positive or something you need to bring to the 
attention of whomever runs your email infrastructure. Let me know if you 
want a copy of the original.

 >
 > *** This email message may be dodgy ***
 >
 > The sending domain's SPF record was checked to try and prove if it 
was sent by an authorised host. The sender's SPF record is invalid so 
the sending host could not be validated.
 > This could be for one or more of several reasons -
 > 	The sending domain has more that one SPF record. (max=1)
 > 	The sending domains SPF record has bad syntax.
 > 	The sending domains SPF record requires too many DNS lookups. (max=10)
 >
 > If the email is genuine, the sender should be notified of this issue 
so that they can report it to their IS team.
 >
 > ATLNZ IS
 >
 >

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

* Re: [PATCH] libmtd: don't print an error message for devices without ecc support
  2018-09-19  8:29 [PATCH] libmtd: don't print an error message for devices without ecc support David Oberhollenzer
  2018-09-19 21:45 ` Chris Packham
@ 2018-09-20  0:59 ` xiaolei li
  2018-10-02 12:06 ` David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: xiaolei li @ 2018-09-20  0:59 UTC (permalink / raw)
  To: David Oberhollenzer; +Cc: linux-mtd, Chris.Packham

Hi David,

Thanks.

Reviewed-by: Xiaolei Li <xiaolei.li@mediatek.com>

On Wed, 2018-09-19 at 10:29 +0200, David Oberhollenzer wrote:
> The libmtd library tries to obtain the available OOB size via the sysfs
> with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram),
> the fallback path is always taken and prints an error message to stderr
> since the ioctl fails.
> 
> This patch fixes the fallback path by suppressing the error message if
> errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that).
> 
> Fixes: a10353584f93 ("libmtd: Add support to access OOB available size")
> Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
> ---
>  lib/libmtd_legacy.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
> index 97fef04..2b7f65f 100644
> --- a/lib/libmtd_legacy.c
> +++ b/lib/libmtd_legacy.c
> @@ -235,6 +235,8 @@ int legacy_get_mtd_oobavail(const char *node)
>  
>  	ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
>  	if (ret < 0) {
> +		if (errno == EOPNOTSUPP)
> +			goto out_close;
>  		sys_errmsg("ECCGETLAYOUT ioctl request failed");
>  		goto out_close;
>  	}

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

* Re: [PATCH] libmtd: don't print an error message for devices without ecc support
  2018-09-19  8:29 [PATCH] libmtd: don't print an error message for devices without ecc support David Oberhollenzer
  2018-09-19 21:45 ` Chris Packham
  2018-09-20  0:59 ` xiaolei li
@ 2018-10-02 12:06 ` David Oberhollenzer
  2 siblings, 0 replies; 4+ messages in thread
From: David Oberhollenzer @ 2018-10-02 12:06 UTC (permalink / raw)
  To: linux-mtd; +Cc: Chris.Packham, xiaolei.li

Applied to mtd-utils.git master

David

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

end of thread, other threads:[~2018-10-02 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19  8:29 [PATCH] libmtd: don't print an error message for devices without ecc support David Oberhollenzer
2018-09-19 21:45 ` Chris Packham
2018-09-20  0:59 ` xiaolei li
2018-10-02 12:06 ` David Oberhollenzer

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.