lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1271280993.1833.36.camel@Joe-Laptop.home>
Date:	Wed, 14 Apr 2010 14:36:33 -0700
From:	Joe Perches <joe@...ches.com>
To:	Alan Cox <alan@...rguk.ukuu.org.uk>,
	Kalhan Trisal <kalhan.trisal@...el.com>
Cc:	Jonathan Cameron <kernel@...23.retrosnub.co.uk>,
	linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] hmc6352: Add driver for the HMC6352 compass

Trivial neatening

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

Signed-off-by: Joe Perches <joe@...ches.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);
 }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