#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/device.h>
+#include <linux/irq.h>
-#include <asm/irq.h>
#include <asm/mach/irq.h>
#include <asm/arch/gpio.h>
*
* @return result of operation - 0 is success
*/
-int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
+int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes)
{
int ret;
int sid;
ret = 0;
return ret;
}
+EXPORT_SYMBOL(twl4030_i2c_write);
/**
* @brief twl4030_i2c_read - Reads a n bit register in TWL4030
*
* @return result of operation - num_bytes is success else failure.
*/
-int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
+int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes)
{
int ret;
u8 val;
ret = 0;
return ret;
}
+EXPORT_SYMBOL(twl4030_i2c_read);
/**
* @brief twl4030_i2c_write_u8 - Writes a 8 bit register in TWL4030
temp_buffer[1] = value;
return twl4030_i2c_write(mod_no, temp_buffer, reg, 1);
}
+EXPORT_SYMBOL(twl4030_i2c_write_u8);
/**
* @brief twl4030_i2c_read_u8 - Reads a 8 bit register from TWL4030
*
* @return result of operation - 0 is success
*/
-int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
+int twl4030_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
{
return twl4030_i2c_read(mod_no, value, reg, 1);
}
+EXPORT_SYMBOL(twl4030_i2c_read_u8);
/* Helper Functions */
if (retval != IRQ_HANDLED)
printk(KERN_ERR "ISR for TWL4030 module"
- " irq %d can't handle interrupt\n", irq);
+ " irq %d can't handle interrupt\n",
+ irq);
/*
* Here is where we should call the unmask method, but
if (++i2c_errors >= max_i2c_errors) {
printk(KERN_ERR "Maximum I2C error count"
" exceeded. Terminating %s.\n",
- __FUNCTION__);
+ __func__);
break;
}
continue;
}
/* Check basic functionality */
- if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
- I2C_FUNC_SMBUS_WRITE_BYTE))) {
+ err = i2c_check_functionality(adapter,
+ I2C_FUNC_SMBUS_WORD_DATA
+ | I2C_FUNC_SMBUS_WRITE_BYTE);
+ if (!err) {
pr_err("SlaveID=%d functionality check failed\n", sid);
return err;
}
pr_info("TWL4030: TRY attach Slave %s on Adapter %s [%x]\n",
twl->client_name, adapter->name, err);
- if ((err = i2c_attach_client(&twl->client))) {
+ err = i2c_attach_client(&twl->client);
+ if (err) {
pr_err("Couldn't attach Slave %s on Adapter"
"%s [%x]\n", twl->client_name, adapter->name, err);
} else {
for (i = 0; i < TWL4030_NUM_SLAVES; i++) {
/* Check if I need to hook on to this adapter or not */
if (twl4030_modules[i].adapter_index == twl_i2c_adapter) {
- if ((ret = twl4030_detect_client(adapter, i)))
+ ret = twl4030_detect_client(adapter, i);
+ if (ret)
goto free_client;
}
}
return 0;
free_client:
- pr_err("TWL_CLIENT(Idx=%d] registration failed[0x%x]\n",i,ret);
+ pr_err("TWL_CLIENT(Idx=%d] registration failed[0x%x]\n", i, ret);
/* ignore current slave..it never got registered */
i--;
static int twl4030_detach_client(struct i2c_client *client)
{
int err;
- if ((err = i2c_detach_client(client))) {
+ err = i2c_detach_client(client);
+ if (err) {
pr_err("Client detach failed\n");
return err;
}
"twl4030 irq %d", irq);
if (!thread)
pr_err("%s: could not create twl4030 irq %d thread!\n",
- __FUNCTION__, irq);
+ __func__, irq);
return thread;
}
clk_put(osc);
switch (rate) {
- case 19200000 : ctrl = HFCLK_FREQ_19p2_MHZ; break;
- case 26000000 : ctrl = HFCLK_FREQ_26_MHZ; break;
- case 38400000 : ctrl = HFCLK_FREQ_38p4_MHZ; break;
+ case 19200000 : ctrl = HFCLK_FREQ_19p2_MHZ; break;
+ case 26000000 : ctrl = HFCLK_FREQ_26_MHZ; break;
+ case 38400000 : ctrl = HFCLK_FREQ_38p4_MHZ; break;
}
ctrl |= HIGH_PERF_SQ;
set_irq_chained_handler(TWL4030_IRQNUM, do_twl4030_irq);
res = power_companion_init();
- if (res < 0) {
+ if (res < 0)
pr_err("%s[%d][%d]\n", msg, res, __LINE__);
- }
}
static int __init twl4030_init(void)
{
- int res;
-
- if ((res = i2c_add_driver(&twl4030_driver))) {
- printk(KERN_ERR "TWL4030: Driver registration failed \n");
- return res;
- }
-
- pr_info(KERN_INFO "TWL4030: Driver registration complete.\n");
-
- return 0;
+ return i2c_add_driver(&twl4030_driver);
}
static void __exit twl4030_exit(void)
subsys_initcall(twl4030_init);
module_exit(twl4030_exit);
-EXPORT_SYMBOL(twl4030_i2c_write_u8);
-EXPORT_SYMBOL(twl4030_i2c_read_u8);
-EXPORT_SYMBOL(twl4030_i2c_read);
-EXPORT_SYMBOL(twl4030_i2c_write);
-
MODULE_AUTHOR("Texas Instruments, Inc.");
MODULE_DESCRIPTION("I2C Core interface for TWL4030");
MODULE_LICENSE("GPL");