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 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7C0EC0015E for ; Wed, 19 Jul 2023 22:12:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8D4F4405B9; Wed, 19 Jul 2023 22:12:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8D4F4405B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1689804771; bh=MFDgRxShILCGWtW3JscDCxyIs/Yi5fkL8hAM8O+AV50=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=3yFIoyTsqmSqQwR7Kn4XPc02P5tOUiOw7ulnnhVAurSJRFdKb9/GFmsAFcATOwx/J ON8qkhWwc3DNDj70mOx2yWt9Fl4eM6ls2hmI8dUkzl8K1JSBgTM6Jl11ZF+DmJrcV0 Ef6kggJc3Weu8nR4s6T/x8qQn6oKpUkpEbBJ0mwTWq6zpIJNviAgDIknvFBnWAYAhY 25FqWpjBTL6ee+7BBlL7GBCVFz7H/RYyAk5zHet2buKYHZFHziGTfC0vy9cUhofm97 /a6fjTnC8vjtY9UpzQHI8At06FUW0goUA4JCttmf0VSnI3ryRKWETssyNijAoJB2F4 tNetd1GAlmupg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ZkclwTs1afY; Wed, 19 Jul 2023 22:12:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 8D447409E6; Wed, 19 Jul 2023 22:12:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8D447409E6 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 01CFC1BF276 for ; Wed, 19 Jul 2023 22:12:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E70078209A for ; Wed, 19 Jul 2023 22:12:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E70078209A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1t9g1mxSUA8d for ; Wed, 19 Jul 2023 22:12:40 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by smtp1.osuosl.org (Postfix) with ESMTPS id 450C8820B7 for ; Wed, 19 Jul 2023 22:12:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 450C8820B7 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="365460317" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="365460317" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2023 15:05:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="701411242" X-IronPort-AV: E=Sophos;i="6.01,216,1684825200"; d="scan'208";a="701411242" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2023 15:05:32 -0700 From: Jacob Keller To: Intel Wired LAN Date: Wed, 19 Jul 2023 15:05:24 -0700 Message-ID: <20230719220525.3153469-3-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.41.0.1.g9857a21e0017.dirty In-Reply-To: <20230719220525.3153469-1-jacob.e.keller@intel.com> References: <20230719220525.3153469-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689804760; x=1721340760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Mbjus+kYdx2VoWIobnBbLzCfv9VtnYcLZWOCwUYV60=; b=neLaOQZGpvpsl5j9YD3Z+t7tcoFSQk7DnwEEpwqVRwwYq66GKFk9OUgo Dvy2RhRwoC38/qFcenXzvM5PXlJxjGCaor+WYgDGH4BNcs13wyB2uegNA Uzaxal2NBJXL/ql8RrMYBJmm4LuxC1qU375nO9x5KTEBqmqw43z6k8wzC I8HAsNNCNDnYo6hzJ5gcTPr/ovKjo4zW121dsmkGIvm9ttv/oLsHQQUJZ ZpDO0MveWgN4hi2zRnyJsOibORngdtuBFszMiAe5G/dbg7zgTzgUipU54 bCQ7lrGjh+IqyojxzegypAKarp1zoTWyTN3mq7aMZDVBKx+KsUR/8CafJ w==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=neLaOQZG Subject: [Intel-wired-lan] [PATCH iwl-next 3/4] ice: PTP: move quad value check inside ice_fill_phy_msg_e822 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: Karol Kolacinski , Anthony Nguyen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Karol Kolacinski The callers of ice_fill_phy_msg_e822 check for whether the quad number is within the expected range. Move this check inside the ice_fill_phy_msg_e822 function instead of duplicating it twice. Signed-off-by: Karol Kolacinski Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c index 2f01f12a5391..168e72de06d7 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c @@ -505,11 +505,14 @@ ice_write_64b_phy_reg_e822(struct ice_hw *hw, u8 port, u16 low_addr, u64 val) * Fill a message buffer for accessing a register in a quad shared between * multiple PHYs. */ -static void +static int ice_fill_quad_msg_e822(struct ice_sbq_msg_input *msg, u8 quad, u16 offset) { u32 addr; + if (quad >= ICE_MAX_QUAD) + return -EINVAL; + msg->dest_dev = rmn_0; if ((quad % ICE_QUADS_PER_PHY_E822) == 0) @@ -519,6 +522,8 @@ ice_fill_quad_msg_e822(struct ice_sbq_msg_input *msg, u8 quad, u16 offset) msg->msg_addr_low = lower_16_bits(addr); msg->msg_addr_high = upper_16_bits(addr); + + return 0; } /** @@ -537,10 +542,10 @@ ice_read_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 *val) struct ice_sbq_msg_input msg = {0}; int err; - if (quad >= ICE_MAX_QUAD) - return -EINVAL; + err = ice_fill_quad_msg_e822(&msg, quad, offset); + if (err) + return err; - ice_fill_quad_msg_e822(&msg, quad, offset); msg.opcode = ice_sbq_msg_rd; err = ice_sbq_rw_reg(hw, &msg); @@ -571,10 +576,10 @@ ice_write_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 val) struct ice_sbq_msg_input msg = {0}; int err; - if (quad >= ICE_MAX_QUAD) - return -EINVAL; + err = ice_fill_quad_msg_e822(&msg, quad, offset); + if (err) + return err; - ice_fill_quad_msg_e822(&msg, quad, offset); msg.opcode = ice_sbq_msg_wr; msg.data = val; -- 2.41.0.1.g9857a21e0017.dirty _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan