From patchwork Thu Oct 10 12:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13830075 X-Patchwork-Delegate: kuba@kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2CE01C6F65; Thu, 10 Oct 2024 12:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728564929; cv=none; b=ADc0JdT7sN2gyYC0foFZ9hqugGhBbIfTQlv6/W7T9HFdcIOmeFv7vSx6xOwxX0tQynvoWWsGbf+Ct0iJ2+i/sBTEf5RA74uN66qfIQ2NGI+Qq9qNjegGPqxA3bfy0BH+WwN218sGirqjenrHHA4S6wxteX+3aryLldZedhkVJmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728564929; c=relaxed/simple; bh=BDcveaXRRH7OxdXgT/OSU3kQSAeTncKr+aE+8wR1bJE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ds03N8+qIWJ0fXUxrX67KRWYwuE5opXnsPXluTGr7JkXCBVNsPdU7TD5MWqOrapeYm4ZkwV1xiUtuft47lJTjk4Ohtubd+q/bUn2vdYO9pFEGpbn3HyqEtOk3qFoabtGX0W+ku/wyFWYv9lc/5LtZaK6XpMdyVoXWFWGJNqGivQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98) (envelope-from ) id 1syshN-000000003Ap-2cNR; Thu, 10 Oct 2024 12:55:21 +0000 Date: Thu, 10 Oct 2024 13:55:17 +0100 From: Daniel Golle To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xu Liang , Christian Marangi , Bartosz Golaszewski , Daniel Golle , Robert Marko , Russell King , Jacek Anaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 4/5] net: phy: mxl-gpy: correctly describe LED polarity Message-ID: <180ccafa837f09908b852a8a874a3808c5ecd2d0.1728558223.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org According the datasheet covering the LED (0x1b) register: 0B Active High LEDx pin driven high when activated 1B Active Low LEDx pin driven low when activated Make use of the now available 'active-high' property and correctly reflect the polarity setting which was previously inverted. Signed-off-by: Daniel Golle Reviewed-by: Andrew Lunn --- v2: use dedicated bools force_active_high and force_active_low to make gpy_led_polarity_set() more robust drivers/net/phy/mxl-gpy.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index bc4abb957e15..00676e272913 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -989,7 +989,7 @@ static int gpy_led_hw_control_set(struct phy_device *phydev, u8 index, static int gpy_led_polarity_set(struct phy_device *phydev, int index, unsigned long modes) { - bool active_low = false; + bool force_active_low = false, force_active_high = false; u32 mode; if (index >= GPY_MAX_LEDS) @@ -998,15 +998,23 @@ static int gpy_led_polarity_set(struct phy_device *phydev, int index, for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { switch (mode) { case PHY_LED_ACTIVE_LOW: - active_low = true; + force_active_low = true; + break; + case PHY_LED_ACTIVE_HIGH: + force_active_high = true; break; default: return -EINVAL; } } - return phy_modify(phydev, PHY_LED, PHY_LED_POLARITY(index), - active_low ? 0 : PHY_LED_POLARITY(index)); + if (force_active_low) + return phy_set_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); + + if (force_active_high) + return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); + + unreachable(); } static struct phy_driver gpy_drivers[] = {