Skip to contentSkip to conversation

byteorder: add put/get_{endian} helpers

PATCH New Harvey Harrison 1 participant 1 message May 29, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 byteorder: add put/get_{endian} helpers

Add a set of endian helpers for the pattern:
*(__le16 *)ptr = cpu_to_le16(val);

put_le16(val, (__le16 *)ptr);

The argument order follows that of the get/put_unaligned_{endian} helpers.

The get_ helpers are exactly equivalent to the existing {endian}_to_cpup functions, but have been added anyway for symmetry in the apis.

Myrinet had a put_be32 helper that has been changed to myri_put_be32 to avoid namespace collisions.

Private helpers in the usb-gadget drivers have been removed and switched over to the common ones. Note that the put helpers here had the args in the opposite order from the common version.

---
Andrew, whether or not my patches reworking the byteorder headers goes in, could we get this in -mm for testing to expose the new api? At least then the patches I have using the new api could go in. Let me know if you want that patchset that adds users of get/put_{endian}

 drivers/net/myri10ge/myri10ge.c   |   16 ++++----
 drivers/usb/gadget/file_storage.c |   78 +++++++++++-------------------------
 include/linux/byteorder/generic.h |   72 +++++++++++++++++++++++++++++++---
 3 files changed, 98 insertions(+), 68 deletions(-)
drivers/net/myri10ge/myri10ge.c +8 -8
index 36be6ef..5d035d0 100644
@@ -331,7 +331,7 @@ MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled");
 static void myri10ge_set_multicast_list(struct net_device *dev);
 static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev);
 
-static inline void put_be32(__be32 val, __be32 __iomem * p)
+static inline void myri_put_be32(__be32 val, __be32 __iomem * p)
 {
 	__raw_writel((__force __u32) val, (__force void __iomem *)p);
 }
@@ -897,7 +897,7 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
 		dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
 		return status;
 	}
-	put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+	myri_put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
 
 	memset(mgp->ss.rx_done.entry, 0, bytes);
 
@@ -930,7 +930,7 @@ myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
 	myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
 	mb();
 	src->addr_low = low;
-	put_be32(low, &dst->addr_low);
+	myri_put_be32(low, &dst->addr_low);
 	mb();
 }
 
@@ -1288,7 +1288,7 @@ static int myri10ge_poll(struct napi_struct *napi, int budget)
 
 	if (work_done < budget) {
 		netif_rx_complete(netdev, napi);
-		put_be32(htonl(3), ss->irq_claim);
+		myri_put_be32(htonl(3), ss->irq_claim);
 	}
 	return work_done;
 }
@@ -1312,7 +1312,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
 		netif_rx_schedule(ss->dev, &ss->napi);
 
 	if (!mgp->msi_enabled) {
-		put_be32(0, mgp->irq_deassert);
+		myri_put_be32(0, mgp->irq_deassert);
 		if (!myri10ge_deassert_wait)
 			stats->valid = 0;
 		mb();
@@ -1341,7 +1341,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
 
 	myri10ge_check_statblock(mgp);
 
-	put_be32(htonl(3), ss->irq_claim + 1);
+	myri_put_be32(htonl(3), ss->irq_claim + 1);
 	return (IRQ_HANDLED);
 }
 
@@ -1410,7 +1410,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
 	struct myri10ge_priv *mgp = netdev_priv(netdev);
 
 	mgp->intr_coal_delay = coal->rx_coalesce_usecs;
-	put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+	myri_put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
 	return 0;
 }
 
@@ -2201,7 +2201,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
 
 	/* re-write the last 32-bits with the valid flags */
 	src->flags = last_flags;
-	put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
+	myri_put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
 	tx->req += cnt;
 	mb();
 }
drivers/usb/gadget/file_storage.c +24 -54

195 lines not on this page · raw message

include/linux/byteorder/generic.h +66 -6

100 lines not on this page · raw message

Signature · 1 line
1.5.6.rc0.277.g804cf