[07/17] mach-integrator: introduce cm_read function helper to read CM_CTRL register
diff mbox

Message ID 1312364089-32380-8-git-send-email-bryan.wu@canonical.com
State New, archived
Headers show

Commit Message

Bryan Wu Aug. 3, 2011, 9:34 a.m. UTC
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
 arch/arm/mach-integrator/core.c            |   17 +++++++++++++++++
 arch/arm/mach-integrator/include/mach/cm.h |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)

Comments

Sergei Shtylyov Aug. 3, 2011, 11:29 a.m. UTC | #1
Hello.

On 03-08-2011 13:34, Bryan Wu wrote:

> Signed-off-by: Bryan Wu<bryan.wu@canonical.com>
> ---
>   arch/arm/mach-integrator/core.c            |   17 +++++++++++++++++
>   arch/arm/mach-integrator/include/mach/cm.h |    1 +
>   2 files changed, 18 insertions(+), 0 deletions(-)

> diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
> index 77315b9..0ee6af6 100644
> --- a/arch/arm/mach-integrator/core.c
> +++ b/arch/arm/mach-integrator/core.c
> @@ -225,6 +225,23 @@ void cm_control(u32 mask, u32 set)
>
>   EXPORT_SYMBOL(cm_control);
>
> +/**
> + * cm_read - read the CM_CTRL register.
> + */
> +u32 cm_read(void)
> +{
> +	unsigned long flags;
> +	u32 val = 0;
> +
> +	spin_lock_irqsave(&cm_lock, flags);
> +	val = readl(CM_CTRL);
> +	spin_unlock_irqrestore(&cm_lock, flags);

    What's the point of locking around already atomic read?

WBR, Sergei
Sergei Shtylyov Aug. 3, 2011, 11:30 a.m. UTC | #2
Hello.

On 03-08-2011 13:34, Bryan Wu wrote:

> Signed-off-by: Bryan Wu<bryan.wu@canonical.com>
> ---
>   arch/arm/mach-integrator/core.c            |   17 +++++++++++++++++
>   arch/arm/mach-integrator/include/mach/cm.h |    1 +
>   2 files changed, 18 insertions(+), 0 deletions(-)

> diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
> index 77315b9..0ee6af6 100644
> --- a/arch/arm/mach-integrator/core.c
> +++ b/arch/arm/mach-integrator/core.c
> @@ -225,6 +225,23 @@ void cm_control(u32 mask, u32 set)
>
>   EXPORT_SYMBOL(cm_control);
>
> +/**
> + * cm_read - read the CM_CTRL register.
> + */
> +u32 cm_read(void)
> +{
> +	unsigned long flags;
> +	u32 val = 0;

    Intialization not needed.

> +
> +	spin_lock_irqsave(&cm_lock, flags);
> +	val = readl(CM_CTRL);
> +	spin_unlock_irqrestore(&cm_lock, flags);
> +
> +	return val;
> +}
> +
> +EXPORT_SYMBOL(cm_read);
> +
>   /*
>    * We need to stop things allocating the low memory; ideally we need a
>    * better implementation of GFP_DMA which does not assume that DMA-able

WBR, Sergei
Bryan Wu Aug. 4, 2011, 8:54 a.m. UTC | #3
On Wed, Aug 3, 2011 at 7:29 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> Hello.
>
> On 03-08-2011 13:34, Bryan Wu wrote:
>
>> Signed-off-by: Bryan Wu<bryan.wu@canonical.com>
>> ---
>>  arch/arm/mach-integrator/core.c            |   17 +++++++++++++++++
>>  arch/arm/mach-integrator/include/mach/cm.h |    1 +
>>  2 files changed, 18 insertions(+), 0 deletions(-)
>
>> diff --git a/arch/arm/mach-integrator/core.c
>> b/arch/arm/mach-integrator/core.c
>> index 77315b9..0ee6af6 100644
>> --- a/arch/arm/mach-integrator/core.c
>> +++ b/arch/arm/mach-integrator/core.c
>> @@ -225,6 +225,23 @@ void cm_control(u32 mask, u32 set)
>>
>>  EXPORT_SYMBOL(cm_control);
>>
>> +/**
>> + * cm_read - read the CM_CTRL register.
>> + */
>> +u32 cm_read(void)
>> +{
>> +       unsigned long flags;
>> +       u32 val = 0;
>> +
>> +       spin_lock_irqsave(&cm_lock, flags);
>> +       val = readl(CM_CTRL);
>> +       spin_unlock_irqrestore(&cm_lock, flags);
>
>   What's the point of locking around already atomic read?
>

Actually, I'm not sure about whether we need special operation on
CM_CTRL register. So I followed the cm_control() function style.

Yeah, if it is just a common register, it's quite convenient for me to
read it in leds drivers.

Thanks a lot,

Patch
diff mbox

diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 77315b9..0ee6af6 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -225,6 +225,23 @@  void cm_control(u32 mask, u32 set)
 
 EXPORT_SYMBOL(cm_control);
 
+/**
+ * cm_read - read the CM_CTRL register.
+ */
+u32 cm_read(void)
+{
+	unsigned long flags;
+	u32 val = 0;
+
+	spin_lock_irqsave(&cm_lock, flags);
+	val = readl(CM_CTRL);
+	spin_unlock_irqrestore(&cm_lock, flags);
+
+	return val;
+}
+
+EXPORT_SYMBOL(cm_read);
+
 /*
  * We need to stop things allocating the low memory; ideally we need a
  * better implementation of GFP_DMA which does not assume that DMA-able
diff --git a/arch/arm/mach-integrator/include/mach/cm.h b/arch/arm/mach-integrator/include/mach/cm.h
index 445d57a..3731508 100644
--- a/arch/arm/mach-integrator/include/mach/cm.h
+++ b/arch/arm/mach-integrator/include/mach/cm.h
@@ -2,6 +2,7 @@ 
  * update the core module control register.
  */
 void cm_control(u32, u32);
+u32 cm_read(void);
 
 #define CM_CTRL_LED			(1 << 0)
 #define CM_CTRL_nMBDET			(1 << 1)