2022-03-02 21:40:23

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [RESEND PATCH v2 4/6] nfc: llcp: use test_bit()

Use test_bit() instead of open-coding it, just like in other places
touching the bitmap.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
net/nfc/llcp_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 5ad5157aa9c5..b70d5042bf74 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -383,7 +383,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
pr_debug("WKS %d\n", ssap);

/* This is a WKS, let's check if it's free */
- if (local->local_wks & BIT(ssap)) {
+ if (test_bit(ssap, &local->local_wks)) {
mutex_unlock(&local->sdp_lock);

return LLCP_SAP_MAX;
--
2.32.0


2022-03-03 00:48:48

by David Laight

[permalink] [raw]
Subject: RE: [RESEND PATCH v2 4/6] nfc: llcp: use test_bit()

From: Krzysztof Kozlowski
> Sent: 02 March 2022 19:25
>
> Use test_bit() instead of open-coding it, just like in other places
> touching the bitmap.

Except it isn't a bitmap, it is just a structure member that contains bits.
So all the other places should be changes to use C shifts and masks (etc).

David

>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> net/nfc/llcp_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
> index 5ad5157aa9c5..b70d5042bf74 100644
> --- a/net/nfc/llcp_core.c
> +++ b/net/nfc/llcp_core.c
> @@ -383,7 +383,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
> pr_debug("WKS %d\n", ssap);
>
> /* This is a WKS, let's check if it's free */
> - if (local->local_wks & BIT(ssap)) {
> + if (test_bit(ssap, &local->local_wks)) {
> mutex_unlock(&local->sdp_lock);
>
> return LLCP_SAP_MAX;
> --
> 2.32.0

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

2022-03-03 13:33:49

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [RESEND PATCH v2 4/6] nfc: llcp: use test_bit()

On 03/03/2022 01:10, David Laight wrote:
> From: Krzysztof Kozlowski
>> Sent: 02 March 2022 19:25
>>
>> Use test_bit() instead of open-coding it, just like in other places
>> touching the bitmap.
>
> Except it isn't a bitmap, it is just a structure member that contains bits.
> So all the other places should be changes to use C shifts and masks (etc).
>

It's not declared as bitmap but it is unsigned long, so an appropriate
type (and same type) for test_bit.


Best regards,
Krzysztof