* [PATCH v1] staging: vme_user: replace (1 << n) with BIT(n)
@ 2025-12-06 6:36 Dharanitharan R
2025-12-06 10:10 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: Dharanitharan R @ 2025-12-06 6:36 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, Dharanitharan R
In drivers/staging/vme_user/vme.c, the functions vme_register_bridge()
and vme_unregister_bridge() use bit shifts like (1 << i) and
(1 << bridge->num) to manipulate vme_bus_numbers.
Replace these shifts with the BIT(n) macro for readability,
consistency, and kernel coding style.
Changes:
- vme_register_bridge(): (1 << i) → BIT(i)
- vme_unregister_bridge(): (1 << bridge->num) → BIT(bridge->num)
Signed-off-by: Dharanitharan R <dharanitharan725@gmail.com>
---
drivers/staging/vme_user/vme.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/vme_user/vme.c b/drivers/staging/vme_user/vme.c
index 2095de72596a..f62a94ef35fc 100644
--- a/drivers/staging/vme_user/vme.c
+++ b/drivers/staging/vme_user/vme.c
@@ -1766,8 +1766,8 @@ int vme_register_bridge(struct vme_bridge *bridge)
mutex_lock(&vme_buses_lock);
for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) {
- if ((vme_bus_numbers & (1 << i)) == 0) {
- vme_bus_numbers |= (1 << i);
+ if ((vme_bus_numbers & BIT(i)) == 0) {
+ vme_bus_numbers |= BIT(i);
bridge->num = i;
INIT_LIST_HEAD(&bridge->devices);
list_add_tail(&bridge->bus_list, &vme_bus_list);
@@ -1787,7 +1787,7 @@ void vme_unregister_bridge(struct vme_bridge *bridge)
struct vme_dev *tmp;
mutex_lock(&vme_buses_lock);
- vme_bus_numbers &= ~(1 << bridge->num);
+ vme_bus_numbers &= ~BIT(bridge->num);
list_for_each_entry_safe(vdev, tmp, &bridge->devices, bridge_list) {
list_del(&vdev->drv_list);
list_del(&vdev->bridge_list);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] staging: vme_user: replace (1 << n) with BIT(n)
2025-12-06 6:36 [PATCH v1] staging: vme_user: replace (1 << n) with BIT(n) Dharanitharan R
@ 2025-12-06 10:10 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2025-12-06 10:10 UTC (permalink / raw)
To: Dharanitharan R; +Cc: gregkh, linux-staging, linux-kernel
On Sat, 6 Dec 2025 06:36:19 +0000
Dharanitharan R <dharanitharan725@gmail.com> wrote:
> In drivers/staging/vme_user/vme.c, the functions vme_register_bridge()
> and vme_unregister_bridge() use bit shifts like (1 << i) and
> (1 << bridge->num) to manipulate vme_bus_numbers.
>
> Replace these shifts with the BIT(n) macro for readability,
> consistency, and kernel coding style.
The whole loop is just doing ffz().
So could be:
if (vme_bus_numbers != ~0u) {
bus_num = ffz(vme_bus_numbers);
vme_bus_numbers = BIT(bus_num);
bridge->num = bus_num;
...
ret = 0;
}
David
>
> Changes:
> - vme_register_bridge(): (1 << i) → BIT(i)
> - vme_unregister_bridge(): (1 << bridge->num) → BIT(bridge->num)
>
> Signed-off-by: Dharanitharan R <dharanitharan725@gmail.com>
> ---
> drivers/staging/vme_user/vme.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/vme_user/vme.c b/drivers/staging/vme_user/vme.c
> index 2095de72596a..f62a94ef35fc 100644
> --- a/drivers/staging/vme_user/vme.c
> +++ b/drivers/staging/vme_user/vme.c
> @@ -1766,8 +1766,8 @@ int vme_register_bridge(struct vme_bridge *bridge)
>
> mutex_lock(&vme_buses_lock);
> for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) {
> - if ((vme_bus_numbers & (1 << i)) == 0) {
> - vme_bus_numbers |= (1 << i);
> + if ((vme_bus_numbers & BIT(i)) == 0) {
> + vme_bus_numbers |= BIT(i);
> bridge->num = i;
> INIT_LIST_HEAD(&bridge->devices);
> list_add_tail(&bridge->bus_list, &vme_bus_list);
> @@ -1787,7 +1787,7 @@ void vme_unregister_bridge(struct vme_bridge *bridge)
> struct vme_dev *tmp;
>
> mutex_lock(&vme_buses_lock);
> - vme_bus_numbers &= ~(1 << bridge->num);
> + vme_bus_numbers &= ~BIT(bridge->num);
> list_for_each_entry_safe(vdev, tmp, &bridge->devices, bridge_list) {
> list_del(&vdev->drv_list);
> list_del(&vdev->bridge_list);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-06 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-06 6:36 [PATCH v1] staging: vme_user: replace (1 << n) with BIT(n) Dharanitharan R
2025-12-06 10:10 ` David Laight
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).