[PATCH v4 04/11] staging: r8188eu: use htons macro instead of __constant_htons (original) (raw)

From: Deepak R Varma drv@mailo.com To: outreachy@lists.linux.dev, Larry.Finger@lwfinger.net, phil@philpotter.co.uk, paskripkin@gmail.com, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, kumarpraveen@linux.microsoft.com, saurabh.truth@gmail.com Subject: [PATCH v4 04/11] staging: r8188eu: use htons macro instead of __constant_htons Date: Fri, 21 Oct 2022 02:58:39 +0530 [thread overview] Message-ID: b46adfbdce0362ed0dbe0fc957ef2f47a93c24bb.1666299151.git.drv@mailo.com () In-Reply-To: <cover.1666299151.git.drv@mailo.com>

Macro "htons" is more efficient and clearer. It should be used for constants instead of the __constant_htons macro. Resolves following checkpatch script complaint: WARNING: __constant_htons should be htons

Signed-off-by: Deepak R Varma drv@mailo.com

Changes in v4: -- None.

Changes in v3:

  1. Make this a driver-wide change. Feedback from philipp.g.hortmann@gmail.com
  2. Correct spelling in patch log. Feedback from joe@perches.com

drivers/staging/r8188eu/core/rtw_br_ext.c | 6 +++--- drivers/staging/r8188eu/core/rtw_xmit.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index b418cbc307b3..a23f7df373ed 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -606,14 +606,14 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) if (!priv->ethBrExtInfo.dhcp_bcst_disable) { __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN));

diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 873d2c5c3634..4f8220428328 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1622,14 +1622,14 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) spin_lock_bh(&padapter->br_ext_lock); if (!(skb->data[0] & 1) && br_port && memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && - *((__be16 *)(skb->data + ETH_ALEN * 2)) != __constant_htons(ETH_P_8021Q) && - *((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP) && + *((__be16 *)(skb->data + ETH_ALEN * 2)) != htons(ETH_P_8021Q) && + *((__be16 )(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP) && !memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) { memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN); padapter->scdb_entry->ageing_timer = jiffies; spin_unlock_bh(&padapter->br_ext_lock); } else { - if (((__be16 )(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_8021Q)) { + if (((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_8021Q)) { is_vlan_tag = 1; vlan_hdr = *((unsigned short )(skb->data + ETH_ALEN * 2 + 2)); for (i = 0; i < 6; i++) @@ -1637,10 +1637,10 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) skb_pull(skb, 4); } if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && - (((__be16 )(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP))) + (((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP))) memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);

@@ -1669,7 +1669,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) skb_push(skb, 4); for (i = 0; i < 6; i++) *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); - *((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); + *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q); *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; }

@@ -1708,7 +1708,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) skb_push(skb, 4); for (i = 0; i < 6; i++) *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); - *((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); + *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q); *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; } }

2.30.2


next prev parent reply other threads:[~2022-10-20 21:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-20 21:26 [PATCH v4 00/11] staging: r8188eu: trivial code cleanup patches Deepak R Varma 2022-10-20 21:26 [[PATCH v4 01/11] staging: r8188eu: use Linux kernel variable naming convention](../a107c527e9032c22a62e93ff12d5fae625e70212.1666299151.git.drv@mailo.com/) Deepak R Varma 2022-10-20 21:27 [PATCH v4 02/11] staging: r8188eu: reformat long computation lines Deepak R Varma 2022-10-20 21:27 [[PATCH v4 03/11] staging: r8188eu: remove {} for single statement blocks](../a50460e1507621b29a7901cc4ff9501b172417db.1666299151.git.drv@mailo.com/) Deepak R Varma **2022-10-20 21:28 Deepak R Varma [this message]** 2022-10-20 21:29 [[PATCH v4 05/11] staging: r8188eu: correct misspelled words in comments](../00be5f2a97b0c899279bd8f9cd27634186b77b9d.1666299151.git.drv@mailo.com/) Deepak R Varma 2022-10-20 21:30 [PATCH v4 06/11] staging: r8188eu: Add space between function & macro parameters Deepak R Varma 2022-10-20 21:30 [[PATCH v4 07/11] staging: r8188eu: Associate pointer symbol with parameter name](../d946b69bfdfb44baae3a130e412ed2e217a710a7.1666299151.git.drv@mailo.com/) Deepak R Varma 2022-10-20 21:31 [PATCH v4 08/11] staging: r8188eu: replace leading spaces by tabs Deepak R Varma 2022-10-21 5:34 [Praveen Kumar](../a1429a6a-1688-c30a-4fb2-3d575ffecbf1@linux.microsoft.com/) 2022-10-20 23:31 Deepak R Varma 2022-10-20 21:31 [[PATCH v4 09/11] staging: r8188eu: Put '{" on the symbol declaration line](../375f742936493b562bd4dfba90eb75bd8ab84f8a.1666299151.git.drv@mailo.com/) Deepak R Varma 2022-10-20 21:32 [PATCH v4 10/11] staging: r8188eu: Correct missing or extra space in the statements Deepak R Varma 2022-10-20 21:32 [[PATCH v4 11/11] staging: r8188eu: Remove unused macros](../efaf637a14b6f7fdd0178e2aecf8abf17e6922f6.1666299151.git.drv@mailo.com/) Deepak R Varma 2022-10-21 5:51 Praveen Kumar 2022-10-21 5:56 [Greg KH](../Y1I0dcZqMJAzHSm2@kroah.com/) 2022-10-20 23:34 Deepak R Varma 2022-10-21 8:33 [Greg KH](../Y1JZdembzkkQPaOQ@kroah.com/) 2022-10-20 23:50 Deepak R Varma 2022-10-21 5:20 [[PATCH v4 00/11] staging: r8188eu: trivial code cleanup patches](../113aed11-de11-bf68-1ec1-1b420ff502da@gmail.com/) Philipp Hortmann 2022-10-22 8:05 Greg KH 2022-10-21 16:49 ` Deepak R Varma


Reply instructions:

You may reply publicly to this message via plain-text email using any one of the following methods:

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).