mfd: add ezx_pcap_setbits

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

Signed-off-by: Daniel Ribeiro <drwyrm@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Daniel Ribeiro 2009-06-27 00:17:20 -03:00 committed by Samuel Ortiz
parent b1148fd46c
commit e9a22635b0
2 changed files with 24 additions and 0 deletions

View File

@ -107,6 +107,29 @@ int ezx_pcap_read(struct pcap_chip *pcap, u8 reg_num, u32 *value)
} }
EXPORT_SYMBOL_GPL(ezx_pcap_read); 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 */ /* IRQ */
int irq_to_pcap(struct pcap_chip *pcap, int irq) int irq_to_pcap(struct pcap_chip *pcap, int irq)
{ {

View File

@ -25,6 +25,7 @@ struct pcap_chip;
int ezx_pcap_write(struct pcap_chip *, u8, u32); int ezx_pcap_write(struct pcap_chip *, u8, u32);
int ezx_pcap_read(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 pcap_to_irq(struct pcap_chip *, int);
int irq_to_pcap(struct pcap_chip *, int); int irq_to_pcap(struct pcap_chip *, int);
int pcap_adc_async(struct pcap_chip *, u8, u32, u8[], void *, void *); int pcap_adc_async(struct pcap_chip *, u8, u32, u8[], void *, void *);