All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	Felipe Balbi <balbi@ti.com>
Subject: [PATCH 09/27] cbus: tahvo: introduce __tahvo_(read/write)_reg
Date: Thu, 13 Oct 2011 11:34:44 +0300	[thread overview]
Message-ID: <1318494902-13093-9-git-send-email-balbi@ti.com> (raw)
In-Reply-To: <1318494902-13093-1-git-send-email-balbi@ti.com>

those two functions are local to tahvo.c and
should be used to read/write Tahvo's registers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/cbus/tahvo.c |   56 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/cbus/tahvo.c b/drivers/cbus/tahvo.c
index 740bb05..04b8203 100644
--- a/drivers/cbus/tahvo.c
+++ b/drivers/cbus/tahvo.c
@@ -67,6 +67,27 @@ int tahvo_get_status(void)
 EXPORT_SYMBOL(tahvo_get_status);
 
 /**
+ * __tahvo_read_reg - Reads a value from a register in Tahvo
+ * @tahvo: pointer to tahvo structure
+ * @reg: the register address to read from
+ */
+static int __tahvo_read_reg(struct tahvo *tahvo, unsigned reg)
+{
+	return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
+}
+
+/**
+ * __tahvo_write_reg - Writes a value to a register in Tahvo
+ * @tahvo: pointer to tahvo structure
+ * @reg: register address to write to
+ * @val: the value to be written to @reg
+ */
+static void __tahvo_write_reg(struct tahvo *tahvo, unsigned reg, u16 val)
+{
+	cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
+}
+
+/**
  * tahvo_read_reg - Read a value from a register in Tahvo
  * @reg: the register to read from
  *
@@ -76,7 +97,7 @@ int tahvo_read_reg(unsigned reg)
 {
 	struct tahvo		*tahvo = the_tahvo;
 
-	return cbus_read_reg(tahvo->dev, TAHVO_ID, reg);
+	return __tahvo_read_reg(tahvo, reg);
 }
 EXPORT_SYMBOL(tahvo_read_reg);
 
@@ -91,7 +112,7 @@ void tahvo_write_reg(unsigned reg, u16 val)
 {
 	struct tahvo		*tahvo = the_tahvo;
 
-	cbus_write_reg(tahvo->dev, TAHVO_ID, reg, val);
+	__tahvo_write_reg(tahvo, reg, val);
 }
 EXPORT_SYMBOL(tahvo_write_reg);
 
@@ -108,10 +129,10 @@ void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear)
 	u16			w;
 
 	mutex_lock(&tahvo->mutex);
-	w = tahvo_read_reg(reg);
+	w = __tahvo_read_reg(tahvo, reg);
 	w &= ~clear;
 	w |= set;
-	tahvo_write_reg(reg, w);
+	__tahvo_write_reg(tahvo, reg, w);
 	mutex_unlock(&tahvo->mutex);
 }
 
@@ -121,9 +142,9 @@ void tahvo_disable_irq(int id)
 	u16			mask;
 
 	mutex_lock(&tahvo->mutex);
-	mask = tahvo_read_reg(TAHVO_REG_IMR);
+	mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
 	mask |= 1 << id;
-	tahvo_write_reg(TAHVO_REG_IMR, mask);
+	__tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
 	mutex_unlock(&tahvo->mutex);
 }
 EXPORT_SYMBOL(tahvo_disable_irq);
@@ -134,16 +155,18 @@ void tahvo_enable_irq(int id)
 	u16			mask;
 
 	mutex_lock(&tahvo->mutex);
-	mask = tahvo_read_reg(TAHVO_REG_IMR);
+	mask = __tahvo_read_reg(tahvo, TAHVO_REG_IMR);
 	mask &= ~(1 << id);
-	tahvo_write_reg(TAHVO_REG_IMR, mask);
+	__tahvo_write_reg(tahvo, TAHVO_REG_IMR, mask);
 	mutex_unlock(&tahvo->mutex);
 }
 EXPORT_SYMBOL(tahvo_enable_irq);
 
 void tahvo_ack_irq(int id)
 {
-	tahvo_write_reg(TAHVO_REG_IDR, 1 << id);
+	struct tahvo		*tahvo = the_tahvo;
+
+	__tahvo_write_reg(tahvo, TAHVO_REG_IDR, 1 << id);
 }
 EXPORT_SYMBOL(tahvo_ack_irq);
 
@@ -156,7 +179,7 @@ int tahvo_get_backlight_level(void)
 		mask = 0x7f;
 	else
 		mask = 0x0f;
-	return tahvo_read_reg(TAHVO_REG_LEDPWMR) & mask;
+	return __tahvo_read_reg(tahvo, TAHVO_REG_LEDPWMR) & mask;
 }
 EXPORT_SYMBOL(tahvo_get_backlight_level);
 
@@ -173,12 +196,13 @@ EXPORT_SYMBOL(tahvo_get_max_backlight_level);
 
 void tahvo_set_backlight_level(int level)
 {
+	struct tahvo		*tahvo = the_tahvo;
 	int			max_level;
 
 	max_level = tahvo_get_max_backlight_level();
 	if (level > max_level)
 		level = max_level;
-	tahvo_write_reg(TAHVO_REG_LEDPWMR, level);
+	__tahvo_write_reg(tahvo, TAHVO_REG_LEDPWMR, level);
 }
 EXPORT_SYMBOL(tahvo_set_backlight_level);
 
@@ -192,8 +216,8 @@ static irqreturn_t tahvo_irq_handler(int irq, void *_tahvo)
 	int			i;
 
 	for (;;) {
-		id = tahvo_read_reg(TAHVO_REG_IDR);
-		im = ~tahvo_read_reg(TAHVO_REG_IMR);
+		id = __tahvo_read_reg(tahvo, TAHVO_REG_IDR);
+		im = ~__tahvo_read_reg(tahvo, TAHVO_REG_IMR);
 		id &= im;
 
 		if (!id)
@@ -299,7 +323,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
 	mutex_init(&tahvo->mutex);
 	tahvo->dev = &pdev->dev;
 
-	rev = tahvo_read_reg(TAHVO_REG_ASICR);
+	rev = __tahvo_read_reg(tahvo, TAHVO_REG_ASICR);
 
 	id = (rev >> 8) & 0xff;
 
@@ -325,7 +349,7 @@ static int __devinit tahvo_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 
 	/* Mask all TAHVO interrupts */
