From patchwork Wed Apr 19 21:07:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 85549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp669029vqo; Wed, 19 Apr 2023 14:14:55 -0700 (PDT) X-Google-Smtp-Source: AKy350bHgaKWhe+OpiqiIQQqHS714YS8bfU6X0uGda07L42882KS9om6AdiAScHkEpTM813HG3tZ X-Received: by 2002:a17:902:ea05:b0:19a:a520:b203 with SMTP id s5-20020a170902ea0500b0019aa520b203mr7761173plg.25.1681938894796; Wed, 19 Apr 2023 14:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681938894; cv=none; d=google.com; s=arc-20160816; b=FYVFiWHItt3ZL+azNvNG4ZPDKsx01njXyayjgs5Cnefx0rAHDzmvdqes19vm2qlUGg j6zZRBZ0s8CO46Ha7CEx9ufdQFOazEm1JKBTo+7A/ztDU2NIQUjZluepguLXaY5YwyY4 c3wOMl26OJU11V4eofNhP9gd6OdwD+EM7oBjKg9WaJIGiHVZT6FQZYZEhE5fQkDN+jnM ejkJjHkJGB6FoT5gTiew9T4fMlljp7zC+UfMG3b6FfIzqtSLO6N5YNPq9JPYlgeVLWSq AhzB3I3GgyHwquTu+Srwmbm/0mUOuDPdkK3EXTIxeI6hDzgW9FrJIzl5XfXIWSJ7E8Up C2Zw== 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:to:from :dkim-signature; bh=zdLjBTspN0RuBhnqah0NEHAUrMQQgvoP610DrLOri+g=; b=mNRPFnrhC5CiVWrPSwjaHaG85W2TozAF9OCImqj4va2qarxAjUewhK+w1B33IxmVzM rw5bJcHaIhEQ6+ANBBI/jfyCTKjUrS5wSUv3yZVv3wseB/Pv2E52bSv+st7/c3B+miGz 4Hg39fQUSZb1sviUHJWozz3kKq8J3v4kTbY8bXCkgdusiCM1GZjBZa8EouFEEBLsBPlr uUCYdn0PE12rfi5Djc/xEp5Kzoq+woHhxfV3APynpZsyu1rGnhOsX6ryjyN8zc37V1+8 H/dkz/4tjv9JyzVSXojxZZ9aUKdiKlaFZiyNxANq2KhWeqTVslX1vQb9WT75wZpDXTjb NCyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XY52PUvu; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz9-20020a170902ef8900b001a51c3404e0si16979325plb.337.2023.04.19.14.14.36; Wed, 19 Apr 2023 14:14:54 -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=@gmail.com header.s=20221208 header.b=XY52PUvu; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231448AbjDSVI1 (ORCPT + 99 others); Wed, 19 Apr 2023 17:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjDSVIV (ORCPT ); Wed, 19 Apr 2023 17:08:21 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561AC5B92; Wed, 19 Apr 2023 14:08:18 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f09b9ac51dso5342585e9.0; Wed, 19 Apr 2023 14:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681938497; x=1684530497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zdLjBTspN0RuBhnqah0NEHAUrMQQgvoP610DrLOri+g=; b=XY52PUvumH0PTZvaEV1/fr7g1UkVMtC05AIAq5eHMV5LFD/xgcMRBNeHpY6ASPaLSZ BHtzcKU8v50KIpRELZO3PhdrKAe600n956MhFEorvW/Ce3qUWhAdc31XJ0H4TBSEf/Zd XTgCyqW58Ca9sTJ6kDJplJzF0zM8THj8gTCLB56DvpK1Pf4BxZxCUb99mzMOU64iM3X7 7l1mRXsLT7UgmfHo1W8YS8fUG91bTm8HNUDe8qzyZOcbw8kwc8vSXHO0yNhZxMWLM1eb u1+UjfBtC7JNOdZxhIkIosOO3M2b03D0Idsx/BzasRrUlyxL/toBykuONZ6Cks6X7g6e Hm6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938497; x=1684530497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdLjBTspN0RuBhnqah0NEHAUrMQQgvoP610DrLOri+g=; b=Yjk5NMWESRoA2h+5uFWUDAe4B9wAoLE0p0o59mlu7o1a+NUKrgrm8jNGzhreQMKlri 131oQ0dvb4mO/YFAQYc8pTla/F2r+dGcF06q7P3NZtwHDC729+vhdY4h1fDR78iGxgLp S36RLI6Yn1LUV6IxjfS0to7fWGTIMrUu9bKZfjsxa32NdjrGP8vz3mFnuLCHpQCSMHgT fSSvZkZNzr2986htMV6mKk/BxhI8Zr7CxUkkdm2hqk2Qy1YLPSBxozawoXuQiuL7W/XU XbbprZVAvl3B7waZfGkpVcwUWLZCVIkWrBhfiAjavEMQvpIvcVZ64h4IPCDk5A+XP8lF CW9Q== X-Gm-Message-State: AAQBX9fWM+RYxf2duF8pUsm/xTuSI0q3qcWVRWq5J6/3+08B+gulUNHu Jp7oH6s/PU4VBJt8Dkpq4Xw= X-Received: by 2002:adf:ec4e:0:b0:2fd:c315:bb2c with SMTP id w14-20020adfec4e000000b002fdc315bb2cmr2673603wrn.22.1681938496496; Wed, 19 Apr 2023 14:08:16 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id g3-20020a5d5543000000b002fe254f6c33sm81295wrw.92.2023.04.19.14.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:08:16 -0700 (PDT) From: Christian Marangi To: Pavel Machek , Lee Jones , Christian Marangi , Martin Schiller , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn Subject: [PATCH 2/5] leds: trigger: netdev: drop NETDEV_LED_MODE_LINKUP from mode Date: Wed, 19 Apr 2023 23:07:40 +0200 Message-Id: <20230419210743.3594-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230419210743.3594-1-ansuelsmth@gmail.com> References: <20230419210743.3594-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763640758088910937?= X-GMAIL-MSGID: =?utf-8?q?1763640758088910937?= Putting NETDEV_LED_MODE_LINKUP in the same list of the netdev trigger modes is wrong as it's used to set the link state of the device and not to set a blink mode as it's done by NETDEV_LED_LINK, NETDEV_LED_TX and NETDEV_LED_RX. It's also wrong to put this state in the same bitmap of the netdev trigger mode and should be external to it. 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: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/leds/trigger/ledtrig-netdev.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index f4d670ec30bc..d5c4e72b8261 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,11 +314,10 @@ 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: - if (netif_carrier_ok(dev)) - set_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); + trigger_data->carrier_link_up = netif_carrier_ok(dev); fallthrough; case NETDEV_REGISTER: if (trigger_data->net_dev) @@ -333,8 +331,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; }