linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: richard.zhao@linaro.org (Richard Zhao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] mfd: anatop: permit adata be NULL when access register
Date: Sun, 13 May 2012 08:59:54 +0800	[thread overview]
Message-ID: <1336870794-6351-2-git-send-email-richard.zhao@freescale.com> (raw)
In-Reply-To: <1336870794-6351-1-git-send-email-richard.zhao@freescale.com>

It makes anatop register access easier. Anatop has many misc registers,
which may not be a specific driver.

There's only one anatop device for a running system, so we use a global
variable to store struct anatop.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/mfd/anatop-mfd.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
index 3bb7c49..b0313210 100644
--- a/drivers/mfd/anatop-mfd.c
+++ b/drivers/mfd/anatop-mfd.c
@@ -41,8 +41,15 @@
 #include <linux/of_address.h>
 #include <linux/mfd/anatop.h>
 
+/* For any running system, there's only one anatop device. */
+static struct anatop *anatop_data;
+
 u32 anatop_read_reg(struct anatop *adata, u32 addr)
 {
+	BUG_ON(!anatop_data);
+	if (!adata)
+		adata = anatop_data;
+
 	return readl(adata->ioreg + addr);
 }
 EXPORT_SYMBOL_GPL(anatop_read_reg);
@@ -51,6 +58,10 @@ void anatop_write_reg(struct anatop *adata, u32 addr, u32 data, u32 mask)
 {
 	u32 val;
 
+	BUG_ON(!anatop_data);
+	if (!adata)
+		adata = anatop_data;
+
 	data &= mask;
 
 	spin_lock(&adata->reglock);
@@ -83,6 +94,7 @@ static int __devinit of_anatop_probe(struct platform_device *pdev)
 	drvdata->ioreg = ioreg;
 	spin_lock_init(&drvdata->reglock);
 	platform_set_drvdata(pdev, drvdata);
+	anatop_data = drvdata;
 	of_platform_populate(np, of_anatop_match, NULL, dev);
 
 	return 0;
-- 
1.7.9.5

  reply	other threads:[~2012-05-13  0:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-13  0:59 [PATCH 1/2] mfd: anatop: make register accessor more flexible and rename meaningfully Richard Zhao
2012-05-13  0:59 ` Richard Zhao [this message]
2012-05-14  3:51   ` [PATCH 2/2] mfd: anatop: permit adata be NULL when access register Shawn Guo
2012-05-14  8:08     ` Mark Brown
2012-05-14  8:48       ` Shawn Guo
2012-05-14  9:01         ` Ying-Chun Liu (PaulLiu)
2012-05-14  9:43           ` Shawn Guo
2012-05-14 13:26             ` Ying-Chun Liu (PaulLiu)
2012-05-14 13:50               ` Richard Zhao
2012-05-18  9:59                 ` Richard Zhao
2012-05-21  4:13                   ` Shawn Guo
2012-05-21  9:27                     ` Ying-Chun Liu (PaulLiu)
2012-05-21  9:39                       ` Richard Zhao
2012-06-18 20:23                         ` Rob Lee
2012-06-18 21:58                           ` Samuel Ortiz
2012-06-18 22:59                             ` Rob Lee
2012-05-13  1:18 ` [PATCH V2] mfd: anatop: make register accessor more flexible and rename meaningfully Richard Zhao
2012-05-13 17:48   ` Ying-Chun Liu (PaulLiu)
2012-05-18  9:09   ` Samuel Ortiz

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=1336870794-6351-2-git-send-email-richard.zhao@freescale.com \
    --to=richard.zhao@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).