From: Matthias Kaehlcke <mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Cc: Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
ath9k Development
<ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Grant Grundler <grundler-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Subject: Re: [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro
Date: Thu, 6 Apr 2017 16:54:27 -0700 [thread overview]
Message-ID: <20170406235427.GC78690@google.com> (raw)
In-Reply-To: <1491514160.27353.102.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Hi Joe,
El Thu, Apr 06, 2017 at 02:29:20PM -0700 Joe Perches ha dit:
> On Thu, 2017-04-06 at 14:21 -0700, Matthias Kaehlcke wrote:
> > The macro results are assigned to u8 variables/fields. Adding the cast
> > fixes plenty of clang warnings about "implicit conversion from 'int' to
> > 'u8'".
> >
> > Signed-off-by: Matthias Kaehlcke <mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > ---
> > drivers/net/wireless/ath/ath9k/eeprom.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
> > index 30bf722e33ed..31390af6c33e 100644
> > --- a/drivers/net/wireless/ath/ath9k/eeprom.h
> > +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
> > @@ -106,7 +106,7 @@
> > #define AR9285_RDEXT_DEFAULT 0x1F
> >
> > #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
> > -#define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
> > +#define FREQ2FBIN(x, y) (u8)((y) ? ((x) - 2300) : (((x) - 4800) / 5))
>
> Maybe better to use:
>
> static inline u8 FREQ2FBIN(int x, int y)
> {
> if (y)
> return x - 2300;
> return (x - 4800) / 5;
> }
Thanks for your suggestion! Unfortunately in this case an inline
function is not suitable since FREQ2FBIN() is mostly used for
structure initialization:
static const struct ar9300_eeprom ar9300_default = {
...
.calFreqPier2G = {
FREQ2FBIN(2412, 1),
FREQ2FBIN(2437, 1),
FREQ2FBIN(2472, 1),
},
...
Cheers
Matthias
next prev parent reply other threads:[~2017-04-06 23:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 21:21 [PATCH] ath9k: Add cast to u8 to FREQ2FBIN macro Matthias Kaehlcke
2017-04-06 21:29 ` Joe Perches
[not found] ` <1491514160.27353.102.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2017-04-06 23:54 ` Matthias Kaehlcke [this message]
[not found] ` <20170406235427.GC78690-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-04-07 2:36 ` Joe Perches
2017-04-19 14:01 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170406235427.GC78690@google.com \
--to=mka-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public.gmane.org \
--cc=grundler-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org \
--cc=kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).