Re: [PATCH wireless-next v2 06/31] wifi: mm81x: add core.h

From: Johannes Berg

Date: Wed Jun 10 2026 - 02:23:43 EST


On Wed, 2026-06-10 at 15:06 +1000, Lachlan Hodges wrote:
> On Thu, Jun 04, 2026 at 01:40:09PM +0200, Johannes Berg wrote:
> > On Thu, 2026-04-30 at 14:55 +1000, Lachlan Hodges wrote:
> > >
> > > +#define KHZ_TO_HZ(x) ((x) * 1000)
> > > +#define KHZ100_TO_MHZ(x) ((x) / 10)
> > > +#define KHZ100_TO_KHZ(freq) ((freq) * 100)
> > > +#define KHZ100_TO_HZ(freq) ((freq) * 100000)
> >
> > Maybe not right now, but at least the first one seems fairly generic and
> > could be elsewhere.
>
> There is a function:
>
> static int mm81x_tx_h_get_prim_bw(struct cfg80211_chan_def *chandef)
> {
> return chandef->s1g_primary_2mhz ? 2 : 1;
> }
>
> which should definitely be in the cfg80211 since its a generic chandef
> helper and will probably be needed at somepoint in mac/cfg in the future.
> I can probably just have it as a patch prior similar to the SDIO id
> as part of v3. Then I guess I can also do the same for the helpers above
> and place them alongside:
>
> /* convert frequencies */
> #define MHZ_TO_KHZ(freq) ((freq) * 1000)
> #define KHZ_TO_MHZ(freq) ((freq) / 1000)
> #define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000
> #define KHZ_F "%d.%03d"
>
> Unless you have some other preference :)
>

That seems reasonable.

I guess eventually a case could be made for moving a bunch of things to
units.h, but it seems to just define the numbers not macros to convert.

Or maybe that means we should open-code, instead of MHZ_TO_KHZ(v) we
could have "v * KHZ_PER_MHZ", which is really just one character longer
anyway (though might need extra parentheses)?

Anyway no strong feelings about any of that, not really even in the
driver though that seems a bit odd (hence my comment.)

johannes