From patchwork Tue May 3 15:16:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 570644 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C2D9C433F5 for ; Tue, 3 May 2022 15:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238171AbiECPWH (ORCPT ); Tue, 3 May 2022 11:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238111AbiECPVx (ORCPT ); Tue, 3 May 2022 11:21:53 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C72B3A5D1; Tue, 3 May 2022 08:18:20 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id g20so20216732edw.6; Tue, 03 May 2022 08:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=z8UQ0gwVo42S8MFd7E26z2Xx0d1KX8rCgVDlpW4ge0U=; b=I15PSPUtz97s9sbyUeXPtBKIvBTxCVYMz3hilzJiVMtt9pAjOemVHYQ8Uis0XtxfOT TN8W9PnnD29qFCawu3etc/tM2JeNRofYFyqtdEtK9Kikn+90FV0gdxlkInUFheBLagE7 nvYR3EygB0DclsZmbC+JfPoF07juG9YKo+EgIRF19zudPBsg4VOnr6F2cVF/Hsgxzs50 cMlurb7UAGobryt3LOLpepKlrz8Id6Pi3kr8ZDe0MwzBI71q7t5mfKhyvRJ56WxtJH0L mBIh7q/Wd95tSrP0nHc4lfE3Hklm1jdbRBd6r5k+sjlAde0MvSXMxxeL7HaR92QIqv2D 1skg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z8UQ0gwVo42S8MFd7E26z2Xx0d1KX8rCgVDlpW4ge0U=; b=kWXVe5WTzVn96ePfmryFLiz+mn+OoTG1ykd8iCHeN2E138mdGOp8/9pElgzDUrVA7g rXVFdEBE/3MXEVBGA6r3ExAafo0zG25B/n7dq85cYLNZw/3dcJqzhiVj2W+n2ZoNBYt3 ltB1ba2sKDQq0RdA7Hd0sNqisV+8BXqTSLmQkHm4ZSOGXcuXS1nB6R21vWdPCGxZQBch IpPyB627CxxkriobEMUsMvTnVEpUTrL0i5YLz5DetegIlo+owIgl1eo81acEvMmXyY59 tmFEpimjC9uM7rHj/U0S59N59s9u7xtvjj9J4yzjo+ozqYq3pT5jrHgGGg3Gkspebw/8 HWow== X-Gm-Message-State: AOAM5318fOiUl8g5gzV5LKjHXDhD9ZWK0kF9QDMP07dOH50Tiacamgc/ xbM++S20SRoz9Gtazola2Ng= X-Google-Smtp-Source: ABdhPJw8PYctsl15p4W9Mjn4kajId/tHVHaGiczNq0Ue9zw8EBCPNN4e2YoBTjoG/vc7j1Q7uWlm9A== X-Received: by 2002:a05:6402:2204:b0:426:34f1:1d2d with SMTP id cq4-20020a056402220400b0042634f11d2dmr18401032edb.335.1651591098520; Tue, 03 May 2022 08:18:18 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id v3-20020aa7d9c3000000b0042617ba63cesm7947507eds.88.2022.05.03.08.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 08:18:18 -0700 (PDT) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Pavel Machek , Ansuel Smith , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org Subject: [RFC PATCH v6 03/11] leds: trigger: netdev: drop NETDEV_LED_MODE_LINKUP from mode Date: Tue, 3 May 2022 17:16:25 +0200 Message-Id: <20220503151633.18760-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503151633.18760-1-ansuelsmth@gmail.com> References: <20220503151633.18760-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Drop NETDEV_LED_MODE_LINKUP from mode list and convert to a simple bool that will be true or false based on the carrier link. No functional change intended. Signed-off-by: Ansuel Smith --- drivers/leds/trigger/ledtrig-netdev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index d5e774d83021..66a81cc9b64d 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -50,10 +50,10 @@ struct led_netdev_data { unsigned int last_activity; unsigned long mode; + bool carrier_link_up; #define NETDEV_LED_LINK 0 #define NETDEV_LED_TX 1 #define NETDEV_LED_RX 2 -#define NETDEV_LED_MODE_LINKUP 3 }; enum netdev_led_attr { @@ -73,9 +73,9 @@ static void set_baseline_state(struct led_netdev_data *trigger_data) if (!led_cdev->blink_brightness) led_cdev->blink_brightness = led_cdev->max_brightness; - if (!test_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode)) + if (!trigger_data->carrier_link_up) { led_set_brightness(led_cdev, LED_OFF); - else { + } else { if (test_bit(NETDEV_LED_LINK, &trigger_data->mode)) led_set_brightness(led_cdev, led_cdev->blink_brightness); @@ -131,10 +131,9 @@ static ssize_t device_name_store(struct device *dev, trigger_data->net_dev = dev_get_by_name(&init_net, trigger_data->device_name); - clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); + trigger_data->carrier_link_up = false; if (trigger_data->net_dev != NULL) - if (netif_carrier_ok(trigger_data->net_dev)) - set_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); + trigger_data->carrier_link_up = netif_carrier_ok(trigger_data->net_dev); trigger_data->last_activity = 0; @@ -315,7 +314,7 @@ static int netdev_trig_notify(struct notifier_block *nb, spin_lock_bh(&trigger_data->lock); - clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); + trigger_data->carrier_link_up = false; switch (evt) { case NETDEV_CHANGENAME: case NETDEV_REGISTER: @@ -330,8 +329,7 @@ static int netdev_trig_notify(struct notifier_block *nb, break; case NETDEV_UP: case NETDEV_CHANGE: - if (netif_carrier_ok(dev)) - set_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); + trigger_data->carrier_link_up = netif_carrier_ok(dev); break; }