From patchwork Wed Sep 30 16:10:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 7300121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C74CBEEA4 for ; Wed, 30 Sep 2015 16:15:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F80520552 for ; Wed, 30 Sep 2015 16:15:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DFC32052C for ; Wed, 30 Sep 2015 16:15:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhK0U-0004jV-EI; Wed, 30 Sep 2015 16:13:26 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhJz4-0003JH-Uq for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2015 16:12:05 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 3172F4460; Wed, 30 Sep 2015 18:11:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (128-79-216-6.hfc.dyn.abo.bbox.fr [128.79.216.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id EF4D83181; Wed, 30 Sep 2015 18:11:20 +0200 (CEST) From: Alexandre Belloni To: Nicolas Ferre , Boris Brezillon Subject: [PATCH 06/16] clk: at91: clk-main: factorize irq handling Date: Wed, 30 Sep 2015 18:10:59 +0200 Message-Id: <1443629469-15086-7-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443629469-15086-1-git-send-email-alexandre.belloni@free-electrons.com> References: <1443629469-15086-1-git-send-email-alexandre.belloni@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150930_091159_559169_24106558 X-CRM114-Status: GOOD ( 12.90 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Alexandre Belloni , Jean-Christophe Plagniol-Villard , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 The three different irq handlers are doing the same thing, factorize their code in a generic irq handler. Signed-off-by: Alexandre Belloni --- drivers/clk/at91/clk-main.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c index c1f119748bdc..79a380cd1f4e 100644 --- a/drivers/clk/at91/clk-main.c +++ b/drivers/clk/at91/clk-main.c @@ -71,12 +71,21 @@ struct clk_sam9x5_main { #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw) -static irqreturn_t clk_main_osc_irq_handler(int irq, void *dev_id) +/* Generic structure */ +struct clk_main { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned int irq; + wait_queue_head_t wait; +}; +#define to_clk_main(hw) container_of(hw, struct clk_main, hw) + +static irqreturn_t clk_main_irq_handler(int irq, void *dev_id) { - struct clk_main_osc *osc = dev_id; + struct clk_main *clkmain = dev_id; - wake_up(&osc->wait); - disable_irq_nosync(osc->irq); + wake_up(&clkmain->wait); + disable_irq_nosync(clkmain->irq); return IRQ_HANDLED; } @@ -185,7 +194,7 @@ at91_clk_register_main_osc(struct regmap *regmap, init_waitqueue_head(&osc->wait); irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); - ret = request_irq(osc->irq, clk_main_osc_irq_handler, + ret = request_irq(osc->irq, clk_main_irq_handler, IRQF_TRIGGER_HIGH, name, osc); if (ret) { kfree(osc); @@ -237,16 +246,6 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc", of_at91rm9200_clk_main_osc_setup); -static irqreturn_t clk_main_rc_osc_irq_handler(int irq, void *dev_id) -{ - struct clk_main_rc_osc *osc = dev_id; - - wake_up(&osc->wait); - disable_irq_nosync(osc->irq); - - return IRQ_HANDLED; -} - static bool clk_main_rc_osc_ready(struct regmap *regmap) { unsigned int status; @@ -361,7 +360,7 @@ at91_clk_register_main_rc_osc(struct regmap *regmap, init_waitqueue_head(&osc->wait); irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); - ret = request_irq(osc->irq, clk_main_rc_osc_irq_handler, + ret = request_irq(osc->irq, clk_main_irq_handler, IRQF_TRIGGER_HIGH, name, osc); if (ret) return ERR_PTR(ret); @@ -529,16 +528,6 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np) CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", of_at91rm9200_clk_main_setup); -static irqreturn_t clk_sam9x5_main_irq_handler(int irq, void *dev_id) -{ - struct clk_sam9x5_main *clkmain = dev_id; - - wake_up(&clkmain->wait); - disable_irq_nosync(clkmain->irq); - - return IRQ_HANDLED; -} - static inline bool clk_sam9x5_main_ready(struct regmap *regmap) { unsigned int status; @@ -657,7 +646,7 @@ at91_clk_register_sam9x5_main(struct regmap *regmap, clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0; init_waitqueue_head(&clkmain->wait); irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN); - ret = request_irq(clkmain->irq, clk_sam9x5_main_irq_handler, + ret = request_irq(clkmain->irq, clk_main_irq_handler, IRQF_TRIGGER_HIGH, name, clkmain); if (ret) return ERR_PTR(ret);