From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E51CC04E87 for ; Mon, 20 May 2019 13:54:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62D6A21707 for ; Mon, 20 May 2019 13:54:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bvxNJcAy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P0r2Nz9M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62D6A21707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5Aznn9gmVzMhDkqImmb9dNvJZsftbnDJBNiPBfnzojo=; b=bvxNJcAyPP02zG 5pTWtyUdvdvL3MnLlzAHV/HNCD1+uRpUONYP1fd1GLhnuAEBvt4f18exPH1P9iKIgKJ8a4Yo2OIF0 PTSlGTieDb+IEy5Nme+RypJ7GqhPfhzY2RNX1EhFrjf0pPJ5iev9rgAfx4/UYwyeSOueNvPlU93jg bF7pezWm7NETy9k6GD2V9WWXCRplP4TmBGqafRcAQzBZn/8F+fHb92WVrgQukwL8iD9J6c/NghtgT XtWOQCyKIiY+EyvjzCCJrGfnneq86O+tBQvy1VGaXTuCrRaLZBDRa/C+vRsQzUrjyWrrahxA4KsUf LEXMx0MN9CdkrC4y75gA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSikK-0004OS-Bp; Mon, 20 May 2019 13:54:32 +0000 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSijs-0003su-TT for linux-arm-kernel@lists.infradead.org; Mon, 20 May 2019 13:54:06 +0000 Received: by mail-io1-xd41.google.com with SMTP id g16so11071324iom.9 for ; Mon, 20 May 2019 06:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=njKYp+14ITtVWnHaTIS/znCm9EIrcpgkV5g8TLL3fv0=; b=P0r2Nz9M5k5sdUMKG8tZN6/xXI3z2RMasXRwJ6C6IeCz245s8PRpWOVSujb7b9MgyZ J9/23EYY+ddUAUrMZfay1vIRvXEYHtG0hgkeSCVzvMevIlhSks1nyvB39qMm5SDJ1eGA BNG5V3yHIpt/nBHeGeT2bHxz/w8RAvaWxH4Tocn/u83KGX2u/CAyCKsAlG4UfjmeL0UE ebkV8fpgkCucrce5oUMX+XrHRZHReuOACoOcTTPouoyUp0MvZHd70Sxxhy9Hrocqf59x mYBWhTiIugfAAZMLNxxUDAJxJh3D0s0zOqlJNAX883i+rNwOr+FuGKKyonpz2Hu5Al+6 uJ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=njKYp+14ITtVWnHaTIS/znCm9EIrcpgkV5g8TLL3fv0=; b=AZvtBC7m85Xq+QwkxH1k7+o3ZSyCpdmqD/71s63zrwydRkuHDICc/ZtWqrF+MLCBYo t63P+kz+xguLJz70rx+Xz0JLcxJwKNx3MFFgHHTOkPbaYTAtFO15oJ5Dlx16N6RmNOWv /MnNq67nTnWqd+XZvDBjhQwnR3mBE5f/J9nfW/bXpVfVE0EJcx8dDK3Dx10nqpzQiDRq vq1od3VmWit9ZR/yLyBdIrgT7PWtBOCLZMVIgjhzAiPRRCtwx7lt6mSHcMMhy7EZYnAH 2Xl/f0cmt2oke2ROOgqcdhZzcFkYXN+BH+XZgnzY2CUquZ3+AWU5suCJv83A/4V+VXO3 CMLg== X-Gm-Message-State: APjAAAXUlpEO9vPdr6Jz1n6UjUEjVeus3VyVlsTN3lGNCIPUIQE7vc1M t/3h9g8KnwOK2KVEDlMoxof8GQ== X-Google-Smtp-Source: APXvYqzj/S+XU04Ps+YBm6sesJFVcrQUv1xkS+ABddiyL4gw5WNdxLtQz26sYD5Yo18XZ6vi6RzsIw== X-Received: by 2002:a5d:9687:: with SMTP id m7mr6337627ion.229.1558360444278; Mon, 20 May 2019 06:54:04 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id n17sm6581185ioa.0.2019.05.20.06.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:54:03 -0700 (PDT) From: Alex Elder To: arnd@arndb.de, subashab@codeaurora.org, david.brown@linaro.org, agross@kernel.org, davem@davemloft.net Subject: [PATCH 3/8] net: qualcomm: rmnet: use field masks instead of C bit-fields Date: Mon, 20 May 2019 08:53:49 -0500 Message-Id: <20190520135354.18628-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520135354.18628-1-elder@linaro.org> References: <20190520135354.18628-1-elder@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190520_065404_951138_CC16BC0D X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: syadagir@codeaurora.org, ejcaruso@google.com, netdev@vger.kernel.org, ilias.apalodimas@linaro.org, linux-kernel@vger.kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, cpratapa@codeaurora.org, benchan@google.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Using C bitfields (e.g. int foo : 3) is not portable. So stop using them for the command/data flag and the pad length fields in the rmnet_map structure. Instead, use the functions defined in along with field mask constants to extract or assign values within an integral structure member of a known size. Signed-off-by: Alex Elder --- drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +++-- drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 8 +++++--- drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c index 4c1b62b72504..5fff6c78ecd5 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include @@ -70,7 +71,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, u16 len, pad; u8 mux_id; - if (map_header->cd_bit) { + if (u8_get_bits(map_header->cmd_pad_len, RMNET_MAP_CMD_FMASK)) { if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) return rmnet_map_command(skb, port); @@ -78,7 +79,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb, } mux_id = map_header->mux_id; - pad = map_header->pad_len; + pad = u8_get_bits(map_header->cmd_pad_len, RMNET_MAP_PAD_LEN_FMASK); len = ntohs(map_header->pkt_len) - pad; if (mux_id >= RMNET_MAX_LOGICAL_EP) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h index a30a7b405a11..a56209645c81 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h @@ -40,13 +40,15 @@ enum rmnet_map_commands { }; struct rmnet_map_header { - u8 cd_bit:1; - u8 reserved_bit:1; - u8 pad_len:6; + u8 cmd_pad_len; /* RMNET_MAP_* */ u8 mux_id; __be16 pkt_len; } __aligned(1); +#define RMNET_MAP_CMD_FMASK GENMASK(0, 0) /* 0: data; 1: cmd */ +#define RMNET_MAP_RESERVED_FMASK GENMASK(1, 1) +#define RMNET_MAP_PAD_LEN_FMASK GENMASK(7, 2) + struct rmnet_map_dl_csum_trailer { u8 reserved1; u8 valid:1; diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index 498f20ba1826..10d2d582a9ce 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include @@ -301,7 +302,9 @@ struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, done: map_header->pkt_len = htons(map_datalen + padding); - map_header->pad_len = padding & 0x3F; + /* This is a data packet, so cmd field is 0 */ + map_header->cmd_pad_len = + u8_encode_bits(padding, RMNET_MAP_PAD_LEN_FMASK); return map_header; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel