2020-04-24 12:31:55

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH net-next v2] ptp: clockmatrix: remove unnecessary comparison

The type of loaddr is u8 which is always '<=' 0xff, so the
loaddr <= 0xff is always true, we can remove this comparison.

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Yang Yingliang <[email protected]>
---
drivers/ptp/ptp_clockmatrix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 032e112..56aee4f 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -780,7 +780,7 @@ static int idtcm_load_firmware(struct idtcm *idtcm,

/* Page size 128, last 4 bytes of page skipped */
if (((loaddr > 0x7b) && (loaddr <= 0x7f))
- || ((loaddr > 0xfb) && (loaddr <= 0xff)))
+ || loaddr > 0xfb)
continue;

err = idtcm_write(idtcm, regaddr, 0, &val, sizeof(val));
--
1.8.3


2020-04-24 13:24:40

by Vincent Cheng

[permalink] [raw]
Subject: Re: [PATCH net-next v2] ptp: clockmatrix: remove unnecessary comparison

>Reported-by: Hulk Robot <[email protected]>
>Signed-off-by: Yang Yingliang <[email protected]>
>---
> drivers/ptp/ptp_clockmatrix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
>index 032e112..56aee4f 100644
>--- a/drivers/ptp/ptp_clockmatrix.c
>+++ b/drivers/ptp/ptp_clockmatrix.c
>@@ -780,7 +780,7 @@ static int idtcm_load_firmware(struct idtcm *idtcm,
>
> /* Page size 128, last 4 bytes of page skipped */
> if (((loaddr > 0x7b) && (loaddr <= 0x7f))
>- || ((loaddr > 0xfb) && (loaddr <= 0xff)))
>+ || loaddr > 0xfb)
> continue;
>
> err = idtcm_write(idtcm, regaddr, 0, &val, sizeof(val));

Thank-you for the fix.

Reviewed-by: Vincent Cheng <[email protected]>

2020-04-26 03:43:52

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v2] ptp: clockmatrix: remove unnecessary comparison

From: Yang Yingliang <[email protected]>
Date: Fri, 24 Apr 2020 20:52:26 +0800

> The type of loaddr is u8 which is always '<=' 0xff, so the
> loaddr <= 0xff is always true, we can remove this comparison.
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Yang Yingliang <[email protected]>

Applied.