mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Kalhan Trisal <kalhan.trisal@intel.com>
Cc: Jonathan Cameron <kernel@jic23.retrosnub.co.uk>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] hmc6352: Add driver for the HMC6352 compass
Date: Wed, 14 Apr 2010 14:36:33 -0700	[thread overview]
Message-ID: <1271280993.1833.36.camel@Joe-Laptop.home> (raw)
In-Reply-To: <20100414161904.713eef78@lxorguk.ukuu.org.uk>

Trivial neatening

Argument alignment
Spacing
Make chars static
Remove prefixes from dev_<level> logging

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/misc/hmc6352.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
index 1c1e974..2c12dc3 100644
--- a/drivers/misc/hmc6352.c
+++ b/drivers/misc/hmc6352.c
@@ -30,13 +30,14 @@
 #include <linux/sysfs.h>
 
 static ssize_t compass_calibration_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t count)
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	int ret;
 	unsigned long val;
-	char  cmd = 'C';	/* Calibrate */
-	char  cmd1 = 'E';	/* Exit calibration mode */
+	static char cmd = 'C';		/* Calibrate */
+	static char cmd1 = 'E';		/* Exit calibration mode */
 	struct i2c_msg msg[] = {
 		{ client->addr, 0, 1, &cmd },
 	};
