kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of |
@ 2020-06-16 11:51 Colin King
  2020-06-16 12:57 ` Miquel Raynal
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2020-06-16 11:51 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, linux-mtd
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the expression (nand_ctrl | BAM_MODE_EN) is always true no
matter the value of nand_ctrl because the incorrect masking operator
is being used.  Fix this by using bit-wise & instead of |.

Addresses-Coverity: ("Wrong operator used")
Fixes: dd0c1fc8de12 ("mtd: rawnand: qcom: set BAM mode only if not set already")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index a3ef4288be27..37d95532ba7e 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2790,7 +2790,7 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
 		 * only if it is not in BAM mode. In most cases BAM
 		 * mode will be enabled in bootloader
 		 */
-		if (!(nand_ctrl | BAM_MODE_EN))
+		if (!(nand_ctrl & BAM_MODE_EN))
 			nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN);
 	} else {
 		nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
-- 
2.27.0.rc0

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

* Re: [PATCH][next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of |
  2020-06-16 11:51 [PATCH][next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of | Colin King
@ 2020-06-16 12:57 ` Miquel Raynal
  2020-06-16 13:04   ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Miquel Raynal @ 2020-06-16 12:57 UTC (permalink / raw)
  To: Colin King; +Cc: Richard Weinberger, kernel-janitors, linux-mtd, linux-kernel

Hi Colin,

Colin King <colin.king@canonical.com> wrote on Tue, 16 Jun 2020
12:51:25 +0100:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the expression (nand_ctrl | BAM_MODE_EN) is always true no
> matter the value of nand_ctrl because the incorrect masking operator
> is being used.  Fix this by using bit-wise & instead of |.

I saw it when reviewing and marked it to solve before applying but it
looks like I forgot to do so. If you don't mind I'll merge this with
the original commit.

> 
> Addresses-Coverity: ("Wrong operator used")
> Fixes: dd0c1fc8de12 ("mtd: rawnand: qcom: set BAM mode only if not set already")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index a3ef4288be27..37d95532ba7e 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -2790,7 +2790,7 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
>  		 * only if it is not in BAM mode. In most cases BAM
>  		 * mode will be enabled in bootloader
>  		 */
> -		if (!(nand_ctrl | BAM_MODE_EN))
> +		if (!(nand_ctrl & BAM_MODE_EN))
>  			nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN);
>  	} else {
>  		nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);

Thanks,
Miquèl

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

* Re: [PATCH][next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of |
  2020-06-16 12:57 ` Miquel Raynal
@ 2020-06-16 13:04   ` Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2020-06-16 13:04 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Richard Weinberger, kernel-janitors, linux-mtd, linux-kernel

On 16/06/2020 13:57, Miquel Raynal wrote:
> Hi Colin,
> 
> Colin King <colin.king@canonical.com> wrote on Tue, 16 Jun 2020
> 12:51:25 +0100:
> 
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the expression (nand_ctrl | BAM_MODE_EN) is always true no
>> matter the value of nand_ctrl because the incorrect masking operator
>> is being used.  Fix this by using bit-wise & instead of |.
> 
> I saw it when reviewing and marked it to solve before applying but it
> looks like I forgot to do so. If you don't mind I'll merge this with
> the original commit.
> 
>>
>> Addresses-Coverity: ("Wrong operator used")
>> Fixes: dd0c1fc8de12 ("mtd: rawnand: qcom: set BAM mode only if not set already")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/mtd/nand/raw/qcom_nandc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
>> index a3ef4288be27..37d95532ba7e 100644
>> --- a/drivers/mtd/nand/raw/qcom_nandc.c
>> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
>> @@ -2790,7 +2790,7 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
>>  		 * only if it is not in BAM mode. In most cases BAM
>>  		 * mode will be enabled in bootloader
>>  		 */
>> -		if (!(nand_ctrl | BAM_MODE_EN))
>> +		if (!(nand_ctrl & BAM_MODE_EN))
>>  			nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN);
>>  	} else {
>>  		nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
> 
> Thanks,
> Miquèl
> 

Sure merge it.

Colin

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

end of thread, other threads:[~2020-06-16 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 11:51 [PATCH][next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of | Colin King
2020-06-16 12:57 ` Miquel Raynal
2020-06-16 13:04   ` Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).