From patchwork Thu Jun 4 18:22:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6548911 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 969679F443 for ; Thu, 4 Jun 2015 18:22:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B913320649 for ; Thu, 4 Jun 2015 18:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CADEA20797 for ; Thu, 4 Jun 2015 18:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752426AbbFDSWn (ORCPT ); Thu, 4 Jun 2015 14:22:43 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:44366 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbbFDSWd (ORCPT ); Thu, 4 Jun 2015 14:22:33 -0400 Received: from ayla.of.borg ([84.193.93.87]) by xavier.telenet-ops.be with bizsmtp id cJNW1q00J1t5w8s01JNWEs; Thu, 04 Jun 2015 20:22:31 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1Z0Zmg-0006DY-8I; Thu, 04 Jun 2015 20:22:30 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1Z0Zmo-00055q-Eg; Thu, 04 Jun 2015 20:22:38 +0200 From: Geert Uytterhoeven To: Simon Horman , Magnus Damm Cc: Ulrich Hecht , linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 08/11] ARM: shmobile: R-Car: Get rid of on_off_fn() function pointer Date: Thu, 4 Jun 2015 20:22:32 +0200 Message-Id: <1433442155-19492-9-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433442155-19492-1-git-send-email-geert+renesas@glider.be> References: <1433442155-19492-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Simplify the power request code by passing an "on" flag, and picking the right status bit and register offset in the innermost function, based on this flag. This allows to remove the rcar_sysc_pwr_{off,on}() helper functions, and the function pointer through which they were called. Make sr_bit and reg_offs unsigned while we're at it. Signed-off-by: Geert Uytterhoeven --- arch/arm/mach-shmobile/pm-rcar.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/arch/arm/mach-shmobile/pm-rcar.c b/arch/arm/mach-shmobile/pm-rcar.c index 7adf9ce5fc1d1ffe..4092ad16e0a42a26 100644 --- a/arch/arm/mach-shmobile/pm-rcar.c +++ b/arch/arm/mach-shmobile/pm-rcar.c @@ -51,11 +51,19 @@ static void __iomem *rcar_sysc_base; static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */ -static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, - int sr_bit, int reg_offs) +static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, bool on) { + unsigned int sr_bit, reg_offs; int k; + if (on) { + sr_bit = SYSCSR_PONENB; + reg_offs = PWRONCR_OFFS; + } else { + sr_bit = SYSCSR_POFFENB; + reg_offs = PWROFFCR_OFFS; + } + /* Wait until SYSC is ready to accept a power request */ for (k = 0; k < SYSCSR_RETRIES; k++) { if (ioread32(rcar_sysc_base + SYSCSR) & BIT(sr_bit)) @@ -73,18 +81,7 @@ static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch, return 0; } -static int rcar_sysc_pwr_off(const struct rcar_sysc_ch *sysc_ch) -{ - return rcar_sysc_pwr_on_off(sysc_ch, SYSCSR_POFFENB, PWROFFCR_OFFS); -} - -static int rcar_sysc_pwr_on(const struct rcar_sysc_ch *sysc_ch) -{ - return rcar_sysc_pwr_on_off(sysc_ch, SYSCSR_PONENB, PWRONCR_OFFS); -} - -static int rcar_sysc_update(const struct rcar_sysc_ch *sysc_ch, - int (*on_off_fn)(const struct rcar_sysc_ch *)) +static int rcar_sysc_power(const struct rcar_sysc_ch *sysc_ch, bool on) { unsigned int isr_mask = BIT(sysc_ch->isr_bit); unsigned int chan_mask = BIT(sysc_ch->chan_bit); @@ -99,7 +96,7 @@ static int rcar_sysc_update(const struct rcar_sysc_ch *sysc_ch, /* Submit power shutoff or resume request until it was accepted */ for (k = 0; k < PWRER_RETRIES; k++) { - ret = on_off_fn(sysc_ch); + ret = rcar_sysc_pwr_on_off(sysc_ch, on); if (ret) goto out; @@ -138,12 +135,12 @@ static int rcar_sysc_update(const struct rcar_sysc_ch *sysc_ch, int rcar_sysc_power_down(const struct rcar_sysc_ch *sysc_ch) { - return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_off); + return rcar_sysc_power(sysc_ch, false); } int rcar_sysc_power_up(const struct rcar_sysc_ch *sysc_ch) { - return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_on); + return rcar_sysc_power(sysc_ch, true); } bool rcar_sysc_power_is_off(const struct rcar_sysc_ch *sysc_ch)