From patchwork Thu Mar 12 01:27:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1253329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48dB5g6fS5z9sSL for ; Thu, 12 Mar 2020 12:27:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6A0D0869A5; Thu, 12 Mar 2020 01:27:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ekfUA2LXBb45; Thu, 12 Mar 2020 01:27:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id DEB1A858A6; Thu, 12 Mar 2020 01:27:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id EA0B41BF473 for ; Thu, 12 Mar 2020 01:27:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id DDF86263F2 for ; Thu, 12 Mar 2020 01:27:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YIbNA8JBMKCq for ; Thu, 12 Mar 2020 01:27:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by silver.osuosl.org (Postfix) with ESMTPS id 2CE4E261E3 for ; Thu, 12 Mar 2020 01:27:31 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 18:27:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,543,1574150400"; d="scan'208";a="242867031" Received: from jekeller-desk.amr.corp.intel.com ([10.166.241.33]) by orsmga003.jf.intel.com with ESMTP; 11 Mar 2020 18:27:28 -0700 From: Jacob Keller To: Intel Wired LAN Date: Wed, 11 Mar 2020 18:27:18 -0700 Message-Id: <20200312012726.973301-2-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200312012726.973301-1-jacob.e.keller@intel.com> References: <20200312012726.973301-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH v2 1/9] ice: use __le16 types for explicitly Little Endian values X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Kicinski Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The ice_read_sr_aq function returns words in the Little Endian format. Remove the need for __force and typecasting by using a local variable in the ice_read_sr_word_aq function. Additionally clarify explicitly that the ice_read_sr_aq function takes storage for __le16 values instead of using u16. Being explicit about the endianness of this data helps when using tools like sparse to catch endian-related issues. Signed-off-by: Jacob Keller Reviewed-by: Jesse Brandeburg --- drivers/net/ethernet/intel/ice/ice_nvm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c index f6e25db22c23..5597ec50a662 100644 --- a/drivers/net/ethernet/intel/ice/ice_nvm.c +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c @@ -80,13 +80,14 @@ ice_check_sr_access_params(struct ice_hw *hw, u32 offset, u16 words) * @hw: pointer to the HW structure * @offset: offset in words from module start * @words: number of words to read - * @data: buffer for words reads from Shadow RAM + * @data: storage for the words read from Shadow RAM (Little Endian) * @last_command: tells the AdminQ that this is the last command * - * Reads 16-bit word buffers from the Shadow RAM using the admin command. + * Reads 16-bit Little Endian word buffers from the Shadow RAM using the admin + * command. */ static enum ice_status -ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, u16 *data, +ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, __le16 *data, bool last_command) { enum ice_status status; @@ -116,10 +117,11 @@ static enum ice_status ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data) { enum ice_status status; + __le16 data_local; - status = ice_read_sr_aq(hw, offset, 1, data, true); + status = ice_read_sr_aq(hw, offset, 1, &data_local, true); if (!status) - *data = le16_to_cpu(*(__force __le16 *)data); + *data = le16_to_cpu(data_local); return status; }