From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Kalle Valo <kvalo@kernel.org>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH 4/4] wifi: rt2x00: fix __le32 sparse warnings
Date: Sat, 3 Feb 2024 13:35:28 +0100 [thread overview]
Message-ID: <20240203123528.GA170353@wp.pl> (raw)
In-Reply-To: <87il3aaqoz.fsf@kernel.org>
Hi Kalle
On Wed, Jan 31, 2024 at 09:48:44AM +0200, Kalle Valo wrote:
> Kalle Valo <kvalo@kernel.org> writes:
>
> > Sparse warns:
> >
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10949:39: warning: incorrect type in assignment (different base types)
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10949:39: expected unsigned int [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10949:39: got restricted __le32 [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10951:43: warning: incorrect type in assignment (different base types)
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10951:43: expected unsigned int [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10951:43: got restricted __le32 [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10953:43: warning: incorrect type in assignment (different base types)
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10953:43: expected unsigned int [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10953:43: got restricted __le32 [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10955:43: warning: incorrect type in assignment (different base types)
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10955:43: expected unsigned int [usertype]
> > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:10955:43: got restricted __le32 [usertype]
> >
> > rt2x00 does some wicked casting here so no wonder sparse warns. Clean that up
> > and use cpu_to_le16() to avoid any warnings.
> >
> > Compile tested only.
> >
> > Signed-off-by: Kalle Valo <kvalo@kernel.org>
>
> Stanislaw, sorry somehow I corrupted your address but fixed it now. Let
> me know what you think, patch here:
>
> https://patchwork.kernel.org/project/linux-wireless/patch/20240130151556.2315951-5-kvalo@kernel.org/
If I analyse it correctly, patch is not ok on Big Endian machines
where we do bytes swapping.
Let asume reg value is 0x0D0C0B0A
On previous code:
- *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg);
result is
eeprom[0] = 0x0D
eeprom[1] = 0x0C
eeprom[2] = 0x0B
eeprom[3] = 0x0A
After modification:
+ rt2x00dev->eeprom[i] = cpu_to_le16(reg);
+ rt2x00dev->eeprom[i + 1] = cpu_to_le16(upper_16_bits(reg));
result will be
eeprom[0] = 0x0B
eeprom[1] = 0x0A
eeprom[2] = 0x0D
eeprom[2] = 0x0C
Maybe just casting to __le32, i.e:
*(__le32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg);
would solve the problem ?
Regards
Stanislaw
next prev parent reply other threads:[~2024-02-03 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 15:15 [PATCH 0/4] wifi: drivers: fix some sparse warnings Kalle Valo
2024-01-30 15:15 ` [PATCH 1/4] wifi: zd1211rw: remove __nocast from zd_addr_t Kalle Valo
2024-02-05 18:16 ` Kalle Valo
2024-01-30 15:15 ` [PATCH 2/4] wifi: rsi: fix restricted __le32 degrades to integer sparse warnings Kalle Valo
2024-01-30 15:15 ` [PATCH 3/4] wifi: cw1200: fix __le16 " Kalle Valo
2024-01-30 15:15 ` [PATCH 4/4] wifi: rt2x00: fix __le32 " Kalle Valo
2024-01-31 7:48 ` Kalle Valo
2024-02-03 12:35 ` Stanislaw Gruszka [this message]
2024-02-28 9:44 ` Kalle Valo
2024-03-02 8:01 ` Stanislaw Gruszka
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=20240203123528.GA170353@wp.pl \
--to=stf_xl@wp.pl \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.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).