public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP: TWL4030 core misc. cleanups.
@ 2007-05-31 10:48 Trilok Soni
  2007-05-31 20:50 ` Syed Mohammed, Khasim
  0 siblings, 1 reply; 3+ messages in thread
From: Trilok Soni @ 2007-05-31 10:48 UTC (permalink / raw)
  To: Linux OMAP

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

Syed/Tony,

Attached twl4030 core cleanup patch and it is compile tested only.
Syed please test. Goal is to move towards converting it to new I2C
style bindings {probe/remove}.

But this driver is handling four clients and as per legacy style it is
creating client structures internally and handling it. But as per the
new style client structures are being handed over to driver by
i2c_register_board_info at boot time by attaching it. In this case do
we have to call i2c_add_adapter with same driver structure but with
".name" and common .probe and .remove methods ?

David please suggest your ideas on how to convert twl4030_core.c
driver to new I2C style.

-- 
--Trilok Soni

[-- Attachment #2: 0001-ARM-OMAP-TWL4030-core-misc.-cleanups.patch --]
[-- Type: text/x-patch, Size: 7398 bytes --]

From 3260688f2b32766cb65bab771f153871ca6fd4af Mon Sep 17 00:00:00 2001
From: Trilok Soni <soni.trilok@gmail.com>
Date: Thu, 31 May 2007 21:40:45 +0530
Subject: [PATCH] ARM: OMAP: TWL4030 core misc. cleanups.

- Add pr_err and CodingStyle cleanups.

Signed-off-by: Trilok Soni <soni.trilok@gmail.com>
---
 drivers/i2c/chips/twl4030_core.c |   78 ++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/drivers/i2c/chips/twl4030_core.c b/drivers/i2c/chips/twl4030_core.c
index 2278b5c..6123ce8 100644
--- a/drivers/i2c/chips/twl4030_core.c
+++ b/drivers/i2c/chips/twl4030_core.c
@@ -49,6 +49,10 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/mux.h>
 
+#define DRIVER_NAME			"twl4030"
+
+#define pr_err(fmt, arg...)	printk(KERN_ERR DRIVER_NAME ": " fmt, ##arg);
+
 /**** Macro Definitions */
 #define TWL_CLIENT_STRING		"TWL4030-ID"
 #define TWL_CLIENT_USED			1
@@ -257,16 +261,15 @@ int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
 	struct i2c_msg *msg;
 
 	if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
-		printk(KERN_ERR "TWL4030: Invalid module Number\n");
+		pr_err("Invalid module Number\n");
 		return -EPERM;
 	}
 	sid = twl4030_map[mod_no].sid;
 	client = &(twl4030_modules[sid]);
 
 	if (unlikely(client->inuse != TWL_CLIENT_USED)) {
-		printk(KERN_ERR
-			"TWL4030: I2C Client[%d] is not initialized[%d]\n",
-			sid, __LINE__);
+		pr_err("I2C Client[%d] is not initialized[%d]\n",
+		       sid,__LINE__);
 		return -EPERM;
 	}
 	down(&(client->xfer_lock));
@@ -307,17 +310,17 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
 	int sid;
 	struct twl4030_client *client;
 	struct i2c_msg *msg;
+
 	if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
-		printk(KERN_ERR "TWL4030: Invalid module Number\n");
+		pr_err("Invalid module Number\n");
 		return -EPERM;
 	}
 	sid = twl4030_map[mod_no].sid;
 	client = &(twl4030_modules[sid]);
 
 	if (unlikely(client->inuse != TWL_CLIENT_USED)) {
-		printk(KERN_ERR
-			"TWL4030: I2C Client[%d] is not initialized[%d]\n",
-			sid, __LINE__);
+		pr_err("I2C Client[%d] is not initialized[%d]\n", sid,
+		       __LINE__);
 		return -EPERM;
 	}
 	down(&(client->xfer_lock));
@@ -355,6 +358,7 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
 int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
 {
 	int ret;
+
 	/* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
 	u8 temp_buffer[2] = { 0 };
 	/* offset 1 contains the data */
@@ -375,6 +379,7 @@ int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
 int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
 {
 	int ret = 0;
+
 	ret = twl4030_i2c_read(mod_no, value, reg, 1);
 	return ret;
 }
@@ -535,24 +540,21 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid)
 {
 	int err = 0;
 	struct twl4030_client *client;
+
 	if (unlikely(sid >= TWL4030_NUM_SLAVES)) {
-		printk(KERN_ERR "TWL4030: sid[%d] >MOD_LAST[%d]\n", sid,
-				TWL4030_NUM_SLAVES);
+		pr_err("sid[%d] > MOD_LAST[%d]\n", sid, TWL4030_NUM_SLAVES);
 		return -EPERM;
 	}
 
 	/* Check basic functionality */
 	if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
 						I2C_FUNC_SMBUS_WRITE_BYTE))) {
-		printk(KERN_WARNING
-			"TWL4030: SlaveID=%d functionality check failed\n", sid);
+		pr_err("SlaveID=%d functionality check failed\n", sid);
 		return err;
 	}
 	client = &(twl4030_modules[sid]);
 	if (unlikely(client->inuse)) {
-		printk(KERN_ERR "TWL4030: Client is already in Use.....\n");
-		printk("%s[ID=0x%x] NOT attached to I2c Adapter %s\n",
-			client->client_name, client->address, adapter->name);
+		pr_err("Client %s is already in use\n", client->client_name);
 		return -EPERM;
 	}
 
@@ -564,17 +566,18 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid)
 
 	memcpy(&(client->client.name), client->client_name,
 			sizeof(TWL_CLIENT_STRING) + 1);
-	printk("TWL4030: TRY attach Slave %s on Adapter %s[%d][%x]\n",
-				client->client_name, adapter->name, err, err);
-	if ((err = i2c_attach_client(&(client->client))))
-		printk(KERN_WARNING
-			"TWL4030: Couldn't attach Slave %s on Adapter "
-			"%s[%d][%x]\n",
-			client->client_name, adapter->name, err, err);
-	else {
+
+	pr_info("TWL4030: TRY attach Slave %s on Adapter %s [%x]\n",
+				client->client_name, adapter->name, err);
+
+	if ((err = i2c_attach_client(&(client->client)))) {
+		pr_err("Couldn't attach Slave %s on Adapter"
+		       "%s [%x]\n", client->client_name, adapter->name, err);
+	} else {
 		client->inuse = TWL_CLIENT_USED;
 		init_MUTEX(&client->xfer_lock);
 	}
+
 	return err;
 }
 
@@ -584,6 +587,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter)
 	int i;
 	int ret = 0;
 	static int twl_i2c_adapter = 1;
+
 	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) {
@@ -605,9 +609,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter)
 	return 0;
 
 free_client:
-	printk(KERN_ERR
-		"TWL4030: TWL_CLIENT(Idx=%d] REGISTRATION FAILED=%d[0x%x]\n", i,
-			ret, ret);
+	pr_err("TWL_CLIENT(Idx=%d] registration failed[0x%x]\n",i,ret);
 
 	/* ignore current slave..it never got registered */
 	i--;
@@ -625,8 +627,7 @@ static int twl4030_detach_client(struct i2c_client *iclient)
 {
 	int err;
 	if ((err = i2c_detach_client(iclient))) {
-		printk(KERN_ERR
-				"TWL4030: Client deregistration failed, client not detached.\n");
+		pr_err("Client detach failed\n");
 		return err;
 	}
 	return 0;
@@ -639,8 +640,8 @@ struct task_struct *start_twl4030_irq_thread(int irq)
 	thread = kthread_create(twl4030_irq_thread, (void *)irq,
 				"twl4030 irq %d", irq);
 	if (!thread)
-		printk(KERN_ERR "%s: could not create twl4030 irq %d thread!\n",
-			__FUNCTION__, irq);
+		pr_err("%s: could not create twl4030 irq %d thread!\n",
+		       __FUNCTION__,irq);
 
 	return thread;
 }
@@ -652,6 +653,7 @@ struct task_struct *start_twl4030_irq_thread(int irq)
 static int protect_pm_master(void)
 {
 	int e = 0;
+
 	e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK,
 			R_PROTECT_KEY);
 	return e;
@@ -660,6 +662,7 @@ static int protect_pm_master(void)
 static int unprotect_pm_master(void)
 {
 	int e = 0;
+
 	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1,
 			R_PROTECT_KEY);
 	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2,
@@ -697,6 +700,7 @@ static void twl_init_irq(void)
 	int i = 0;
 	int res = 0;
 	int line = 0;
+
 	/*
 	 * We end up with interrupts from other modules before
 	 * they get a chance to handle them...
@@ -873,20 +877,22 @@ static void twl_init_irq(void)
 
 irq_exit_path:
 	if (res)
-		printk(KERN_ERR
-			"TWL4030: Unable to register interrupt "
-			"subsystem[%d][%d]\n", res, line);
+		pr_err("Unable to register interrupt subsystem[%d][%d]\n",
+		       res,line);
 }
 
 static int __init twl4030_init(void)
 {
 	int res;
-	if ((res = i2c_register_driver(THIS_MODULE, &twl4030_driver))) {
+
+	if ((res = i2c_add_driver(&twl4030_driver))) {
 		printk(KERN_ERR "TWL4030: Driver registration failed \n");
 		return res;
 	}
-	printk(KERN_INFO "TWL4030: Driver registration complete.\n");
-	return res;
+
+	pr_info(KERN_INFO "TWL4030: Driver registration complete.\n");
+
+	return 0;
 }
 
 static void __exit twl4030_exit(void)
-- 
1.5.0


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] ARM: OMAP: TWL4030 core misc. cleanups.
  2007-05-31 10:48 [PATCH] ARM: OMAP: TWL4030 core misc. cleanups Trilok Soni
@ 2007-05-31 20:50 ` Syed Mohammed, Khasim
  2007-06-05  9:47   ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Syed Mohammed, Khasim @ 2007-05-31 20:50 UTC (permalink / raw)
  To: Trilok Soni, Linux OMAP

Hi Trilok,

>Syed/Tony,
>
>Attached twl4030 core cleanup patch and it is compile tested only.
>Syed please test. 

I tested this patch (using Keypad driver) it works as expected. 

Thanks

Regards,
Khasim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: OMAP: TWL4030 core misc. cleanups.
  2007-05-31 20:50 ` Syed Mohammed, Khasim
@ 2007-06-05  9:47   ` Tony Lindgren
  0 siblings, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2007-06-05  9:47 UTC (permalink / raw)
  To: Syed Mohammed, Khasim; +Cc: Linux OMAP

* Syed Mohammed, Khasim <x0khasim@ti.com> [070531 13:50]:
> Hi Trilok,
> 
> >Syed/Tony,
> >
> >Attached twl4030 core cleanup patch and it is compile tested only.
> >Syed please test. 
> 
> I tested this patch (using Keypad driver) it works as expected. 

Thanks, pushing today.

Tony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-05  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-31 10:48 [PATCH] ARM: OMAP: TWL4030 core misc. cleanups Trilok Soni
2007-05-31 20:50 ` Syed Mohammed, Khasim
2007-06-05  9:47   ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox