All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Claudiu.Beznea@microchip.com>
To: <sre@kernel.org>, <Nicolas.Ferre@microchip.com>,
	<alexandre.belloni@bootlin.com>,
	<Ludovic.Desroches@microchip.com>
Cc: <linux-pm@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <Claudiu.Beznea@microchip.com>
Subject: [PATCH 05/15] power: reset: at91-reset: convert reset in pointer to struct at91_reset
Date: Tue, 21 Jan 2020 10:03:31 +0000	[thread overview]
Message-ID: <1579601001-5711-6-git-send-email-claudiu.beznea@microchip.com> (raw)
In-Reply-To: <1579601001-5711-1-git-send-email-claudiu.beznea@microchip.com>

Convert reset in pointer to struct at91_reset.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/power/reset/at91-reset.c | 50 ++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index e8840193620d..4bb5eef4b258 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -56,7 +56,7 @@ struct at91_reset {
 	struct notifier_block nb;
 };
 
-static struct at91_reset reset;
+static struct at91_reset *reset;
 
 /*
 * unless the SDRAM is cleanly shutdown before we hit the
@@ -81,8 +81,8 @@ static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
 
 		"b	.\n\t"
 		:
-		: "r" (reset.ramc_base[0]),
-		  "r" (reset.rstc_base),
+		: "r" (reset->ramc_base[0]),
+		  "r" (reset->rstc_base),
 		  "r" (1),
 		  "r" cpu_to_le32(AT91_SDRAMC_LPCB_POWER_DOWN),
 		  "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST));
@@ -123,9 +123,9 @@ static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
 
 		"	b	.\n\t"
 		:
-		: "r" (reset.ramc_base[0]),
-		  "r" (reset.ramc_base[1]),
-		  "r" (reset.rstc_base),
+		: "r" (reset->ramc_base[0]),
+		  "r" (reset->ramc_base[1]),
+		  "r" (reset->rstc_base),
 		  "r" (1),
 		  "r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN),
 		  "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)
@@ -138,7 +138,7 @@ static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
 			   void *cmd)
 {
 	writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST),
-	       reset.rstc_base);
+	       reset->rstc_base);
 
 	return NOTIFY_DONE;
 }
@@ -147,7 +147,7 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
 			 void *cmd)
 {
 	writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PROCRST),
-	       reset.rstc_base);
+	       reset->rstc_base);
 
 	return NOTIFY_DONE;
 }
@@ -155,7 +155,7 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
 static void __init at91_reset_status(struct platform_device *pdev)
 {
 	const char *reason;
-	u32 reg = readl(reset.rstc_base + AT91_RSTC_SR);
+	u32 reg = readl(reset->rstc_base + AT91_RSTC_SR);
 
 	switch ((reg & AT91_RSTC_RSTTYP) >> 8) {
 	case RESET_TYPE_GENERAL:
@@ -212,8 +212,12 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	struct device_node *np;
 	int ret, idx = 0;
 
-	reset.rstc_base = of_iomap(pdev->dev.of_node, 0);
-	if (!reset.rstc_base) {
+	reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL);
+	if (!reset)
+		return -ENOMEM;
+
+	reset->rstc_base = of_iomap(pdev->dev.of_node, 0);
+	if (!reset->rstc_base) {
 		dev_err(&pdev->dev, "Could not map reset controller address\n");
 		return -ENODEV;
 	}
@@ -221,8 +225,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	if (!of_device_is_compatible(pdev->dev.of_node, "atmel,sama5d3-rstc")) {
 		/* we need to shutdown the ddr controller, so get ramc base */
 		for_each_matching_node(np, at91_ramc_of_match) {
-			reset.ramc_base[idx] = of_iomap(np, 0);
-			if (!reset.ramc_base[idx]) {
+			reset->ramc_base[idx] = of_iomap(np, 0);
+			if (!reset->ramc_base[idx]) {
 				dev_err(&pdev->dev, "Could not map ram controller address\n");
 				of_node_put(np);
 				return -ENODEV;
@@ -232,22 +236,22 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	}
 
 	match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
-	reset.nb.notifier_call = match->data;
-	reset.nb.priority = 192;
+	reset->nb.notifier_call = match->data;
+	reset->nb.priority = 192;
 
-	reset.sclk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(reset.sclk))
-		return PTR_ERR(reset.sclk);
+	reset->sclk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(reset->sclk))
+		return PTR_ERR(reset->sclk);
 
