aboutsummaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorBalaji Rao <balajirrao@openmoko.org>2008-11-20 19:46:51 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-20 19:46:51 +0000
commit76e92a5722a4b89c39208eec56ea6e80222e8208 (patch)
tree251fe855c5dfc417b330379c7295e98462f2890f /drivers/i2c
parent7e8fd667d1f857fdd7e3b5511869933a72388564 (diff)
pcf50633_introduce_reg_read_functions.patch
Introduces pcf50633_read and pcf50633_write for reading a block of registers. Assumes mutex held by caller.
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/chips/pcf50633.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index c2139ba3097..419dd3198f7 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -104,6 +104,26 @@ static void pcf50633_charge_enable(struct pcf50633_data *pcf, int on);
* Low-Level routines
***********************************************************************/
+/* Read a block of upto 32 regs
+ *
+ * Locks assumed to be held by caller
+ */
+int pcf50633_read(struct pcf50633_data *pcf, u_int8_t reg, int nr_regs, u_int8_t *data)
+{
+ return i2c_smbus_read_i2c_block_data(pcf->client, reg, nr_regs, data);
+}
+EXPORT_SYMBOL(pcf50633_read);
+
+/* Read a block of upto 32 regs
+ *
+ * Locks assumed to be held by caller
+ */
+int pcf50633_write(struct pcf50633_data *pcf, u_int8_t reg, int nr_regs, u_int8_t *data)
+{
+ return i2c_smbus_write_i2c_block_data(pcf->client, reg, nr_regs, data);
+}
+EXPORT_SYMBOL(pcf50633_write);
+
static int __reg_write(struct pcf50633_data *pcf, u_int8_t reg, u_int8_t val)
{
if (pcf->suspend_state == PCF50633_SS_COMPLETED_SUSPEND) {
@@ -594,10 +614,8 @@ static void pcf50633_work(struct work_struct *work)
* datasheet says we have to read the five IRQ
* status regs in one transaction
*/
- ret = i2c_smbus_read_i2c_block_data(pcf->client,
- PCF50633_REG_INT1,
- sizeof(pcfirq),
- pcfirq);
+ ret = pcf50633_read(pcf, PCF50633_REG_INT1,
+ sizeof(pcfirq), pcfirq);
if (ret != sizeof(pcfirq)) {
dev_info(&pcf->client->dev,
"Oh crap PMU IRQ register read failed -- "
@@ -1972,9 +1990,7 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state)
for (i = 0; i < 5; i++)
res[i] = ~pcf->pdata->resumers[i];
- ret = i2c_smbus_write_i2c_block_data(pcf->client,
- PCF50633_REG_INT1M,
- 5, &res[0]);
+ ret = pcf50633_write(pcf, PCF50633_REG_INT1M, 5, &res[0]);
if (ret)
dev_err(dev, "Failed to set wake masks :-( %d\n", ret);
@@ -2041,9 +2057,7 @@ static int pcf50633_resume(struct device *dev)
memset(res, 0, sizeof(res));
/* not interested in second on resume */
res[0] = PCF50633_INT1_SECOND;
- ret = i2c_smbus_write_i2c_block_data(pcf->client,
- PCF50633_REG_INT1M,
- 5, &res[0]);
+ ret = pcf50633_write(pcf, PCF50633_REG_INT1M, 5, &res[0]);
if (ret)
dev_err(dev, "Failed to set int masks :-( %d\n", ret);