From patchwork Thu May 5 13:55:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12839633 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 60F61C433EF for ; Thu, 5 May 2022 14:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DZZ8n1TWphABysEbvWnL6L4GxOIj30tk/IRvABIXlDs=; b=vrzWNjwQ7WG9ix DBoOciZ1jRNsfQVBMzst/3EfX8LUtKke3MAbSfweTS/EWowym57z1VDYX3zSrRKDCsY2MnfkrWW40 BpYBEmawk98O/R8UrxtsDG64SmH80Lez1gT6x+UtKFQ4W93KJAcEsijbUQUahj2mqyATbGunLPxn8 pDrrJdW9dV3pkKIH24Uvinmq8PWPwFt5ll0Z2JhHbv84uWBalF9/5RD3ONPlfc0+QHbdE6eTAzDfu svFtUMQQn69XxBEwoHl6d+30WfYv6lhsGIdCKWU5FKEl+Qhx3Z/O09FpwDmcQ3iXEEM727Y4Tvb0O Gqfqovx19G7IZuQO+GJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmc10-00GEMt-E2; Thu, 05 May 2022 13:59:34 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmbxC-00GCh5-E7 for linux-arm-kernel@lists.infradead.org; Thu, 05 May 2022 13:55:39 +0000 Received: by mail-ed1-x529.google.com with SMTP id ba17so5307660edb.5 for ; Thu, 05 May 2022 06:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W4OY/JvmasUugHSn3rUmXaSkS514QXA0AsYyOrhfQQg=; b=H8Ao8D+HKPoqzvyk98XDDUx5ZI7tA1FociIFIuzl17MmQWY+/ne9onYEyJ0AYfrm6M WBl8sG1lg7rLJT+ffPgm8+ERj97fPvTeSbCsqbV/h6YlsCvpNUU/SH7E4nWQHwQU8Y0H fQhXJQemxVsnGX6dt0rvSKqm47LDBgg9ByAAs+3RMv0Ot3YFjq3hLRfsG2DPniS3t4tp WhEqGTIecb+TAtoJ4goXvh/SbiMP9gwzm/uIIgPQNy116BtfzSDWWjEaRdRfeoc2C1Te o5Mry/99pzA8YkYpAYviJKCNP97gqiItOI+NtsW6Ppnw9ndyiGrdPcpP2ZSxG1ufiQh+ +Aig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W4OY/JvmasUugHSn3rUmXaSkS514QXA0AsYyOrhfQQg=; b=6cqn4J2638U5lPqwkDD74yeZGUFwGvIYPMRum2XsV71yHIdU9x7yoM7mGGNha0yVrL 4pT9+8zUDknnLINxAln+RzFl/OlzEQw125AY1/bRIWDNwuJ92L0iESvKhnTYUE2PZa0R +HF1Lo8OVh8MBpyQE5uNGF6wjumhetx7vCJBcjRuzz9+wSXo7v3/N3bDbvldO7plUYCP rNYrSspNoxNky57D5q228Hpt8vCQBtfjRtH8JaBm6ZMgjSIxALzQJaMvI5RPvFSDhjZH 8szbj/IRXtxSjSrUFnsAhA/XnUR07bY9buKdOGpeUu4ZuNlcqoQjuazib0vVGdQGPj5H Ssbw== X-Gm-Message-State: AOAM532v5CfKClmTGjS3Op3eMFYZI1LKpoVGTbGv0W1FkFfg9GB4/m3d 2qsXxDxojhOTQovgLzNfVKk= X-Google-Smtp-Source: ABdhPJxZtO2nEF1yJ6MjoitOsoR6NiKa4vbJTd4fTbtfyjCPOSo9zQI9bOEoP434SL7qulITdqNiPQ== X-Received: by 2002:a05:6402:2741:b0:41f:69dc:9bcd with SMTP id z1-20020a056402274100b0041f69dc9bcdmr30258922edd.239.1651758936244; Thu, 05 May 2022 06:55:36 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id e15-20020a50e44f000000b0042617ba63c7sm877949edm.81.2022.05.05.06.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 06:55:35 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski Cc: Pavel Machek , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Hauke Mehrtens , Jacek Anaszewski , devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, ansuelsmth@gmail.com, andrew@lunn.ch, vivien.didelot@gmail.com, Vladimir Oltean , Jonathan Corbet , John Crispin , linux-doc@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH RESEND PoC] leds: trigger: netdev: support DT "trigger-sources" property Date: Thu, 5 May 2022 15:55:12 +0200 Message-Id: <20220505135512.3486-6-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220505135512.3486-1-zajec5@gmail.com> References: <20220505135512.3486-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220505_065538_555277_B8635FA5 X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Rafał Miłecki Parse "trigger-sources", find referenced netdev & use it as default trigger source. Signed-off-by: Rafał Miłecki --- This is a proof on concept, please don't apply this patch. I'll rework this on top of Ansuel's netdev trigger refactoring once it gets accepted ---- drivers/leds/trigger/ledtrig-netdev.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index d5e774d83021..c036a3671773 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include "../leds.h" @@ -389,6 +391,28 @@ static void netdev_trig_work(struct work_struct *work) (atomic_read(&trigger_data->interval)*2)); } +static void netdev_trig_of_init(struct led_classdev *led_cdev) +{ + struct device *dev = led_cdev->dev; + struct device_node *np = dev->of_node; + struct of_phandle_args args; + struct net_device *netdev; + int err; + + err = of_parse_phandle_with_args(np, "trigger-sources", "#trigger-source-cells", 0, &args); + if (err || WARN_ON(!args.np)) { + dev_err(dev, "Failed to get trigger source phandle: %d\n", err); + return; + } + + netdev = of_find_net_device_by_node(args.np); + if (netdev) { + device_name_store(dev, NULL, netdev->name, strlen(netdev->name) + 1); + } + + of_node_put(args.np); +} + static int netdev_trig_activate(struct led_classdev *led_cdev) { struct led_netdev_data *trigger_data; @@ -415,6 +439,8 @@ static int netdev_trig_activate(struct led_classdev *led_cdev) led_set_trigger_data(led_cdev, trigger_data); + netdev_trig_of_init(led_cdev); + rc = register_netdevice_notifier(&trigger_data->notifier); if (rc) kfree(trigger_data);