-	ret = clk_prepare_enable(reset.sclk);
+	ret = clk_prepare_enable(reset->sclk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable slow clock\n");
 		return ret;
 	}
 
-	ret = register_restart_handler(&reset.nb);
+	ret = register_restart_handler(&reset->nb);
 	if (ret) {
-		clk_disable_unprepare(reset.sclk);
+		clk_disable_unprepare(reset->sclk);
 		return ret;
 	}
 
@@ -258,8 +262,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 
 static int __exit at91_reset_remove(struct platform_device *pdev)
 {
-	unregister_restart_handler(&reset.nb);
-	clk_disable_unprepare(reset.sclk);
+	unregister_restart_handler(&reset->nb);
+	clk_disable_unprepare(reset->sclk);
 
 	return 0;
 }
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: <Claudiu.Beznea@microchip.com>
To: <sre@kernel.org>, <Nicolas.Ferre@microchip.com>,
	<alexandre.belloni@bootlin.com>,
	<Ludovic.Desroches@microchip.com>
Cc: Claudiu.Beznea@microchip.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org
Subject: [PATCH 05/15] power: reset: at91-reset: convert reset in pointer to struct at91_reset
Date: Tue, 21 Jan 2020 10:03:31 +0000	[thread overview]
Message-ID: <1579601001-5711-6-git-send-email-claudiu.beznea@microchip.com> (raw)
In-Reply-To: <1579601001-5711-1-git-send-email-claudiu.beznea@microchip.com>

Convert reset in pointer to struct at91_reset.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/power/reset/at91-reset.c | 50 ++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index e8840193620d..4bb5eef4b258 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -56,7 +56,7 @@ struct at91_reset {
 	struct notifier_block nb;
 };
 
-static struct at91_reset reset;
+static struct at91_reset *reset;
 
 /*
 * unless the SDRAM is cleanly shutdown before we hit the
@@ -81,8 +81,8 @@ static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
 
 		"b	.\n\t"
 		:
-		: "r" (reset.ramc_base[0]),
-		  "r" (reset.rstc_base),
+		: "r" (reset->ramc_base[0]),
+		  "r" (reset->rstc_base),
 		  "r" (1),
 		  "r" cpu_to_le32(AT91_SDRAMC_LPCB_POWER_DOWN),
 		  "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST));
@@ -123,9 +123,9 @@ static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
 
 		"	b	.\n\t"
 		:
-		: "r" (reset.ramc_base[0]),
-		  "r" (reset.ramc_base[1]),
-		  "r" (reset.rstc_base),
+		: "r" (reset->ramc_base[0]),
+		  "r" (reset->ramc_base[1]),
+		  "r" (reset->rstc_base),
 		  "r" (1),
 		  "r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN),
 		  "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)
@@ -138,7 +138,7 @@ static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
 			   void *cmd)
 {
 	writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST),
-	       reset.rstc_base);
+	       reset->rstc_base);
 
 	return NOTIFY_DONE;
 }
@@ -147,7 +147,7 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
 			 void *cmd)
 {
 	writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PROCRST),
-	       reset.rstc_base);
+	       reset->rstc_base);
 
 	return NOTIFY_DONE;
 }
@@ -155,7 +155,7 @@ static int samx7_restart(struct notifier_block *this, unsigned long mode,
 static void __init at91_reset_status(struct platform_device *pdev)
 {
 	const char *reason;
-	u32 reg = readl(reset.rstc_base + AT91_RSTC_SR);
+	u32 reg = readl(reset->rstc_base + AT91_RSTC_SR);
 
 	switch ((reg & AT91_RSTC_RSTTYP) >> 8) {
 	case RESET_TYPE_GENERAL:
@@ -212,8 +212,12 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	struct device_node *np;
 	int ret, idx = 0;
 
-	reset.rstc_base = of_iomap(pdev->dev.of_node, 0);
-	if (!reset.rstc_base) {
+	reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL);
+	if (!reset)
+		return -ENOMEM;
+
+	reset->rstc_base = of_iomap(pdev->dev.of_node, 0);
+	if (!reset->rstc_base) {
 		dev_err(&pdev->dev, "Could not map reset controller address\n");
 		return -ENODEV;
 	}
@@ -221,8 +225,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	if (!of_device_is_compatible(pdev->dev.of_node, "atmel,sama5d3-rstc")) {
 		/* we need to shutdown the ddr controller, so get ramc base */
 		for_each_matching_node(np, at91_ramc_of_match) {
-			reset.ramc_base[idx] = of_iomap(np, 0);
-			if (!reset.ramc_base[idx]) {
+			reset->ramc_base[idx] = of_iomap(np, 0);
+			if (!reset->ramc_base[idx]) {
 				dev_err(&pdev->dev, "Could not map ram controller address\n");
 				of_node_put(np);
 				return -ENODEV;
@@ -232,22 +236,22 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	}
 
 	match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
-	reset.nb.notifier_call = match->data;
-	reset.nb.priority = 192;
+	reset->nb.notifier_call = match->data;
+	reset->nb.priority = 192;
 
-	reset.sclk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(reset.sclk))
-		return PTR_ERR(reset.sclk);
+	reset->sclk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(reset->sclk))
+		return PTR_ERR(reset->sclk);
 
