2012-06-04 01:56:42

by Richard Zhao

[permalink] [raw]
Subject: [PATCH RESEND] mfd: anatop: permit adata be NULL when access register

From: Richard Zhao <[email protected]>

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 <[email protected]>
Cc: Ying-Chun Liu (PaulLiu) <[email protected]>
---
drivers/mfd/anatop-mfd.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
index 6da0634..60d59cb 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.5.4


2012-06-04 02:13:25

by Richard Zhao

[permalink] [raw]
Subject: Re: [PATCH RESEND] mfd: anatop: permit adata be NULL when access register

Cc Paul's other mail address.

On Mon, Jun 04, 2012 at 09:56:29AM +0800, Richard Zhao wrote:
> From: Richard Zhao <[email protected]>
>
> 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 <[email protected]>
> Cc: Ying-Chun Liu (PaulLiu) <[email protected]>
> ---
> drivers/mfd/anatop-mfd.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
> index 6da0634..60d59cb 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.5.4
>

2012-06-11 06:19:41

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH RESEND] mfd: anatop: permit adata be NULL when access register

On Mon, Jun 04, 2012 at 10:13:16AM +0800, Richard Zhao wrote:
> Cc Paul's other mail address.
>
> On Mon, Jun 04, 2012 at 09:56:29AM +0800, Richard Zhao wrote:
> > From: Richard Zhao <[email protected]>
> >
> > 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 <[email protected]>
> > Cc: Ying-Chun Liu (PaulLiu) <[email protected]>

Acked-by: Shawn Guo <[email protected]>

2012-06-11 06:28:15

by Ying-Chun Liu (PaulLiu)

[permalink] [raw]
Subject: Re: [PATCH RESEND] mfd: anatop: permit adata be NULL when access register

(2012年06月11日 14:19), Shawn Guo wrote:
> On Mon, Jun 04, 2012 at 10:13:16AM +0800, Richard Zhao wrote:
>> Cc Paul's other mail address.
>>
>> On Mon, Jun 04, 2012 at 09:56:29AM +0800, Richard Zhao wrote:
>>> From: Richard Zhao <[email protected]>
>>>
>>> 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 <[email protected]>
>>> Cc: Ying-Chun Liu (PaulLiu) <[email protected]>
>
> Acked-by: Shawn Guo <[email protected]>
Acked-by: Ying-Chun Liu (PaulLiu) <[email protected]>

--
PaulLiu (劉穎駿)
E-mail: Ying-Chun Liu (PaulLiu) <[email protected]>


Attachments:
signature.asc (900.00 B)
OpenPGP digital signature

2012-06-29 15:30:29

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH RESEND] mfd: anatop: permit adata be NULL when access register

Hi Richard,

On Mon, Jun 04, 2012 at 09:56:29AM +0800, Richard Zhao wrote:
> From: Richard Zhao <[email protected]>
>
> 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.
Even though I understand it's quite unlikely that you'll never get 2 anatop
blocks on the same system, the below patch is not really nice.
Please make your driver support N > 1 instances of your hardware, even though
it's only for the sake of code cleanness.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/