From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH 06/16] clk: at91: clk-main: factorize irq handling
Date: Wed, 30 Sep 2015 18:10:59 +0200 [thread overview]
Message-ID: <1443629469-15086-7-git-send-email-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <1443629469-15086-1-git-send-email-alexandre.belloni@free-electrons.com>
The three different irq handlers are doing the same thing, factorize their
code in a generic irq handler.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
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);
--
2.1.4
next prev parent reply other threads:[~2015-09-30 16:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 16:10 [PATCH 00/16] ARM: at91: PMC driver rework Alexandre Belloni
2015-09-30 16:10 ` [PATCH 01/16] clk: at91: utmi: use pmc_read when the at91_pmc is available Alexandre Belloni
2015-09-30 16:10 ` [PATCH 02/16] clk: at91: system: don't try to free_irq when there is no IRQ Alexandre Belloni
2015-09-30 16:10 ` [PATCH 03/16] ARM: at91/dt: use syscon for PMC Alexandre Belloni
2015-09-30 16:10 ` [PATCH 04/16] clk: at91: make use of syscon to share PMC registers in several drivers Alexandre Belloni
2015-10-01 17:49 ` Stephen Boyd
2015-09-30 16:10 ` [PATCH 05/16] clk: at91: make use of syscon/regmap internally Alexandre Belloni
2015-09-30 16:10 ` Alexandre Belloni [this message]
2015-10-01 8:34 ` [PATCH 06/16] clk: at91: clk-main: factorize irq handling Boris Brezillon
2015-09-30 16:11 ` [PATCH 07/16] clk: at91: make IRQ optional and register them later Alexandre Belloni
2015-09-30 16:11 ` [PATCH 08/16] clk: at91: only enable available IRQs Alexandre Belloni
2015-10-01 8:24 ` Ludovic Desroches
2015-09-30 16:11 ` [PATCH 09/16] clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe Alexandre Belloni
2015-09-30 16:11 ` [PATCH 10/16] clk: at91: pmc: move pmc structures to C file Alexandre Belloni
2015-09-30 16:11 ` [PATCH 11/16] ARM: at91: pm: simply call at91_pm_init Alexandre Belloni
2015-09-30 16:11 ` [PATCH 12/16] ARM: at91: pm: find and remap the pmc Alexandre Belloni
2015-09-30 16:11 ` [PATCH 13/16] ARM: at91: pm: move idle functions to pm.c Alexandre Belloni
2015-09-30 16:11 ` [PATCH 14/16] ARM: at91: remove useless includes and function prototypes Alexandre Belloni
2015-09-30 16:11 ` [PATCH 15/16] usb: gadget: atmel: access the PMC using regmap Alexandre Belloni
2015-09-30 16:31 ` Felipe Balbi
2015-09-30 16:39 ` Nicolas Ferre
2015-09-30 16:43 ` Felipe Balbi
2015-09-30 16:59 ` Alexandre Belloni
2015-09-30 16:59 ` Alexandre Belloni
2015-09-30 16:11 ` [PATCH 16/16] clk: at91: pmc: drop at91_pmc_base Alexandre Belloni
2015-09-30 16:17 ` [PATCH 00/16] ARM: at91: PMC driver rework Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443629469-15086-7-git-send-email-alexandre.belloni@free-electrons.com \
--to=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@atmel.com \
--cc=plagnioj@jcrosoft.com \
--cc=sboyd@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®