From patchwork Thu Oct 2 18:24:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Kan X-Patchwork-Id: 5019931 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CAD1AC11AB for ; Thu, 2 Oct 2014 18:24:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFF372013A for ; Thu, 2 Oct 2014 18:24:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE6C4201FA for ; Thu, 2 Oct 2014 18:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbaJBSYP (ORCPT ); Thu, 2 Oct 2014 14:24:15 -0400 Received: from exprod5og122.obsmtp.com ([64.18.0.192]:38180 "HELO exprod5og122.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751290AbaJBSYO (ORCPT ); Thu, 2 Oct 2014 14:24:14 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]) (using TLSv1) by exprod5ob122.postini.com ([64.18.4.12]) with SMTP ID DSNKVC2YTcSZABfG+GzRgfxePE30ZtSoQPjX@postini.com; Thu, 02 Oct 2014 11:24:14 PDT Received: by mail-pa0-f48.google.com with SMTP id eu11so3108911pac.21 for ; Thu, 02 Oct 2014 11:24:12 -0700 (PDT) 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; bh=j2a/Abdk1LDdJTuZpiSEhKl3aXtE0BprBr2/OBqjF8c=; b=gJzz3S+AnzD+kJMt8GSEkkaaPwsLV0ouwlxKUYdlhark6YPRgkTte7C66kVMAMnKcH 84zJkKTJRWWptGliKUKXrdeJe63W4ArPfSdS+hHpF8QnNbQmfbk9KAt5pCRGYqaGgC4a CVaVlbxh8JsmzRECyfsObLjA9YpZvQFW6KtCelmg/EdQotRX3upSVJIHev+c39Sv26fb MV44d0YBYXOSHEOB5/NK+8Yo+Xa0qL5uPcaYqxOvAhazfLxiGlWZTNitMLd4EjygSADZ eDtJW01UlZ8evsBX8hrPJA2eHZqUE1HfFN7XfkJiqQwAEfhz7g3gsCoyZ0dGEhWCS/35 vdBw== X-Gm-Message-State: ALoCoQlQT7sfzzO72swX4XRbaJbyxoLvPkqt8NZPBoME92MtwKmwCmjjHLbu3+8cyaOu57Nd5+ZUPU6QxwYkq+R2R8YfW4FuGzDLEBHzJvPyT4Nk7/BCMjv5JGbWuV++ZUblW5p/VIfYskrJrkB2nfejKY52c5etdA== X-Received: by 10.69.31.138 with SMTP id km10mr658955pbd.67.1412274252838; Thu, 02 Oct 2014 11:24:12 -0700 (PDT) X-Received: by 10.69.31.138 with SMTP id km10mr658803pbd.67.1412274251637; Thu, 02 Oct 2014 11:24:11 -0700 (PDT) Received: from fkan-lpt.amcc.com (67-207-112-226.static.wiline.com. [67.207.112.226]) by mx.google.com with ESMTPSA id gj1sm4340476pbc.85.2014.10.02.11.24.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Oct 2014 11:24:11 -0700 (PDT) From: Feng Kan To: linux@roeck-us.net, dbaryshkov@gmail.com, linux-kernel@vger.kernel.org, patches@apm.com, linux-pm@vger.kernel.org, ser@kernel.org Cc: Feng Kan Subject: [PATCH 1/1] power: reset: corrections for simple syscon reboot driver Date: Thu, 2 Oct 2014 11:24:15 -0700 Message-Id: <1412274255-1315-1-git-send-email-fkan@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is to fix some bugs in reboot driver. Which includes auto selection of the MFD_SYSCON for the driver, use of container to locate restart handler, correction of the count down failure timer and ordering of the header file. Signed-off-by: Feng Kan Reviewed-by: Guenter Roeck --- drivers/power/reset/Kconfig | 3 ++- drivers/power/reset/syscon-reboot.c | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index addb26a..3b451e1 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE config POWER_RESET_SYSCON bool "Generic SYSCON regmap reset driver" - depends on POWER_RESET && MFD_SYSCON && OF + depends on POWER_RESET && OF + select MFD_SYSCON help Reboot support for generic SYSCON mapped register reset. diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c index 948e0ee..90dfdbf 100644 --- a/drivers/power/reset/syscon-reboot.c +++ b/drivers/power/reset/syscon-reboot.c @@ -14,14 +14,15 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +#include #include -#include -#include -#include #include #include -#include +#include +#include +#include #include +#include struct syscon_reboot_context { struct regmap *map; @@ -30,21 +31,17 @@ struct syscon_reboot_context { struct notifier_block restart_handler; }; -static struct syscon_reboot_context *syscon_reboot_ctx; - static int syscon_restart_handle(struct notifier_block *this, unsigned long mode, void *cmd) { - struct syscon_reboot_context *ctx = syscon_reboot_ctx; - unsigned long timeout; + struct syscon_reboot_context *ctx = + container_of(this, struct syscon_reboot_context, + restart_handler); /* Issue the reboot */ - if (ctx->map) - regmap_write(ctx->map, ctx->offset, ctx->mask); + regmap_write(ctx->map, ctx->offset, ctx->mask); - timeout = jiffies + HZ; - while (time_before(jiffies, timeout)) - cpu_relax(); + mdelay(1000); pr_emerg("Unable to restart system\n"); return NOTIFY_DONE; @@ -76,8 +73,6 @@ static int syscon_reboot_probe(struct platform_device *pdev) if (err) dev_err(dev, "can't register restart notifier (err=%d)\n", err); - syscon_reboot_ctx = ctx; - return 0; }