-	ret = clk_prepare_enable(reset.sclk);
+	ret = clk_prepare_enable(reset->sclk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable slow clock\n");
 		return ret;
 	}
 
-	ret = register_restart_handler(&reset.nb);
+	ret = register_restart_handler(&reset->nb);
 	if (ret) {
-		clk_disable_unprepare(reset.sclk);
+		clk_disable_unprepare(reset->sclk);
 		return ret;
 	}
 
@@ -258,8 +262,8 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 
 static int __exit at91_reset_remove(struct platform_device *pdev)
 {
-	unregister_restart_handler(&reset.nb);
-	clk_disable_unprepare(reset.sclk);
+	unregister_restart_handler(&reset->nb);
+	clk_disable_unprepare(reset->sclk);
 
 	return 0;
 }
-- 
2.7.4

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-01-21 10:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21 10:03 [PATCH 00/15] rework at91-reset driver Claudiu.Beznea
2020-01-21 10:03 ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 01/15] power: reset: at91-reset: introduce struct at91_reset Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 03/15] power: reset: at91-reset: add sclk to " Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 02/15] power: reset: at91-reset: add ramc_base[] " Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 04/15] power: reset: at91-reset: add notifier block " Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` Claudiu.Beznea [this message]
2020-01-21 10:03   ` [PATCH 05/15] power: reset: at91-reset: convert reset in pointer " Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 08/15] power: reset: at91-reset: introduce struct at91_reset_data Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 06/15] power: reset: at91-reset: pass rstc base address to at91_reset_status() Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 07/15] power: reset: at91-reset: devm_kzalloc() for at91_reset data structure Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 10/15] power: reset: at91-reset: use r4 as tmp argument Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 09/15] power: reset: at91-reset: introduce args member in at91_reset_data Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 11/15] power: reset: at91-reset: introduce ramc_lpr to struct at91_reset Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 12/15] power: reset: at91-reset: make at91sam9g45_restart() generic Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 13/15] power: reset: at91-reset: keep only one reset function Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 14/15] power: reset: at91-reset: get rid of at91_reset_data Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-01-21 10:03 ` [PATCH 15/15] power: reset: at91-reset: handle nrst async for sam9x60 Claudiu.Beznea
2020-01-21 10:03   ` Claudiu.Beznea
2020-03-08 18:54 ` [PATCH 00/15] rework at91-reset driver Sebastian Reichel
2020-03-08 18:54   ` Sebastian Reichel

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=1579601001-5711-6-git-send-email-claudiu.beznea@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=Ludovic.Desroches@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.