From patchwork Mon Jun 5 07:36:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce ZHANG X-Patchwork-Id: 9765659 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 E7B0E602BF for ; Mon, 5 Jun 2017 07:39:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D758420072 for ; Mon, 5 Jun 2017 07:39:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D6720408; Mon, 5 Jun 2017 07:39:35 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E9F2820072 for ; Mon, 5 Jun 2017 07:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KcfBl6vxiJZDk5cUctOKTX9nntTxY2CgNm2vfdqGqPs=; b=PQ7F8pJ//mc8Yd FuAtDUuqIonStDYxRRAgWLKkoEs+GMcybk6E6P+KKAgwm0nP01Ix7VDCxpslSrj4ZjKVly/riVDaK VXJ2CtXV8iuvONBBtg/fRsStGFTrBS77PItqrhlKy9hQZ3+oe6Uhx+lhmDZNrMXPgg8llqOpCB9RA SRgmIZhM7DKBL4BJe7a8m6gfAiKnGYcIS1a8RDPv5LbDoJaKATLA8mfsKzSKNwGT4FYr8eVBvhltu pX9oomDiYOO4v75cmfv/Kl1r6DP0aXleOP9ye5quHRhYNkz+aa17T0vMdz7FCghX+g81o3UYB+hlO g1PsiHFW4phSKBsahPww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dHmbr-0006zO-5e; Mon, 05 Jun 2017 07:39:31 +0000 Received: from mail-eopbgr00044.outbound.protection.outlook.com ([40.107.0.44] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dHmbm-0006yh-QH for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2017 07:39:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Jm5xDT1haitE+1w7yPMvi3KBY+iw2EKWDKlX0JfMQgs=; b=CC7fOIwk3hFZBoAUPeSvv6+l/BXhivZfUECRCWwCzHmzpQWxtvxlIYXWXoo9+hDEbS/Au996SrRuuYWDFPbYAXyoYzWpjETLdqpbzz2Cb0REzWq8OcH6gQBnEkE9t5vhSqLcW3ZtPovPxu1KovTtcCTLQC4b4Jk7Wkw/PtG0nDw= Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none; lists.infradead.org; dmarc=none action=none header.from=nxp.com; Received: from szandroidmpu-PowerEdge-T430.ap.freescale.net (192.158.241.86) by AMSPR04MB406.eurprd04.prod.outlook.com (2a01:111:e400:8037::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10; Mon, 5 Jun 2017 07:38:58 +0000 From: Zhang Bo To: linux-arm-kernel@lists.infradead.org Subject: [[PATCH]] drivers: leds/trigger: system cannot enter suspend Date: Mon, 5 Jun 2017 15:36:31 +0800 Message-Id: <1496648191-134355-1-git-send-email-bo.zhang@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [192.158.241.86] X-ClientProxiedBy: HK2P15301CA0014.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::24) To AMSPR04MB406.eurprd04.prod.outlook.com (2a01:111:e400:8037::14) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMSPR04MB406: X-MS-Office365-Filtering-Correlation-Id: bcfb95a1-39cf-4537-d207-08d4abe5ef22 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:AMSPR04MB406; X-Microsoft-Exchange-Diagnostics: 1; AMSPR04MB406; 3:MMlKi13+s6wFmHoefvzZlt1SLAlU/hOFfCt6URZCvZKFMh9RMw/8z7fLELWT/CLGP6hDkgU18s/gmFEOcT9fIaNHw6wRL1GUFdzH3SpDppRaj89GB11WHx9dIbD6wdh8/t5hwEDuC+x5nO7wETtfz9JFSAc4wBBcVEVabWu8bma1EzqsFq2749r39r8bHInLN48gshr8ePTzXzzPI5EwpbVAWcq9J5+74/SHwH7i6MkkDUYwQcAh9TUXKJHfFFhaWUhLSv9ey9Vf7cWcjEQjE0R6S24sgCJPn8onGux58OnV+dp5zmCRrZ+BB9wVsNNVPJWzYiIdgil18ax/OMrrtPPB7thjCYmox+DxPjKWV7w=; 25:4mtiSkffsB06SwDcYM6/4v6bOCs7AHR+fZfL0lpT8Nu+diFVNe9VLdJ9qJR8tmwHf40t6EZ0yY95Md4zkPn0+vXqk8M0vCFL9CQz7V/zmm2WSBFe2/y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r6kWpmSz5TCWVxZaigW4VLwEzuV1DzVaQeMhBB2m9UvJFOqm1yyCZQJVbhj04dBVQM7MToTsUpnX8ReqUC0MqFpFraUFFwpl9HQFyltDlb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(20161123558100)(20161123562025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AMSPR04MB406; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AMSPR04MB406; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR04MB406; 4:R6br/HfLWQ5tpo0cqCUXUpUClz9eB5mDk/rI3WlUqjO?= =?us-ascii?Q?dkoJCxggdaBrmK4jwsyR3ABZGVRSJ8sq21McF6RcMpsymAQ2UmOJ3IrS40MV?= =?us-ascii?Q?36GEXMOJJbVaQTYiFOiRo6MrMzyiAV+GvlA98goAX65ksXXI7SCFK8dW54Kw?= =?us-ascii?Q?EJJjMfjY0PV4Huo+pX6pcOZ8LdoktPO+YDpdMePQsEgyb6VoUCOLdyzi86TV?= =?us-ascii?Q?pHj3rI+3eEF/NImoYR+ZnBHHzsuXJEkJcxhm5+/lMYLtPZ6FbmGXpsR5/fbg?= =?us-ascii?Q?xEMG5UWB6nzsfdgOeEvgwkP45Qs06G1V4H8mbcPNdyk7b1M8HruWpNlb8l4z?= =?us-ascii?Q?n18BXMfVQPs+AbfEZOu2hn+wMe0oKPLfoww/CpMF5b2pbwfsGnjn7edzjWYZ?= =?us-ascii?Q?YJIIGoXhgUH6bgSacIvqCFBBZo6ADjcmV3jjNPuYKs0Vw5yaz/knxtmS/l3y?= =?us-ascii?Q?R41aNanBqmCGd4QQHD4C2fk18QgOSaEs29yUe0vjdTugkL4ZOH0L3O0Xy6p5?= =?us-ascii?Q?2+2gPBnJ1NB2bQcPxprd1CjLBtGnwPFUfsYY2uhPLHARX/A1ExrriH5hoANV?= =?us-ascii?Q?6e6vA23qk+eSTp5VsIW8gg1QtjMloeO3W2iAYk+54kEzjvM+5MPhA8Rwrv53?= =?us-ascii?Q?yPCdrGmUhZj7WwSsyv/VeuQ42GyEOpycXbGepCXBk/eworISAYZBOUrpk7If?= =?us-ascii?Q?egjHHlW2xsEvNxbU/h1hI7rlqA1eK8PapmJqqahWXqdhErKRXmZDKoyjpzGt?= =?us-ascii?Q?pftMWuGOu6DWuGqAUl3m038dW4Xyu1VHKouXzoPCilsQ7nttNCeyPQpDrYrx?= =?us-ascii?Q?Yd3TRaesh6qmTLwSrGezSVg4iSzKF6Ctdnv3Tbkj9lUgyDTX5FpIDEYZPN7S?= =?us-ascii?Q?P8nhaI2C5sddjk/lR9wN6E1qtpc8Fh2Bp81M33rhNcjd8GC5oJnkyNTHn2/T?= =?us-ascii?Q?1zk+VnUzXs4yF32Ai6/wJgaRpCA7KHIg9CXdaQjqb62mrdg5ZIaHz1qmPj7P?= =?us-ascii?Q?cBX0yXztNdqC8n1f+cVL+qUWNhfV69rRDDWV81HIp2omR5Q70oea1vRWfzPi?= =?us-ascii?Q?9sQEfFml25RbnBSRSJiSbUYcukgHqWndlatNO6rdAVtReGJ0eo9gnSsYdBJ3?= =?us-ascii?Q?HFwzAovm5AsmnTMgve+Pv8BtM2yYoCg2KYG8T9pNEPgAZICQ2iz6daiWtNzp?= =?us-ascii?Q?nwZ5pFNb1baTB8yp16Tlu/eHjB9nSu0hG?= X-Forefront-PRVS: 0329B15C8A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(39410400002)(6666003)(5003940100001)(42186005)(6486002)(15650500001)(5660300001)(6506006)(478600001)(50226002)(25786009)(8676002)(53936002)(6916009)(86362001)(6512007)(189998001)(81166006)(36756003)(66066001)(4326008)(38730400002)(50986999)(50466002)(33646002)(47776003)(110136004)(7736002)(6116002)(305945005)(2351001)(48376002)(2361001)(2906002)(3846002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR04MB406; H:szandroidmpu-PowerEdge-T430.ap.freescale.net; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR04MB406; 23:I5AoSDx5JsPB7FDfszCNc31RgGFap3yXOb7xpjOWyY?= =?us-ascii?Q?tPqASgMPsNfiUGGXXAjbcJT4JyMcsg4ZEDUUz19F2RINMRcBoo/3z/pj14t3?= =?us-ascii?Q?DsJ0sfpajaBFTIc6+tAVAaxBn/0kvg4SXoDs/itXvEXdEVeqQDsQWdAs7spR?= =?us-ascii?Q?LO/gdHTtp02h28UmAp7c8y1Azj9p6e0hyspcHJ7QlRsqNKdRpDeOQ3ijAQlp?= =?us-ascii?Q?x95rTzcGAyvqB/0w1sXUBdf6NB/bFK3H9R49DtsLd6J0vGDZxH9+lpjo+zUV?= =?us-ascii?Q?XJ6Eg3ny8TmLeqk4wPsBsShL8/fSCKFzmZFMLo3ewn4o25zDcktt8LcfIR7/?= =?us-ascii?Q?fybK73YuRJHR3jKwMuYtPRoH9nQZy5trjTmzo6xfr4txcqQwP0PCaMCVC4ou?= =?us-ascii?Q?AoZiNRoNc9c/TWia2Tmtg7J93ZoV4WJfIWML++j0HoFa3oXXV6MTqVKqP7CZ?= =?us-ascii?Q?3v64kBY//QIGMHwXqI4+/3L72kRXpJMK6aUE5R8is7LQTogtGqphvmnGYw8l?= =?us-ascii?Q?w+7eU1wGdmZ1DIT71bZM06us1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f3JqmNvxbPT9ueJKPJJeuDgpVw1YPeodM/q01+gjJGUXjsDjbh4OVk+ulVn3Yuihyp3892Bb718yboATQqqftwk9QCdjnp/hoFlyiQg9uXexlJ4+i/sTxHFqeFhitf1gosbkJFArarN6AJevs9wWXWaN/xX0LZdT6FbbNFPSVkP76WCIFV2ir8F9OxMEvlhB4pHVNb2hvl++K3/qlXhLj0gcvogh7TmTz3/fX92ORNoUpJt3+S+63D0n/9hMSqrUV3J/L/X325sb3qblXluki66d4c89U0aaeOiOLnZ1U4= X-Microsoft-Exchange-Diagnostics: 1; AMSPR04MB406; 5:n31GPpdmL7jszrRkvq1WpoMcMtSbXPY5jzKKf0+rQafGW8YEYNXkOLTLDIAGXyVdkvAngW4yL/M7qixxrXfjhamZUtliZ73aqy7u2BV3rfLsm7X+gPzms3ns4RcrNqRvLzPlmWo7IH9v0pnJq7v2dfdwZMjsc6XoklC3s0zLelTjGMh4+nUGmZxc8dalvBrhDyT5phfs74xOMJCaVGvTrVXO1A8V0Ta1otyFe/WXl9Zy4W5JtfCUcA7zxrJ6TUT+8CQC69cnlRXmRZVUOTg018oXDK5ZKlw/UfMZw7YF6LzpEQQK+UaR/+8WtfYyY2mWSqHn3f2A+iX9DAKhuSOs4wnu5Pp5dNDExoT5ygTwPMpZF9dcJyoaloooUAepfUwZVa2GqHBcj2Kji9vVZ6xVWjiDgEO/LcUHcl15cE11rXwgF2AxLaI7RFsvvUPXyuS4NUR0IpwkPnBQqbJ505ZafRcYvVOMXGOrRq1w1NttMUWavfKLrY/i3X+A9ln3aYAo; 24:cSdGmiD7WC0ECDDAxuATRbliQN4Bu3bf5GVHG4/uzkcYzEQhuwSzJtHKG83OLcd7KmK/Gm1aep7qmq3DttntxVsqxHRtSi/ywGrAEaEjP0Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AMSPR04MB406; 7:sWFnlC3P3QiG2wr5ti4HOR0eK9btIRKBRP1AMPcy18wIo2gJ8FQqibBQawyEiBI1QXwt4y6ytf2QVRIPLKyrbwQM9a1KWlC/ez4IfI3dpW2up+42tIc39NflRMARwWTLS8Afke53Z/89DXQLerFRnkjLllHlNZMdDZszQnPJN9AFtEgNxcez+/SpepXDg052+KvG4DbxCLukj2emWAG0jbgjaywZqFsQr61VZzU1uzWQ/AAsAA38PvKsHq1ihkec5FnTMCZdfFMtpex3xmvhEDFR199t/j9RYdu9O6abv25VEkex448lgpRKoRkY3+ni9JLaWyusmBwUfMxbbu17HQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2017 07:38:58.8919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR04MB406 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170605_003927_232545_F8155004 X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jacek.anaszewski@gmail.com, pavel@ucw.cz Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP System cannot enter suspend mode because of heartbeat led trigger. Heartbeat_pm_notifier is called when system prepare to enter suspend mode, then call led_trigger_unregister to change the trigger of led device to none. It will send uevent message and the wakeup source count changed. Add suspend/resume ops to the struct led_trigger, implement these two ops for ledtrig-heartbeat. Add led_trigger_suspend/led_trigger_resume funcitons to iterate through all LED class devices registered on given trigger and call their suspend/resume ops and disable/enable sysfs at the same time. Call led_trigger_suspend{resuem} API in pm_notifier function to suspend/resume all led devices listed in given trigger. Signed-off-by: Zhang Bo --- drivers/leds/led-triggers.c | 34 +++++++++++++++++++++++++++++++ drivers/leds/trigger/ledtrig-heartbeat.c | 35 ++++++++++++++++++++++++++------ include/linux/leds.h | 6 ++++++ 3 files changed, 69 insertions(+), 6 deletions(-) mode change 100644 => 100755 drivers/leds/led-triggers.c mode change 100644 => 100755 drivers/leds/trigger/ledtrig-heartbeat.c mode change 100644 => 100755 include/linux/leds.h diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c old mode 100644 new mode 100755 index 431123b..1cb1674 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -333,6 +333,40 @@ void led_trigger_blink_oneshot(struct led_trigger *trig, } EXPORT_SYMBOL_GPL(led_trigger_blink_oneshot); +void led_trigger_suspend(struct led_trigger *trig) +{ + struct led_classdev *led_cdev; + + if (!trig) + return; + + read_lock(&trig->leddev_list_lock); + list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) { + if (led_cdev->trigger->suspend) + led_cdev->trigger->suspend(led_cdev); + led_sysfs_disable(led_cdev); + } + read_unlock(&trig->leddev_list_lock); +} +EXPORT_SYMBOL_GPL(led_trigger_suspend); + +void led_trigger_resume(struct led_trigger *trig) +{ + struct led_classdev *led_cdev; + + if (!trig) + return; + + read_lock(&trig->leddev_list_lock); + list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) { + if (led_cdev->trigger->resume) + led_cdev->trigger->resume(led_cdev); + led_sysfs_enable(led_cdev); + } + read_unlock(&trig->leddev_list_lock); +} +EXPORT_SYMBOL_GPL(led_trigger_resume); + void led_trigger_register_simple(const char *name, struct led_trigger **tp) { struct led_trigger *trig; diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c old mode 100644 new mode 100755 index afa3b40..8f779dd --- a/drivers/leds/trigger/ledtrig-heartbeat.c +++ b/drivers/leds/trigger/ledtrig-heartbeat.c @@ -142,6 +142,7 @@ static void heartbeat_trig_activate(struct led_classdev *led_cdev) led_heartbeat_function(heartbeat_data->timer.data); set_bit(LED_BLINK_SW, &led_cdev->work_flags); led_cdev->activated = true; + led_cdev->suspended = false; } static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) @@ -154,6 +155,30 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) kfree(heartbeat_data); clear_bit(LED_BLINK_SW, &led_cdev->work_flags); led_cdev->activated = false; + led_cdev->suspended = false; + } +} + +static void heartbeat_trig_resume(struct led_classdev *led_cdev) +{ + struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; + + if (led_cdev->suspended) { + setup_timer(&heartbeat_data->timer, + led_heartbeat_function, (unsigned long) led_cdev); + heartbeat_data->phase = 0; + led_heartbeat_function(heartbeat_data->timer.data); + led_cdev->suspended = false; + } +} + +static void heartbeat_trig_suspend(struct led_classdev *led_cdev) +{ + struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; + + if (led_cdev->activated && !led_cdev->suspended) { + del_timer_sync(&heartbeat_data->timer); + led_cdev->suspended = true; } } @@ -161,25 +186,23 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) .name = "heartbeat", .activate = heartbeat_trig_activate, .deactivate = heartbeat_trig_deactivate, + .suspend = heartbeat_trig_suspend, + .resume = heartbeat_trig_resume, }; static int heartbeat_pm_notifier(struct notifier_block *nb, unsigned long pm_event, void *unused) { - int rc; - switch (pm_event) { case PM_SUSPEND_PREPARE: case PM_HIBERNATION_PREPARE: case PM_RESTORE_PREPARE: - led_trigger_unregister(&heartbeat_led_trigger); + led_trigger_suspend(&heartbeat_led_trigger); break; case PM_POST_SUSPEND: case PM_POST_HIBERNATION: case PM_POST_RESTORE: - rc = led_trigger_register(&heartbeat_led_trigger); - if (rc) - pr_err("could not re-register heartbeat trigger\n"); + led_trigger_resume(&heartbeat_led_trigger); break; default: break; diff --git a/include/linux/leds.h b/include/linux/leds.h old mode 100644 new mode 100755 index 64c56d4..b792950 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -111,6 +111,7 @@ struct led_classdev { void *trigger_data; /* true if activated - deactivate routine uses it to do cleanup */ bool activated; + bool suspended; #endif #ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED @@ -254,6 +255,8 @@ struct led_trigger { const char *name; void (*activate)(struct led_classdev *led_cdev); void (*deactivate)(struct led_classdev *led_cdev); + void (*suspend)(struct led_classdev *led_cdev); + void (*resume)(struct led_classdev *led_cdev); /* LEDs under control by this trigger (for simple triggers) */ rwlock_t leddev_list_lock; @@ -291,6 +294,9 @@ extern void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger); extern void led_trigger_remove(struct led_classdev *led_cdev); +extern void led_trigger_suspend(struct led_trigger *trig); +extern void led_trigger_resume(struct led_trigger *trig); + static inline void *led_get_trigger_data(struct led_classdev *led_cdev) { return led_cdev->trigger_data;