From patchwork Mon Feb 22 16:36:41 2016 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: 8379751 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 269879F1D4 for ; Mon, 22 Feb 2016 16:38:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 524B8204FC for ; Mon, 22 Feb 2016 16:38:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72929204EB for ; Mon, 22 Feb 2016 16:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753717AbcBVQhN (ORCPT ); Mon, 22 Feb 2016 11:37:13 -0500 Received: from mail-qg0-f53.google.com ([209.85.192.53]:33506 "EHLO mail-qg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148AbcBVQhI (ORCPT ); Mon, 22 Feb 2016 11:37:08 -0500 Received: by mail-qg0-f53.google.com with SMTP id b35so114830659qge.0; Mon, 22 Feb 2016 08:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=ItGVJxk693j6FUCjj8L8Etg0jah8XGG6fKDNIGg/Bag=; b=v5EBNjtixu8wv/LjeZnNUI9h4ds5h6cVNQFDRpZD5qhTazPFKBcz/wnxXXZ+mRvxsq CILKasTt83qtpHALqBT1rIa+rdUdGCigbtE9s0+gG24XiitE3XDO17Vm0Eq0gMc1Kpgw i6J3rTRFGXOOSmJd9Kn9+v8zn7Fae2ziwFGuiE4TENTOSekbvW5PGcewHW/xa5gPlCj7 klyewnQMz1A3nOLd+hg3RsRu51UPKn21tVUONciXQYSBYaUOaNdiA8VMKBJKKV84+lV9 mQlMAPcIlkarsQV3YGZsnMRMgui+y+GHetv+L4r34s0e0WDJ5119WtCFg15H+uB2ASx9 3pqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=ItGVJxk693j6FUCjj8L8Etg0jah8XGG6fKDNIGg/Bag=; b=j5bppRr1bQaJaL4tZE84xlCSnF7MXQxii8qWvt6x4zAos8y9bd5unSsfPX3nfi0VEq 6QdOMi/ByVV+Zit/ebkQxr5d6Akh4qUEL4EmwYBqPtrrbfTmmJPWyulhtbWA1T0fxxlU xqPLSWvYmbWpA//MbiwUQOXeLOR7CmsUqdJ2V0b9xxld8Bmbo04FT3+MPhWQ+/i5p8TA rGtJXeghhfMhn7sBu6DqmmOXwjyKOImML/Fn3DBaQfx2JzDi7v7yQqFmhJn/1dMQrkRi Vyh3WZQ7WO0NQQKHfwIkM6gelVdTDOClv7IFEohUPxFilDKSkuwoyYgzyNxHgtcZob+H 6KJg== X-Gm-Message-State: AG10YOR+HS1q5lT7zKI59NLT+l98y9slb+jSLCn4Wz/KEcR3cD99u1UiJ8gjvw1FREOMKw== X-Received: by 10.140.255.136 with SMTP id a130mr14885355qhd.20.1456159026975; Mon, 22 Feb 2016 08:37:06 -0800 (PST) Received: from kiddo.endlessm-sf.com (c-98-239-150-235.hsd1.wv.comcast.net. [98.239.150.235]) by smtp.gmail.com with ESMTPSA id j67sm6874669qgj.35.2016.02.22.08.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 08:37:06 -0800 (PST) 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 Cc: "David S. Miller" , Darren Hart , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com, =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCHv2 10/10] rfkill: Notify userspace of airplane-mode state changes Date: Mon, 22 Feb 2016 11:36:41 -0500 Message-Id: <1456159001-20307-11-git-send-email-jprvita@endlessm.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456159001-20307-1-git-send-email-jprvita@endlessm.com> References: <1456159001-20307-1-git-send-email-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-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: João Paulo Rechi Vita --- Documentation/rfkill.txt | 3 +++ include/uapi/linux/rfkill.h | 4 ++-- net/rfkill/core.c | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt index 9dbe3fc..588b4bf 100644 --- a/Documentation/rfkill.txt +++ b/Documentation/rfkill.txt @@ -133,5 +133,8 @@ applications to take control. Changes to the airplane-mode indicator state can be made using RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE, passing the new value in the 'soft' field of 'struct rfkill_event'. +This same API is also used to provide userspace with notifications of changes +to airplane-mode indicator state. + For further details consult Documentation/ABI/stable/sysfs-class-rfkill. diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h index 36e0770..2ccb02f 100644 --- a/include/uapi/linux/rfkill.h +++ b/include/uapi/linux/rfkill.h @@ -63,8 +63,8 @@ enum rfkill_type { * are hot-plugged later. * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE: userspace acquires control of * the airplane-mode indicator. - * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE: userspace changes the - * airplane-mode indicator state. + * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE: the airplane-mode indicator state + * changed -- userspace changes the airplane-mode indicator state. */ enum rfkill_operation { RFKILL_OP_ADD = 0, diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 8ea8b73..c59fd1d 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -131,7 +131,20 @@ static struct led_trigger rfkill_apm_led_trigger; static void rfkill_apm_led_trigger_event(bool state) { + struct rfkill_data *data; + struct rfkill_int_event *ev; + led_trigger_event(&rfkill_apm_led_trigger, state ? LED_FULL : LED_OFF); + + list_for_each_entry(data, &rfkill_fds, list) { + ev = kzalloc(sizeof(*ev), GFP_KERNEL); + if (!ev) + continue; + ev->ev.op = RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE; + ev->ev.soft = state; + list_add_tail(&ev->list, &data->events); + wake_up_interruptible(&data->read_wait); + } } static void rfkill_apm_led_trigger_activate(struct led_classdev *led)