From patchwork Mon Jan 29 19:49:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 0v3rdr0n3@gmail.com X-Patchwork-Id: 10191159 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 D338660388 for ; Tue, 30 Jan 2018 00:50:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C17FC28560 for ; Tue, 30 Jan 2018 00:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3043288FD; Tue, 30 Jan 2018 00:50:07 +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=-5.4 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_HI autolearn=ham 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 3009828560 for ; Tue, 30 Jan 2018 00:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752083AbeA3AuG (ORCPT ); Mon, 29 Jan 2018 19:50:06 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:36139 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbeA3AuF (ORCPT ); Mon, 29 Jan 2018 19:50:05 -0500 Received: by mail-io0-f194.google.com with SMTP id l17so9595739ioc.3; Mon, 29 Jan 2018 16:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=n0HuZyn2pseC1QxsZfMjxTBknYVCg52A6ThjyAZGDco=; b=p9USuyzLjQdqvoQhFfawkENoEgm/pA2f9FcduYintiUe8wjxSVcMJwPuCN8j1pfIWD R9HpAMINXp7U/BW2YHepndKjKL+K1RIORI4ocWyq9hCjX1yrrFz8B+JglEljkTNjA8Wu QCcYrPfNKYihd1nektiHDhvM4yo1bbRpp7l6NASyQiY4ICBku2dVSffvb1lwTV7tdSUq uUNbCfqTs0ZGTb2tZDvPStUZPXKqX1aDBlghGd86F0KdUTbECPZUFUPqdY2Nh7Ru7kGX zYITTr7FcuaSeVcy6nyurdRELR7BEbwHPKyu1+Bkpzd2FPP0uLRoJCyAK1BTgklX4GxX O/Tw== 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; bh=n0HuZyn2pseC1QxsZfMjxTBknYVCg52A6ThjyAZGDco=; b=hIOFUPfJgFT+GD45TBKplIx2PAiARpyAF8GaI91HQJRA6lesAMAhdkOPQr7mMa0227 HWI+bnzRt+3E+hbd9ZowXwfB0FcWATbFHXVgLNay7s4Rs5XoweZPAfVlOr9R/i5sRAbd GVDTVxBjID+eom6GDzFiwT4mPF9FqQST/g0aGU0BLSXd/4hEMS3i3detd8Zp2bMe+6Kw ZDf6EH2U3uWGeY4i3k6bhx43LHHAo4TSNgX5PygQsEKcKqETQRgFUzlq6HGhcIaHBaLm SvVGmlqkWFE+TRtxUhf8ufwLPT/HMg7UNkUqbUpJNtQ1YNeebwi00TkEZRS90DEe6GnG Pz4w== X-Gm-Message-State: AKwxytcTWeDqFqJSbMiG0Pwa3lA8QpxBXOLS/ZpXJtOeigJ/D6CdXGQs YEKYf4Yt00btBOGfP7afByipgg== X-Google-Smtp-Source: AH8x226c9rHHFca/LxHgY18Nrv53GygSrWENPRlFa6TG46JYyWnZXklbx9tAttAI0kW5SGGEs5EeSA== X-Received: by 10.107.185.215 with SMTP id j206mr2081997iof.181.1517273404683; Mon, 29 Jan 2018 16:50:04 -0800 (PST) Received: from pride.cinci.rr.com ([2605:a000:1620:4222:f2d5:bfff:fe92:899d]) by smtp.gmail.com with ESMTPSA id o141sm4946613ito.42.2018.01.29.16.50.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 16:50:04 -0800 (PST) From: 0v3rdr0n3@gmail.com To: linux-pm@vger.kernel.org, linux-leds@vger.kernel.org Cc: samorris@lexmark.com Subject: [PATCH] leds: use QoS to control LED suspend behavior from userspace Date: Mon, 29 Jan 2018 19:49:47 +0000 Message-Id: <20180129194947.11071-1-0v3rdr0n3@gmail.com> X-Mailer: git-send-email 2.16.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Samuel Morris Signed-off-by: Samuel Morris --- drivers/leds/led-class.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index f2b0a80..9e9e265 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "leds.h" @@ -196,6 +197,11 @@ static int led_suspend(struct device *dev) { struct led_classdev *led_cdev = dev_get_drvdata(dev); + if(dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF) == + PM_QOS_FLAGS_ALL) { + return 0; + } + if (led_cdev->flags & LED_CORE_SUSPENDRESUME) led_classdev_suspend(led_cdev); @@ -206,6 +212,11 @@ static int led_resume(struct device *dev) { struct led_classdev *led_cdev = dev_get_drvdata(dev); + if(dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF) == + PM_QOS_FLAGS_ALL) { + return 0; + } + if (led_cdev->flags & LED_CORE_SUSPENDRESUME) led_classdev_resume(led_cdev); @@ -287,6 +298,18 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) list_add_tail(&led_cdev->node, &leds_list); up_write(&leds_list_lock); + /* Attempt to let userspace take over the policy. */ + ret = dev_pm_qos_expose_flags(led_cdev->dev, + PM_QOS_FLAG_NO_POWER_OFF); + if (ret < 0) { + dev_warn(led_cdev->dev, "failed to expose pm_qos_no_poweroff\n"); + return 0; + } + + ret = dev_pm_qos_update_flags(led_cdev->dev, + PM_QOS_FLAG_NO_POWER_OFF, + 0); + if (!led_cdev->max_brightness) led_cdev->max_brightness = LED_FULL;