-	tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
+	__tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
 
 	ret = request_threaded_irq(irq, NULL, tahvo_irq_handler,
 			IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -352,7 +376,7 @@ static int __devexit tahvo_remove(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 
 	/* Mask all TAHVO interrupts */
-	tahvo_write_reg(TAHVO_REG_IMR, 0xffff);
+	__tahvo_write_reg(tahvo, TAHVO_REG_IMR, 0xffff);
 	free_irq(irq, 0);
 	kfree(tahvo);
 	the_tahvo = NULL;
-- 
1.7.6.396.ge0613


  parent reply	other threads:[~2011-10-13  8:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13  8:34 [PATCH 01/27] cbus: tahvo: convert spinlock into mutex Felipe Balbi
2011-10-13  8:34 ` [PATCH 02/27] cbus: tahvo: move to __devinit/__devexit sections Felipe Balbi
2011-10-13  8:34 ` [PATCH 03/27] cbus: tahvo: a switch looks better Felipe Balbi
2011-10-13  8:34 ` [PATCH 04/27] cbus: tahvo: don't go over 80 columns Felipe Balbi
2011-10-13  8:34 ` [PATCH 05/27] cbus: tahvo: drop the tasklet Felipe Balbi
2011-10-13  8:34 ` [PATCH 06/27] cbus: retu: set IRQF_ONESHOT flag Felipe Balbi
2011-10-13  8:34 ` [PATCH 07/27] cbus: tahvo: git it a context structure Felipe Balbi
2011-10-13  8:34 ` [PATCH 08/27] cbus: tahvo: pass tahvo to IRQ handler Felipe Balbi
2011-10-13  8:34 ` Felipe Balbi [this message]
2011-10-13  8:34 ` [PATCH 10/27] cbus: tahvo: drop some unneded defines Felipe Balbi
2011-10-13  8:34 ` [PATCH 11/27] cbus: retu: IRQ demux optimization Felipe Balbi
2011-10-13  8:34 ` [PATCH 12/27] cbus: tahvo: give it an irq_chip Felipe Balbi
2011-10-13  8:34 ` [PATCH 13/27] cbus: tahvo: start using irq_chip Felipe Balbi
2011-10-13  8:34 ` [PATCH 14/27] cbus: tahvo: usb: fix up to use threaded irqs Felipe Balbi
2011-10-13  8:34 ` [PATCH 15/27] cbus: tahvo drop the legacy interfaces Felipe Balbi
2011-10-13  8:34 ` [PATCH 16/27] cbus: tahvo: usb: drop unused variable Felipe Balbi
2011-10-13  8:34 ` [PATCH 17/27] cbus: tahvo: no need to mask interrupts on exit Felipe Balbi
2011-10-13  8:34 ` [PATCH 18/27] cbus: tahvo: drop the get_status hack Felipe Balbi
2011-10-13  8:34 ` [PATCH 19/27] cbus: tahvo: drop more unused interfaces Felipe Balbi
2011-10-13  8:34 ` [PATCH 20/27] cbus: tahvo: pass child device pointer Felipe Balbi
2011-10-13  8:34 ` [PATCH 21/27] cbus: tahvo: drop backlight interfaces Felipe Balbi
2011-10-13  8:34 ` [PATCH 22/27] cbus: tahvo: drop static global pointer Felipe Balbi
2011-10-13  8:34 ` [PATCH 23/27] cbus: tahvo: prepare for children without IRQ Felipe Balbi
2011-10-13  8:34 ` [PATCH 24/27] cbus: tahvo: allocate tahvo-pwm child Felipe Balbi
2011-10-13  8:35 ` [PATCH 25/27] cbus: fix compile issue on tahvo and retu Felipe Balbi
2011-10-13  8:35 ` [PATCH 26/27] cbus: use platform_driver_register " Felipe Balbi
2011-10-13  8:35 ` [PATCH 27/27] cbus: mark dependencies for ARCH_OMAP Felipe Balbi
2011-10-17 17:20 ` [PATCH 01/27] cbus: tahvo: convert spinlock into mutex Tony Lindgren
2011-10-17 18:04   ` Felipe Balbi
2011-10-17 18:19     ` Tony Lindgren
2011-10-17 18:26       ` Felipe Balbi

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=1318494902-13093-9-git-send-email-balbi@ti.com \
    --to=balbi@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    /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.