@@ -49,13 +50,13 @@ static ssize_t compass_calibration_store(struct device *dev,
 	if (val == 1) {
 		ret = i2c_transfer(client->adapter, msg, 1);
 		if (ret != 1) {
-			dev_warn(dev, "hmc6352_comp: i2c calib start cmd failed\n");
+			dev_warn(dev, "i2c calib start cmd failed\n");
 			return ret;
 		}
 	} else if (val == 2) {
 		ret = i2c_transfer(client->adapter, msg1, 1);
 		if (ret != 1) {
-			dev_warn(dev, "hmc6352_comp: i2c calib stop cmd failed\n");
+			dev_warn(dev, "i2c calib stop cmd failed\n");
 			return ret;
 		}
 	} else
@@ -65,9 +66,9 @@ static ssize_t compass_calibration_store(struct device *dev,
 }
 
 static ssize_t compass_heading_data_show(struct device *dev,
-			struct device_attribute *attr, char *buf)
+					 struct device_attribute *attr,
+					 char *buf)
 {
-
 	struct i2c_client *client = to_i2c_client(dev);
 	static char cmd = 'A';		/* Get Data */
 	unsigned char i2c_data[2];
@@ -81,22 +82,22 @@ static ssize_t compass_heading_data_show(struct device *dev,
 
 	ret = i2c_transfer(client->adapter, msg, 1);
 	if (ret != 1) {
-		dev_warn(dev, "hmc6352: i2c cmd 0x41 failed\n");
+		dev_warn(dev, "i2c cmd 0x41 failed\n");
 		return ret;
 	}
-	msleep(10); /* sending 0x41 cmd we need to wait for 7-10 milli second*/
+	msleep(10); /* sending 0x41 cmd we need to wait for 7-10 milliseconds */
 	ret = i2c_transfer(client->adapter, msg1, 1);
 	if (ret != 1) {
-		dev_warn(dev, "hmc6352: i2c read data cmd failed\n");
+		dev_warn(dev, "i2c read data cmd failed\n");
 		return ret;
 	}
-	ret_val = i2c_data[0];
-	ret_val = ((ret_val << 8) | i2c_data[1]);
+	ret_val = ((unsigned int)i2c_data[0] << 8) | i2c_data[1];
 	return sprintf(buf, "%d.%d\n", ret_val/10, ret_val%10);
 }
 
 static ssize_t compass_power_mode_store(struct device *dev,
-		struct device_attribute *attr, const  char *buf, size_t count)
+					struct device_attribute *attr,
+					const char *buf, size_t count)
 {
 
 	struct i2c_client *client = to_i2c_client(dev);
@@ -117,11 +118,11 @@ static ssize_t compass_power_mode_store(struct device *dev,
 	if (val == 0) {
 		ret = i2c_transfer(client->adapter, msg, 1);
 		if (ret != 1)
-			dev_warn(dev, "hmc6352: i2c cmd  sleep mode failed\n");
+			dev_warn(dev, "i2c cmd sleep mode failed\n");
 	} else if (val == 1) {
 		ret = i2c_transfer(client->adapter, msg1, 1);
 		if (ret != 1)
-			dev_warn(dev, "hmc6352: i2c cmd active mode failed\n");
+			dev_warn(dev, "i2c cmd active mode failed\n");
 	} else
 		return -EINVAL;
 
@@ -144,18 +145,17 @@ static struct attribute_group m_compass_gr = {
 	.attrs = mid_att_compass
 };
 
-static int  hmc6352_probe(struct i2c_client *client,
-					const struct i2c_device_id *id)
+static int hmc6352_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
 {
 	int res;
 
 	res = sysfs_create_group(&client->dev.kobj, &m_compass_gr);
 	if (res) {
-		dev_err(&client->dev, "hmc6352: device_create_file failed\n");
+		dev_err(&client->dev, "sysfs_create_group failed\n");
 		return res;
 	}
-	dev_info(&client->dev, "%s HMC6352 compass chip found\n",
-		client->name);
+	dev_info(&client->dev, "%s HMC6352 compass chip found\n", client->name);
 	return 0;
 }
 
@@ -174,7 +174,7 @@ MODULE_DEVICE_TABLE(i2c, hmc6352_id);
 
 static struct i2c_driver hmc6352_driver = {
 	.driver = {
-	.name = "hmc6352",
+		.name = "hmc6352",
 	},
 	.probe = hmc6352_probe,
 	.remove = hmc6352_remove,
@@ -186,7 +186,7 @@ static int __init sensor_hmc6352_init(void)
 	return i2c_add_driver(&hmc6352_driver);
 }
 
-static void  __exit sensor_hmc6352_exit(void)
+static void __exit sensor_hmc6352_exit(void)
 {
 	i2c_del_driver(&hmc6352_driver);
 }



  parent reply	other threads:[~2010-04-14 21:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-14 12:51 [PATCH 0/4] Various intel small device drivers Alan Cox
2010-04-14 12:51 ` [PATCH 1/4] hmc6352: Add driver for the HMC6352 compass Alan Cox
2010-04-14 13:48   ` Jonathan Cameron
2010-04-14 14:32     ` Alan Cox
2010-04-14 14:51       ` Jonathan Cameron
2010-04-14 15:19         ` Alan Cox
2010-04-14 16:39           ` Jonathan Cameron
2010-04-14 21:36           ` Joe Perches [this message]
2010-04-15 12:11             ` Alan Cox
2010-04-15 15:57               ` Joe Perches
2010-04-14 16:56         ` isl29020: ALS driver as misc device Alan Cox
2010-04-14 17:01           ` Greg KH
2010-04-15 10:09             ` Jonathan Cameron
2010-04-15 11:17               ` Alan Cox
2010-04-26 10:59                 ` Jonathan Cameron
2010-04-14 12:51 ` [PATCH 2/4] isl29020: ambient light sensor Alan Cox
2010-04-14 22:45   ` Daniel Mack
2010-04-14 22:35     ` Alan Cox
2010-04-15  6:20       ` Daniel Mack
2010-04-15 10:15         ` Jonathan Cameron
2010-04-14 12:52 ` [PATCH 3/4] liss331d1: accelerometer driver Alan Cox
2010-04-14 22:12   ` Éric Piel
2010-04-14 22:34     ` Daniel Mack
2010-04-14 23:05       ` Neil Brown
2010-04-15  9:47         ` Éric Piel
2010-04-14 22:37     ` Alan Cox
2010-04-15 10:28     ` Jonathan Cameron
2010-04-15 10:02       ` Alan Cox
2010-04-15 19:12   ` Pavel Machek
2010-04-14 12:52 ` [PATCH 4/4] emc1403: thermal sensor support Alan Cox
2010-04-14 13:30 ` [PATCH 0/4] Various intel small device drivers Jean Delvare
2010-04-14 13:49   ` Alan Cox
2010-04-14 13:55     ` Jonathan Cameron
2010-04-14 14:19       ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1271280993.1833.36.camel@Joe-Laptop.home \
    --to=joe@perches.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kalhan.trisal@intel.com \
    --cc=kernel@jic23.retrosnub.co.uk \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®