Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751219AbbLHVw3 (ORCPT ); Tue, 8 Dec 2015 16:52:29 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:55443 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbbLHVw1 (ORCPT ); Tue, 8 Dec 2015 16:52:27 -0500 From: Arnd Bergmann To: John Stultz Cc: lkml , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Vinay Simha BN , Bjorn Andersson , Haojian Zhuang , devicetree@vger.kernel.org, Android Kernel Team Subject: Re: [RFC][PATCH] misc: Introduce reboot_reason driver Date: Tue, 08 Dec 2015 22:52:08 +0100 Message-ID: <1858873.xsM5XHIlTX@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1449610162-30543-1-git-send-email-john.stultz@linaro.org> References: <1449610162-30543-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:7+fTGJwo8eKMPmEf7VmsfjH+Bzs4Y0VQe1k8XuA0jHsCxoSZOWj m9onSvdgZar/RZKmr5qx1nczeHRpljMqe3fnE6m7CXWQ6cyyYxIOg/XKGCCT8fAdtWIE+jH Hr1ZoY2OEkju2c4u253ET3i53rd4mfu3AUq4lX9L+fnEhf8pKRV4Z1KKVrPNbYXYe3Acv6r Gn144ShJYj3yZ3+GpT1GQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:gqC1IIqn0L4=:TZQHF24r8t5UaqFPr/+oXc 2tIa/ZNOdwMGAdyrvs6k2QWEXzZX0Y3wsGb0RictePST+zZn7GIrDvmlrC+oNY0IPg1N9ChMg Pmm8a+gNip6gIM5tXmVDxIvruHMM+v2v+7Pthh+IOZWmt8GpHPI7w1j6+bgy8nlSz/He7iK5g H55+yeHQ9JMx1USHsnVbsByo/YSAgX3ROJiT6p3ogtCni9HTpOlQToB3maftW9uLFg9Q4RdAh BBTsZgu8YCUMxvOoWR8gW8N8RxZdCa2JqSfV34Jhr02nHE4nZLLbgw7jQc+XdewSSUKldPsWO k0oa6mL6NR98qGNUItKi7QX+2InLENUcIn+y4UFgd8myWB627eHQo9UjTgbXPltYi+qi7/RUx Pm3wnRSnMl2T9yPUXPHSOBaItSmir2oYwM5uhKgnEeFnrJFu4BEuACruFcqn5PmewnCw87nEx fddIC0LQQd8bznkNq7fkuokDhhT7YAawuKPgxyEqaKYUSZPsjUCgZaIX/YUTx/PxKCgHL2zr0 +ngOnlePFO33S34/JiMo4lV43dycGmsOoc1Nk9X/yFqw9f5h7mvfIVj+UUVoB7a8xYjiNHxjV ieZ0fyZB4sndAfF3/QvoesiTkfia6xi2RELxCQkkIXTWR2oUn4rR2eNjhrb2B3JguzHAHkPI9 8Soo2yeAiw1nR5bpHPId1PlaETR5UwmBwdIwGN7DMkUoJ7vsg9cxHJaW9xiwpG+gmyzTPWKeU dS+9jnFrc1Ur6Qsq Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2623 Lines: 89 On Tuesday 08 December 2015 13:29:22 John Stultz wrote: > diff --git a/arch/arm/boot/dts/qcom-apq8064-nexus7-flo.dts b/arch/arm/boot/dts/qcom-apq8064-nexus7-flo.dts > index 5183d18..ee5dcb7 100644 > --- a/arch/arm/boot/dts/qcom-apq8064-nexus7-flo.dts > +++ b/arch/arm/boot/dts/qcom-apq8064-nexus7-flo.dts > @@ -282,6 +282,15 @@ > }; > }; > > + reboot_reason: reboot_reason@2a03f65c { > + compatible = "reboot_reason"; This is not a good compatible string. There should generally be a vendor name associated with it (use "linux," if nothing else, and you should have '-' instead of '_'. > + reg = <0x2A03F65C 0x4>; This may easily conflict with the device it is part of. We should have non-overlapping register areas in general. For the example you are looking at, which register block is this? > + > +/* Types of reasons */ > +static enum { > + NONE, > + BOOTLOADER, > + RECOVERY, > + OEM, > + MAX_REASONS > +} __maybe_unused reason_types; The variable seems to always be unused, not just "__maybe_unused". Maybe remove it? > +static int reboot_reason(struct notifier_block *nb, unsigned long action, > + void *data) > +{ > + char *cmd = (char *)data; > + long reason = reasons[NONE]; > + > + if (!reboot_reason_addr) > + return NOTIFY_DONE; > + > + if (cmd != NULL) { > + if (!strncmp(cmd, "bootloader", 10)) > + reason = reasons[BOOTLOADER]; > + else if (!strncmp(cmd, "recovery", 8)) > + reason = reasons[RECOVERY]; > + else if (!strncmp(cmd, "oem-", 4)) { > + unsigned long code; > + > + if (!kstrtoul(cmd+4, 0, &code)) > + reason = reasons[OEM] | (code & 0xff); > + } > + } > + > + if (reason != -1) > + writel(reason, reboot_reason_addr); > + return NOTIFY_DONE; > +} Will this reboot the machine? > + /* Install the notifier */ > + restart_nb.notifier_call = reboot_reason; > + restart_nb.priority = 256; > + if (register_restart_handler(&restart_nb)) { If not, you should use register_reboot_notifier() rather than register_restart_handler(). The former gets called to do something just before rebooting, while the latter attempts to actually reboot the machine. > +static int __init reboot_reason_init(void) > +{ > + return platform_driver_register(&reboot_reason_driver); > +} > +arch_initcall(reboot_reason_init); Why this early? If it can be a normal device_initcall, you can use module_platform_driver(). Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/