diff mbox series

[next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of |

Message ID 20200616115125.74298-1-colin.king@canonical.com
State Not Applicable
Headers show
Series [next] mtd: rawnand: qcom: fix incorrect masking operator, used & instead of | | expand

Commit Message

Colin Ian King June 16, 2020, 11:51 a.m. UTC
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(-)

Comments

Miquel Raynal June 16, 2020, 12:57 p.m. UTC | #1
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
Colin Ian King June 16, 2020, 1:04 p.m. UTC | #2
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
diff mbox series

Patch

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);