From patchwork Mon May 2 14:39:08 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=20Paulo=20Rechi=20Vita?= X-Patchwork-Id: 617558 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qz6Qg4ycWz9t3x for ; Tue, 3 May 2016 00:39:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=sjUAdgTo; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754081AbcEBOjq (ORCPT ); Mon, 2 May 2016 10:39:46 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:33916 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754029AbcEBOj3 (ORCPT ); Mon, 2 May 2016 10:39:29 -0400 Received: by mail-qk0-f193.google.com with SMTP id i7so8697054qkd.1; Mon, 02 May 2016 07:39:28 -0700 (PDT) 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-transfer-encoding; bh=wljCONTI7A2mbdGq5AWFwqf1DvpMjzzZ+ulpV7Ytgak=; b=sjUAdgToPvuLCQQ/FtqFvm8KGbCpsEG73otc1HMbOR+jSxSUeRFqq+Ae2+88E41K/W TvqV9FKHF90acQD+FivFRnyb0f33QP314FbtXjGusC9OosXj1D2CHwA46pjelWjT5p5H IJVdvw+CXz+f17hV8bL7FsW01xwhw86V2mU1tldJHTFC/jabSqSYMpysKPeKkBtpj4GS Ca0tzmFUedTbqmvTdlR6LjjuDNEze3o0IivgAC2n4v/J9RKD26km5HgK3Hbkb1lvbxK1 DiKJAeqM86KC5j/dbid8cDpCTdCvibk3GYpMqj+WFE0yESoYIFEAt5NUV2Q16IfMVlWu BvUQ== 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-transfer-encoding; bh=wljCONTI7A2mbdGq5AWFwqf1DvpMjzzZ+ulpV7Ytgak=; b=PbwQocuqjE9RLXIscep4ps0SGCRdaT02uTvK8ChlFqwpiGpkPdwKerK6CfNp8X85Mz vHvf885n7fWt6FmSgJ4kLj/3jaofJIjiI9lB7/L9DhCvtfx9dtmnS/bJQvJ/0ACAWl7H lXrSHP1GzIqeMtbByBYh+j/zFf31Iw04VlOVxzSSOZYgGzKXb4Dxs9i5fY+FHlKDaaXF G5ZxeBTJHV9oTkVZpIwKerSBcjQxJh+y77Uu8j762gUsL7OwBpzKHIdotNZDlAYNRse2 ej5g0HSdGt52g/e8JPD5UMsZjFdEQ0kon0SWtAjsgGiTn7tdhPCWvxDdeax5qcINQ9l7 pTzA== X-Gm-Message-State: AOPr4FWxWw/TCjvJVZJf8h/Gr3iAtGjgd2iVeHcrkEmop48Jkk3Lv94IrPZS5jiy5J6o8A== X-Received: by 10.55.74.14 with SMTP id x14mr35461014qka.70.1462199967768; Mon, 02 May 2016 07:39:27 -0700 (PDT) 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 23sm9313213qkd.8.2016.05.02.07.39.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 May 2016 07:39:27 -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 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?= , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [RESEND PATCH 3/3] rfkill: Notify userspace of airplane-mode state changes Date: Mon, 2 May 2016 10:39:08 -0400 Message-Id: <1462199948-6424-4-git-send-email-jprvita@endlessm.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462199948-6424-1-git-send-email-jprvita@endlessm.com> References: <1462199948-6424-1-git-send-email-jprvita@endlessm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: João Paulo Rechi Vita 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 95824b3..c4bbd19 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)