From patchwork Wed Jan 22 16:32:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 23549 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55802203C6 for ; Wed, 22 Jan 2014 16:32:11 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf1347009pab.1 for ; Wed, 22 Jan 2014 08:32:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=PTBxDImyeBZr1Z9hJN96E3nNA5fr0g0sF73IZ7aS5Gs=; b=DM+PrCT3Qa2iPjNt1WWunAr6EPUxz8ih0d+Hl+FVqiELSmK1WD4JmD+LQWtm0COndO uW8BTl8mHhHDaoLKWX7AF4X0kwLH5GI3cu2rG2tsnA7hwqDzZ2Ms6CzyAgwz4mDJj+a4 TJb4K3PvfiIsvucmIwRiSLNCGnfJqYouyNoTJJOn3a2jySbDcYKeLA916J/Y8l+M4Sfo RH6LYhaQ+mm58wOzTqudl2CT9iIs7g/ai2gTjcceHzYhTee25bu6iZWl0m50zuO0zC3Z R8iQjZGjX9NxKuHGX6R5a5BpAtX+kD55Zxt/F0Xp+/JvzQ1LSEA1BFv58IL+1AETkR+Y DGRA== X-Gm-Message-State: ALoCoQkak3IkrqZBVqsZATNo/B9bxAD0DtOQlOV1BPNTLavCh+5ODY+ik46OmznKspIqEuj883I0 X-Received: by 10.66.231.132 with SMTP id tg4mr822520pac.31.1390408330602; Wed, 22 Jan 2014 08:32:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.196 with SMTP id q4ls103473qed.11.gmail; Wed, 22 Jan 2014 08:32:10 -0800 (PST) X-Received: by 10.220.247.68 with SMTP id mb4mr661921vcb.37.1390408330459; Wed, 22 Jan 2014 08:32:10 -0800 (PST) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id ja16si4840036vec.126.2014.01.22.08.32.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 08:32:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id w20so351753vbb.41 for ; Wed, 22 Jan 2014 08:32:10 -0800 (PST) X-Received: by 10.220.170.68 with SMTP id c4mr452964vcz.41.1390408330369; Wed, 22 Jan 2014 08:32:10 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp196613vcz; Wed, 22 Jan 2014 08:32:09 -0800 (PST) X-Received: by 10.68.196.164 with SMTP id in4mr2621623pbc.128.1390408329406; Wed, 22 Jan 2014 08:32:09 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vk8si3231037pbc.293.2014.01.22.08.32.09; Wed, 22 Jan 2014 08:32:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbaAVQcI (ORCPT ); Wed, 22 Jan 2014 11:32:08 -0500 Received: from fw-tnat.austin.arm.com ([217.140.110.23]:58725 "EHLO collaborate-mta1.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751379AbaAVQcI (ORCPT ); Wed, 22 Jan 2014 11:32:08 -0500 Received: from hornet.Cambridge.Arm.com (hornet.cambridge.arm.com [10.2.201.45]) by collaborate-mta1.arm.com (Postfix) with ESMTP id 98C8B13F841; Wed, 22 Jan 2014 10:32:04 -0600 (CST) From: Pawel Moll To: linux-leds@vger.kernel.org, Bryan Wu , Richard Purdie Cc: Linus Walleij , Pawel Moll Subject: [PATCH] ledtrig-cpu: Handle CPU hot(un)plugging Date: Wed, 22 Jan 2014 16:32:02 +0000 Message-Id: <1390408322-1284-1-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-leds-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-leds@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pawel.moll@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When CPU is hot(un)plugged, no syscore notification is being generated, nor is cpuidle involved. This leaves the CPU LED turned on, because the dying thread is doing some work (LED on) and than it is... well, dying (LED still on :-) Added notifier block for hot(un)plugging operations, generating existing trigger events. Signed-off-by: Pawel Moll --- drivers/leds/trigger/ledtrig-cpu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c index 118335e..1c3ee9f 100644 --- a/drivers/leds/trigger/ledtrig-cpu.c +++ b/drivers/leds/trigger/ledtrig-cpu.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../leds.h" #define MAX_NAME_LEN 8 @@ -92,6 +93,26 @@ static struct syscore_ops ledtrig_cpu_syscore_ops = { .resume = ledtrig_cpu_syscore_resume, }; +static int ledtrig_cpu_notify(struct notifier_block *self, + unsigned long action, void *hcpu) +{ + switch (action & ~CPU_TASKS_FROZEN) { + case CPU_STARTING: + ledtrig_cpu(CPU_LED_START); + break; + case CPU_DYING: + ledtrig_cpu(CPU_LED_STOP); + break; + } + + return NOTIFY_OK; +} + + +static struct notifier_block ledtrig_cpu_nb = { + .notifier_call = ledtrig_cpu_notify, +}; + static int __init ledtrig_cpu_init(void) { int cpu; @@ -113,6 +134,7 @@ static int __init ledtrig_cpu_init(void) } register_syscore_ops(&ledtrig_cpu_syscore_ops); + register_cpu_notifier(&ledtrig_cpu_nb); pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); @@ -124,6 +146,8 @@ static void __exit ledtrig_cpu_exit(void) { int cpu; + unregister_cpu_notifier(&ledtrig_cpu_nb); + for_each_possible_cpu(cpu) { struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);