Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2808832rwd; Mon, 22 May 2023 04:50:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MLDACHvitNjvefcyZRtHcrfrFTdqJyLn5E1al35eHlmyvJG8+aCHqCEZMZAlLGD6ieVWo X-Received: by 2002:a05:6a00:2d28:b0:64a:f730:154b with SMTP id fa40-20020a056a002d2800b0064af730154bmr12910155pfb.5.1684756239355; Mon, 22 May 2023 04:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684756239; cv=none; d=google.com; s=arc-20160816; b=XRonRSCpja16bLh8ZCkZA12V1AqocNIzJs6Fmx1B/6gs8QlBpTmAxXXAMVn7ORzHOG OOWTwWC20BjfMGuBdZFndaCCDYD20G5x5R+Z2nXdYPWbfV9iFlvKZXWA33kXZsM35h93 dBsOr6GITh9VuPpgZhMsDByiSZD5OercU10HPzwYpd5mAAV/N+FBbhWJeyAZuONpJJYY 6PQ6GqBR/8/dfo/rw5KgEw8aYHxbBtP9oyHLv1Ks0zG/R406SKHFHgaLhmu6Oi1/kI9c SX24Oi5cFn4gO7gyKJFoLgOdTYkMbKNB9dMNd9G9+Fpqxj4cy/T09d9PMVvVHrMZu8SY wDrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/thaHVkMaXjThFKFRotXX3h8+YZGs1vN65O1LM9GutU=; b=LsnrIZpvV3TlLbQS2hsChydy+2kJlbRiZWMVRIxH8KjWp8XtXi+MAN+Ebq1sIzJ3zn oR4ZTut/iQ21tVEp7E1PWJQm61rAFVf/7kfgnIRXT84r3rCuPN8h7Gzz1BJYonKF7LCH AmBVZbl8ZDJGccZh0Et4TBLNyX5/l1dya69HmqDnwcCN1i6mkkC0Tw2wrSIFBCG5HXbM 6RNEiZEuUE9mfl3mXS8HYpfIyvSupcGj2YhD6Abn2LYRWbIqy2EQbKBjxRwhp3O2TA7b /uDD2lh54BUK+IZ+tJpVGf/5htWi5kTakl8m7nzeLGcbcTLvXeKS03bKlKYjgPpyRg7E u9ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=gqX0EBpv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m129-20020a625887000000b00643c4345942si141620pfb.134.2023.05.22.04.50.25; Mon, 22 May 2023 04:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=gqX0EBpv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233093AbjEVLdB (ORCPT + 99 others); Mon, 22 May 2023 07:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232859AbjEVLcv (ORCPT ); Mon, 22 May 2023 07:32:51 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B308ABB; Mon, 22 May 2023 04:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684755160; x=1716291160; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GsuBZcasl8sgSNzixS2gOiiY1ioqkDcpYlCuGBXnRyo=; b=gqX0EBpvEuRToAmejaYPMixciBJJEO0ufMqXgcnVMDT5yVgUyrNz+PG+ MqRVeFfBGmVxBsJ1QecsfiFcMdJAEYcXSxzqEywyi28XDTc0U5fhq0yOL ci0xsYjdm7/SU3KAjSuZ3R7Dnu0zxH+8oWRrI2i0R2m2Smljjj/PYHMy5 xlFlTeLmUwa0RwV08Knxym/G8W6cxFjl5HyqPv78byn42fIPF/QvEHGwx qoq3r1H6JvZ5olnf6mnvxbk56xrPykkHFXuetDTSqHY6vKuUDZsr4BOmx u3ZP4b8qUu/duNlcjTizHJEIILDehQHTpRkag94lrYJjFCr60c0nVgQAX Q==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="153287684" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 04:32:39 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 04:32:38 -0700 Received: from CHE-LT-I17164LX.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 04:32:33 -0700 From: Parthiban Veerasooran To: , , , , , , , , , CC: , , , , "Parthiban Veerasooran" Subject: [PATCH net-next v2 2/6] net: phy: microchip_t1s: replace read-modify-write code with phy_modify_mmd Date: Mon, 22 May 2023 17:03:27 +0530 Message-ID: <20230522113331.36872-3-Parthiban.Veerasooran@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230522113331.36872-1-Parthiban.Veerasooran@microchip.com> References: <20230522113331.36872-1-Parthiban.Veerasooran@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace read-modify-write code in the lan867x_config_init function to avoid handling data type mismatch and to simplify the code. Signed-off-by: Parthiban Veerasooran --- drivers/net/phy/microchip_t1s.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c index a42a6bb6e3bd..534d9faf8475 100644 --- a/drivers/net/phy/microchip_t1s.c +++ b/drivers/net/phy/microchip_t1s.c @@ -31,19 +31,19 @@ * W 0x1F 0x0099 0x7F80 ------ */ -static const int lan867x_fixup_registers[12] = { +static const u32 lan867x_fixup_registers[12] = { 0x00D0, 0x00D1, 0x0084, 0x0085, 0x008A, 0x0087, 0x0088, 0x008B, 0x0080, 0x00F1, 0x0096, 0x0099, }; -static const int lan867x_fixup_values[12] = { +static const u16 lan867x_fixup_values[12] = { 0x0002, 0x0000, 0x3380, 0x0006, 0xC000, 0x801C, 0x033F, 0x0404, 0x0600, 0x2400, 0x2000, 0x7F80, }; -static const int lan867x_fixup_masks[12] = { +static const u16 lan867x_fixup_masks[12] = { 0x0E03, 0x0300, 0xFFC0, 0x000F, 0xF800, 0x801C, 0x1FFF, 0xFFFF, 0x0600, 0x7F00, 0x2000, 0xFFFF, @@ -63,9 +63,7 @@ static int lan867x_config_init(struct phy_device *phydev) * used, which might then write the same value back as read + modified. */ - int reg_value; int err; - int reg; /* Read-Modified Write Pseudocode (from AN1699) * current_val = read_register(mmd, addr) // Read current register value @@ -74,12 +72,11 @@ static int lan867x_config_init(struct phy_device *phydev) * write_register(mmd, addr, new_val) // Write back updated register value */ for (int i = 0; i < ARRAY_SIZE(lan867x_fixup_registers); i++) { - reg = lan867x_fixup_registers[i]; - reg_value = phy_read_mmd(phydev, MDIO_MMD_VEND2, reg); - reg_value &= ~lan867x_fixup_masks[i]; - reg_value |= lan867x_fixup_values[i]; - err = phy_write_mmd(phydev, MDIO_MMD_VEND2, reg, reg_value); - if (err != 0) + err = phy_modify_mmd(phydev, MDIO_MMD_VEND2, + lan867x_fixup_registers[i], + lan867x_fixup_masks[i], + lan867x_fixup_values[i]); + if (err) return err; } -- 2.34.1