Search Linux Wireless

Re: [PATCH] nl/cfg/mac80211: use BIT(x) instead of (1 << x)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 09 Jul 2012 11:22:04 +0200
Johannes Berg <johannes@xxxxxxxxxxxxxxxx> wrote:

> 
> > --- a/net/mac80211/iface.c
> > +++ b/net/mac80211/iface.c
> > @@ -1432,7 +1432,7 @@ int ieee80211_if_add(struct ieee80211_local
> > *local, const char *name, struct ieee80211_supported_band *sband;
> >  		sband = local->hw.wiphy->bands[i];
> >  		sdata->rc_rateidx_mask[i] =
> > -			sband ? (1 << sband->n_bitrates) - 1 : 0;
> > +			sband ? BIT(sband->n_bitrates) - 1 : 0;
> 
> I don't like the BIT()-1 pattern, "(1 << x) - 1" seems like a more
> regular pattern. Arguably, there should be a define for it, but I
> can't seem to come up with a good name.

>From drivers/mfd/dbx500-prcmu-regs.h:

#define BITS(_start, _end) ((BIT(_end) - BIT(_start)) + BIT(_end))

So it would be

BITS(0, sband->n_bitrates - 1)

Perhaps BITS could be made safer and more generic when moved to a
common header.

-- 
Regards,
Pavel Roskin
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux