mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity
@ 2024-10-14 11:52 Ahmad Fatoum
  2024-10-14 11:52 ` [PATCH 2/2] usb: gadget: fix static analysis false positive Ahmad Fatoum
  2024-10-15  7:19 ` [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-10-14 11:52 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

No functional difference, but the code is much more readable without the
casts and shifts.

Additional benefit is removing the strange use of DMA_BIT_MASK here.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/r8169_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/r8169_main.c b/drivers/net/r8169_main.c
index cd45677131ab..2d895cf88b43 100644
--- a/drivers/net/r8169_main.c
+++ b/drivers/net/r8169_main.c
@@ -1542,10 +1542,10 @@ static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp)
 	 * register to be written before TxDescAddrLow to work.
 	 * Switching from MMIO to I/O access fixes the issue as well.
 	 */
-	RTL_W32(tp, TxDescStartAddrHigh, ((u64) tp->TxPhyAddr) >> 32);
-	RTL_W32(tp, TxDescStartAddrLow, ((u64) tp->TxPhyAddr) & DMA_BIT_MASK(32));
-	RTL_W32(tp, RxDescAddrHigh, ((u64) tp->RxPhyAddr) >> 32);
-	RTL_W32(tp, RxDescAddrLow, ((u64) tp->RxPhyAddr) & DMA_BIT_MASK(32));
+	RTL_W32(tp, TxDescStartAddrHigh, upper_32_bits(tp->TxPhyAddr));
+	RTL_W32(tp, TxDescStartAddrLow, lower_32_bits(tp->TxPhyAddr));
+	RTL_W32(tp, RxDescAddrHigh, upper_32_bits(tp->RxPhyAddr));
+	RTL_W32(tp, RxDescAddrLow, lower_32_bits(tp->RxPhyAddr));
 }
 
 static void rtl8169_set_magic_reg(struct rtl8169_private *tp)
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] usb: gadget: fix static analysis false positive
  2024-10-14 11:52 [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Ahmad Fatoum
@ 2024-10-14 11:52 ` Ahmad Fatoum
  2024-10-15  7:19 ` [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-10-14 11:52 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

On 32-bit systems, the 32-bit-wide buf can never exceed 0xffffffff,
so this resulted in a warning. Fix this by using upper_32_bits()
instead, which is also easier to read.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/usb/gadget/udc/fsl_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc.c b/drivers/usb/gadget/udc/fsl_udc.c
index e1d0d0b48272..30f4da0c41e7 100644
--- a/drivers/usb/gadget/udc/fsl_udc.c
+++ b/drivers/usb/gadget/udc/fsl_udc.c
@@ -780,7 +780,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req,
 
 	/* Init all of buffer page pointers */
 	buf = (unsigned long)req->req.buf;
-	if (buf > 0xffffffff) {
+	if (upper_32_bits(buf)) {
 		pr_err("Only 32bit supported\n");
 		return NULL;
 	}
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity
  2024-10-14 11:52 [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Ahmad Fatoum
  2024-10-14 11:52 ` [PATCH 2/2] usb: gadget: fix static analysis false positive Ahmad Fatoum
@ 2024-10-15  7:19 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-10-15  7:19 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 14 Oct 2024 13:52:31 +0200, Ahmad Fatoum wrote:
> No functional difference, but the code is much more readable without the
> casts and shifts.
> 
> Additional benefit is removing the strange use of DMA_BIT_MASK here.
> 
> 

Applied, thanks!

[1/2] net: r8169: use lower/upper_32_bits for clarity
      https://git.pengutronix.de/cgit/barebox/commit/?id=30fab792c340 (link may not be stable)
[2/2] usb: gadget: fix static analysis false positive
      https://git.pengutronix.de/cgit/barebox/commit/?id=9899233fafb9 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-15  7:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-14 11:52 [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Ahmad Fatoum
2024-10-14 11:52 ` [PATCH 2/2] usb: gadget: fix static analysis false positive Ahmad Fatoum
2024-10-15  7:19 ` [PATCH 1/2] net: r8169: use lower/upper_32_bits for clarity Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox