/* * rl6347a.c - RL6347A class device shared support * * Copyright 2015 Realtek Semiconductor Corp. * * Author: Oder Chiou * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include #include #include #include "rl6347a.h" int rl6347a_hw_write(void *context, unsigned int reg, unsigned int value) { struct i2c_client *client = context; struct rl6347a_priv *rl6347a = i2c_get_clientdata(client); u8 data[4]; int ret, i; /* handle index registers */ if (reg <= 0xff) { rl6347a_hw_write(client, RL6347A_COEF_INDEX, reg); for (i = 0; i < rl6347a->index_cache_size; i++) { if (reg == rl6347a->index_cache[i].reg) { rl6347a->index_cache[i].def = value; break; } } reg = RL6347A_PROC_COEF; } data[0] = (reg >> 24) & 0xff; data[1] = (reg >> 16) & 0xff; /* * 4 bit VID: reg should be 0 * 12 bit VID: value should be 0 * So we use an OR operator to handle it rather than use if condition. */ data[2] = ((reg >> 8) & 0xff) | ((value >> 8) & 0xff); data[3] = value & 0xff; ret = i2c_master_send(client, data, 4); if (ret == 4) return 0; else dev_err(&client->dev, "I2C error %d\n", ret); if (ret < 0) return ret; else return -EIO; } EXPORT_SYMBOL_GPL(rl6347a_hw_write); int rl6347a_hw_read(void *context, unsigned int reg, unsigned int *value) { struct i2c_client *client = context; struct i2c_msg xfer[2]; int ret; __be32 be_reg; unsigned int index, vid, buf = 0x0; /* handle index registers */ if (reg <= 0xff) { rl6347a_hw_write(client, RL6347A_COEF_INDEX, reg); reg = RL6347A_PROC_COEF; } reg = reg | 0x80000; vid = (reg >> 8) & 0xfff; if (AC_VERB_GET_AMP_GAIN_MUTE == (vid & 0xf00)) { index = (reg >> 8) & 0xf; reg = (reg & ~0xf0f) | index; } be_reg = cpu_to_be32(reg); /* Write register */ xfer[0].addr = client->addr; xfer[0].flags = 0; xfer[0].len = 4; xfer[0].buf = (u8 *)&be_reg; /* Read data */ xfer[1].addr = client->addr; xfer[1].flags = I2C_M_RD; xfer[1].len = 4; xfer[1].buf = (u8 *)&buf; ret = i2c_transfer(client->adapter, xfer, 2); if (ret < 0) return ret; else if (ret != 2) return -EIO; *value = be32_to_cpu(buf); return 0; } EXPORT_SYMBOL_GPL(rl6347a_hw_read); MODULE_DESCRIPTION("RL6347A class device shared support"); MODULE_AUTHOR("Oder Chiou "); MODULE_LICENSE("GPL v2"); s='content'>
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-30 09:35:52 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-30 09:35:52 -0700
commit6aba74f2791287ec407e0f92487a725a25908067 (patch)
tree5d1bb70820fee020e3365c40e204dd256a1f0a10
parenta8e498b768d912ad3e7069c86b86bdb821d43b5f (diff)
parentdd8ea6af1b9f4cedefb718dbfff60203c458d7ab (diff)
Merge branch 'irq-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'irq-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: avr32: Fix missing irq namespace conversion powerpc: qe_ic: Rename get_irq_desc_data and get_irq_desc_chip genirq: Remove the now obsolete config options and select statements arm: versatile : Fix typo introduced in irq namespace cleanup sound: Fixup the last user of the old irq functions genirq: Remove obsolete comment genirq: Remove now obsolete set_irq_wake() sh: Fix irq cleanup fallout x86: apb_timer: Fixup genirq fallout genirq: Fix misnamed label in handle_edge_eoi_irq Fix up crazy conflict in arch/powerpc/include/asm/qe_ic.h: - commit eead4d5c63ff ("powerpc: qe_ic: Rename get_irq_desc_data and get_irq_desc_chip") made the helper functions use irq_desc_get_handler_data() instead of the legacy (and no longer existing) get_irq_desc_data. - commit d4db35e8dc96 ("powerpc/qe_ic: Fix another breakage from the irq_data conversion") used irq_desc_get_chip_data() instead. According to Thomas, the former is the correct direct conversion, but it does look like both should work (arch/powerpc/sysdev/qe_lib/qe_ic.c seems to initialize both to the same thing), and the chip data in some ways is the more logical. Somebody should really decide on one of the other. This merge picks irq_desc_get_handler_data() as the straightforward pure conversion to new names, as per Thomas.