Skip to contentSkip to conversation

MFD/PCAP: ezx_pcap_setbits()

PATCH Applied Daniel Ribeiro 2 participants 2 messages Jun 27, 2009 – Jul 3, 2009 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MFD/PCAP: ezx_pcap_setbits()

Provides an atomic set_bits functions, as needed by the pcap-regulator driver.

---
 drivers/mfd/ezx-pcap.c       |   23 +++++++++++++++++++++++
 include/linux/mfd/ezx-pcap.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/mfd/ezx-pcap.c +23 -0
index 732664f..86d3948 100644
@@ -107,6 +107,29 @@ int ezx_pcap_read(struct pcap_chip *pcap, u8 reg_num, u32 *value)
 }
 EXPORT_SYMBOL_GPL(ezx_pcap_read);
 
+int ezx_pcap_set_bits(struct pcap_chip *pcap, u8 reg_num, u32 mask, u32 val)
+{
+	int ret;
+	u32 tmp = PCAP_REGISTER_READ_OP_BIT |
+		(reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
+
+	mutex_lock(&pcap->io_mutex);
+	ret = ezx_pcap_putget(pcap, &tmp);
+	if (ret)
+		goto out_unlock;
+
+	tmp &= (PCAP_REGISTER_VALUE_MASK & ~mask);
+	tmp |= (val & mask) | PCAP_REGISTER_WRITE_OP_BIT |
+		(reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
+
+	ret = ezx_pcap_putget(pcap, &tmp);
+out_unlock:
+	mutex_unlock(&pcap->io_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(ezx_pcap_set_bits);
+
 /* IRQ */
 int irq_to_pcap(struct pcap_chip *pcap, int irq)
 {
include/linux/mfd/ezx-pcap.h +1 -0
index b15caac..dec82b0 100644
@@ -25,6 +25,7 @@ struct pcap_chip;
 
 int ezx_pcap_write(struct pcap_chip *, u8, u32);
 int ezx_pcap_read(struct pcap_chip *, u8, u32 *);
+int ezx_pcap_set_bits(struct pcap_chip *, u8, u32, u32);
 int pcap_to_irq(struct pcap_chip *, int);
 int irq_to_pcap(struct pcap_chip *, int);
 int pcap_adc_async(struct pcap_chip *, u8, u32, u8[], void *, void *);
Signature · 4 lines
tg: (e94c381..) pcap/set_bits (depends on: pcap/fix-irq-handler)

-- 
Daniel Ribeiro
Applied
#1 lore raw
Quoted 4 lines · Daniel Ribeiro

Provides an atomic set_bits functions, as needed by the pcap-regulator driver.

Applied to my for-next branch, thanks Daniel.

Cheers,
Samuel.

Quoted 56 lines
---
 drivers/mfd/ezx-pcap.c       |   23 +++++++++++++++++++++++
 include/linux/mfd/ezx-pcap.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/mfd/ezx-pcap.c +23 -0
index 732664f..86d3948 100644
@@ -107,6 +107,29 @@ int ezx_pcap_read(struct pcap_chip *pcap, u8 reg_num, u32 *value)
 }
 EXPORT_SYMBOL_GPL(ezx_pcap_read);
 
+int ezx_pcap_set_bits(struct pcap_chip *pcap, u8 reg_num, u32 mask, u32 val)
+{
+	int ret;
+	u32 tmp = PCAP_REGISTER_READ_OP_BIT |
+		(reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
+
+	mutex_lock(&pcap->io_mutex);
+	ret = ezx_pcap_putget(pcap, &tmp);
+	if (ret)
+		goto out_unlock;
+
+	tmp &= (PCAP_REGISTER_VALUE_MASK & ~mask);
+	tmp |= (val & mask) | PCAP_REGISTER_WRITE_OP_BIT |
+		(reg_num << PCAP_REGISTER_ADDRESS_SHIFT);
+
+	ret = ezx_pcap_putget(pcap, &tmp);
+out_unlock:
+	mutex_unlock(&pcap->io_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(ezx_pcap_set_bits);
+
 /* IRQ */
 int irq_to_pcap(struct pcap_chip *pcap, int irq)
 {
include/linux/mfd/ezx-pcap.h +1 -0
index b15caac..dec82b0 100644
@@ -25,6 +25,7 @@ struct pcap_chip;
 
 int ezx_pcap_write(struct pcap_chip *, u8, u32);
 int ezx_pcap_read(struct pcap_chip *, u8, u32 *);
+int ezx_pcap_set_bits(struct pcap_chip *, u8, u32, u32);
 int pcap_to_irq(struct pcap_chip *, int);
 int irq_to_pcap(struct pcap_chip *, int);
 int pcap_adc_async(struct pcap_chip *, u8, u32, u8[], void *, void *);
Signature · 4 lines
tg: (e94c381..) pcap/set_bits (depends on: pcap/fix-irq-handler)

-- 
Daniel Ribeiro
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/