From patchwork Tue May 22 21:29:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Paulo_Rechi_Vita?= X-Patchwork-Id: 10419647 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EB2A36032A for ; Tue, 22 May 2018 21:30:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA06A28DED for ; Tue, 22 May 2018 21:30:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBAD728E15; Tue, 22 May 2018 21:30:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C5CA28DEE for ; Tue, 22 May 2018 21:30:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753152AbeEVV35 (ORCPT ); Tue, 22 May 2018 17:29:57 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:41517 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752785AbeEVV3h (ORCPT ); Tue, 22 May 2018 17:29:37 -0400 Received: by mail-pl0-f68.google.com with SMTP id az12-v6so11652362plb.8; Tue, 22 May 2018 14:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uhCQ0fdeS9CnAHBq86x0B8Z3/3qny6mf+ZneWdLU2f0=; b=h8zm50BXW5tYViVjkWebwgFN19Wh5psYae7NgYzwse/FUfW0+UJK8SrTJshBcksN+9 LU7qJgyD42OubdlYaaIEaPRm05aEh8qrYrgSeHDLEGr8Elx1GAdog5G1v494yljEjJuh 15A5VECtaK7r7CADE3X2cBsQ5S1yr2rWU4u/TB9aRIARgy/KesIyQKNeC9ymmwEgDaAu 6oC+HmNAubIr42eY+rp83rjS4pEfVUi4eTnNvQ08/AOH6lYFkUPXZ3P2BzEUhOAw+ERC NzSjBYVF/RCG+UYaj3wxCD1TEXiiuqJ4pEsjwer8yeTbab0wWTGvM1uCTPbl6GhPgHsJ VmKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uhCQ0fdeS9CnAHBq86x0B8Z3/3qny6mf+ZneWdLU2f0=; b=eWWHTLTGixdArT1D1bTq25D7sauwvKcV4HEI5vbPxLUl1ZMLkotQHBe0hg6CQa1vyB EPX2SKvWwSpA2mZSCbUkxjMabIwHdEum4oIPl3NzwW5wkyBFs31+/4ERIzxRr/QYmx9F ATgHaordwq6OL4wiiqrul4tUtfM+k/woYmHBloKg/rCy+h1djSOJibMD5fvCRE0sKfsO si8i9K3c2VyeUgvYme7XQwEPSfAuZWHziSLwFFas4QwgJjv/1rbGxddBNfKjvoa5YgpT GXyevonhZ6wHm0IwSZ6QztwITfXXtQhllCWXSmwDlEpSZeyxWFqGfP2yhKyepRlUWdeu igOw== X-Gm-Message-State: ALKqPwf2durzbjpyVbE8YahuVA+OIV2HVb58Jk0MTylZoZNtYA5upWgc X5tRpW6pCW+gXEo7ue9k7y8= X-Google-Smtp-Source: AB8JxZpKyEdmUsHvaynEcWsglTeYQY8R4lHJX3Ckbas6s4BG1lDJL7xTJ/TX1jnw6Rf0HqQOimon8w== X-Received: by 2002:a17:902:5409:: with SMTP id d9-v6mr141935pli.1.1527024576686; Tue, 22 May 2018 14:29:36 -0700 (PDT) Received: from kiddo.hsd1.wa.comcast.net (c-73-169-152-248.hsd1.wa.comcast.net. [73.169.152.248]) by smtp.gmail.com with ESMTPSA id b81-v6sm31177172pfj.56.2018.05.22.14.29.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 14:29:36 -0700 (PDT) From: "=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=" X-Google-Original-From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: Johannes Berg , "David S. Miller" Cc: linux@endlessm.com, =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] rfkill: Create rfkill-none LED trigger Date: Tue, 22 May 2018 14:29:32 -0700 Message-Id: <20180522212932.5357-2-jprvita@endlessm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180522212932.5357-1-jprvita@endlessm.com> References: <20180522212932.5357-1-jprvita@endlessm.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Creates a new trigger rfkill-none, as a complement to rfkill-any, which drives LEDs when any radio is enabled. The new trigger is meant to turn a LED ON whenever all radios are OFF, and turn it OFF otherwise. Signed-off-by: João Paulo Rechi Vita --- net/rfkill/core.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 6d64d14f4b0a..07235520b00f 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -178,6 +178,7 @@ static void rfkill_led_trigger_unregister(struct rfkill *rfkill) } static struct led_trigger rfkill_any_led_trigger; +static struct led_trigger rfkill_none_led_trigger; static struct work_struct rfkill_global_led_trigger_work; static void rfkill_global_led_trigger_worker(struct work_struct *work) @@ -195,6 +196,8 @@ static void rfkill_global_led_trigger_worker(struct work_struct *work) mutex_unlock(&rfkill_global_mutex); led_trigger_event(&rfkill_any_led_trigger, brightness); + led_trigger_event(&rfkill_none_led_trigger, brightness == LED_OFF ? + LED_FULL : LED_OFF); } static void rfkill_global_led_trigger_event(void) @@ -202,22 +205,32 @@ static void rfkill_global_led_trigger_event(void) schedule_work(&rfkill_global_led_trigger_work); } -static void rfkill_global_led_trigger_activate(struct led_classdev *led_cdev) -{ - rfkill_global_led_trigger_event(); -} - static int rfkill_global_led_trigger_register(void) { + int ret; + INIT_WORK(&rfkill_global_led_trigger_work, rfkill_global_led_trigger_worker); + rfkill_any_led_trigger.name = "rfkill-any"; - rfkill_any_led_trigger.activate = rfkill_global_led_trigger_activate; - return led_trigger_register(&rfkill_any_led_trigger); + ret = led_trigger_register(&rfkill_any_led_trigger); + if (ret) + return ret; + + rfkill_none_led_trigger.name = "rfkill-none"; + ret = led_trigger_register(&rfkill_none_led_trigger); + if (ret) + led_trigger_unregister(&rfkill_any_led_trigger); + else + /* Delay activation until all global triggers are registered */ + rfkill_global_led_trigger_event(); + + return ret; } static void rfkill_global_led_trigger_unregister(void) { + led_trigger_unregister(&rfkill_none_led_trigger); led_trigger_unregister(&rfkill_any_led_trigger); cancel_work_sync(&rfkill_global_led_trigger_work); }