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]
Date:	Sun, 12 Jul 2009 21:09:28 +0300
From:	Felipe Balbi <me@...ipebalbi.com>
To:	dwmw2@...radead.org
Cc:	linux-kernel@...r.kernel.org, Felipe Balbi <me@...ipebalbi.com>
Subject: [rfc/patch 06/15] power: bq27200: rename structure to something smaller

the previous name was quite big, rename to something smaller.

Trivial patch.

Signed-off-by: Felipe Balbi <me@...ipebalbi.com>
---
 drivers/power/bq27200_battery.c |   91 +++++++++++++++++++--------------------
 1 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
index deef1b5..44375d6 100644
--- a/drivers/power/bq27200_battery.c
+++ b/drivers/power/bq27200_battery.c
@@ -32,7 +32,7 @@
 #define BQ27200_REG_AI			0x14
 #define BQ27200_REG_FLAGS		0x0A
 
-struct bq27200_device_info {
+struct bq27200 {
 	struct power_supply	bat;
 	struct i2c_client	*client;
 
@@ -42,8 +42,7 @@ struct bq27200_device_info {
 	int			temp_C;
 };
 
-#define to_bq27200_device_info(x) container_of((x), \
-				struct bq27200_device_info, bat);
+#define to_bq27200(x) container_of((x), struct bq27200, bat);
 
 static enum power_supply_property bq27200_props[] = {
 	POWER_SUPPLY_PROP_PRESENT,
@@ -57,28 +56,27 @@ static enum power_supply_property bq27200_props[] = {
  * Common code for BQ27200 devices
  */
 
-static inline int bq27200_read(struct bq27200_device_info *di, u8 reg)
+static inline int bq27200_read(struct bq27200 *bq, u8 reg)
 {
-	return i2c_smbus_read_word_data(di->client, reg);
+	return i2c_smbus_read_word_data(bq->client, reg);
 }
 
-static inline int bq27200_write(struct bq27200_device_info *di,
-		u8 reg, u8 data)
+static inline int bq27200_write(struct bq27200 *bq, u8 reg, u8 data)
 {
-	return i2c_smbus_write_word_data(di->client, reg, data);
+	return i2c_smbus_write_word_data(bq->client, reg, data);
 }
 
 /*
  * Return the battery temperature in Celsius degrees
  * Or < 0 if something fails.
  */
-static int bq27200_temperature(struct bq27200_device_info *di)
+static int bq27200_temperature(struct bq27200 *bq)
 {
 	int ret;
 
-	ret = bq27200_read(di, BQ27200_REG_TEMP);
+	ret = bq27200_read(bq, BQ27200_REG_TEMP);
 	if (ret < 0) {
-		dev_err(&di->client->dev, "error reading temperature\n");
+		dev_err(&bq->client->dev, "error reading temperature\n");
 		return ret;
 	}
 
@@ -89,13 +87,13 @@ static int bq27200_temperature(struct bq27200_device_info *di)
  * Return the battery Voltage in milivolts
  * Or < 0 if something fails.
  */
-static int bq27200_voltage(struct bq27200_device_info *di)
+static int bq27200_voltage(struct bq27200 *bq)
 {
 	int ret;
 
-	ret = bq27200_read(di, BQ27200_REG_VOLT);
+	ret = bq27200_read(bq, BQ27200_REG_VOLT);
 	if (ret < 0)
-		dev_err(&di->client->dev, "error reading voltage\n");
+		dev_err(&bq->client->dev, "error reading voltage\n");
 
 	return ret;
 }
@@ -105,13 +103,13 @@ static int bq27200_voltage(struct bq27200_device_info *di)
  * Note that current can be negative signed as well
  * Or 0 if something fails.
  */
-static int bq27200_current(struct bq27200_device_info *di)
+static int bq27200_current(struct bq27200 *bq)
 {
 	int ret;
 
-	ret = bq27200_read(di, BQ27200_REG_AI);
+	ret = bq27200_read(bq, BQ27200_REG_AI);
 	if (ret < 0) {
-		dev_err(&di->client->dev, "error reading current\n");
+		dev_err(&bq->client->dev, "error reading current\n");
 		return 0;
 	}
 
@@ -122,13 +120,13 @@ static int bq27200_current(struct bq27200_device_info *di)
  * Return the battery Relative State-of-Charge
  * Or < 0 if something fails.
  */
-static int bq27200_rsoc(struct bq27200_device_info *di)
+static int bq27200_rsoc(struct bq27200 *bq)
 {
 	int ret;
 
-	ret = bq27200_read(di, BQ27200_REG_RSOC);
+	ret = bq27200_read(bq, BQ27200_REG_RSOC);
 	if (ret < 0) {
-		dev_err(&di->client->dev, "error reading relative State-of-Charge\n");
+		dev_err(&bq->client->dev, "error reading relative State-of-Charge\n");
 		return ret;
 	}
 
@@ -136,26 +134,28 @@ static int bq27200_rsoc(struct bq27200_device_info *di)
 }
 
 static int bq27200_get_property(struct power_supply *psy,
-					enum power_supply_property psp,
-					union power_supply_propval *val)
+		enum power_supply_property psp, union power_supply_propval *val)
 {
-	struct bq27200_device_info *di = to_bq27200_device_info(psy);
+	struct bq27200 *bq = to_bq27200(psy);
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 	case POWER_SUPPLY_PROP_PRESENT:
-		val->intval = bq27200_voltage(di);
+		val->intval = bq27200_voltage(bq);
+		if (val->intval < 0)
+			return val->intval;
+
 		if (psp == POWER_SUPPLY_PROP_PRESENT)
-			val->intval = val->intval <= 0 ? 0 : 1;
+			val->intval = !!val->intval;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
-		val->intval = bq27200_current(di);
+		val->intval = bq27200_current(bq);
 		break;
 	case POWER_SUPPLY_PROP_CAPACITY:
-		val->intval = bq27200_rsoc(di);
+		val->intval = bq27200_rsoc(bq);
 		break;
 	case POWER_SUPPLY_PROP_TEMP:
-		val->intval = bq27200_temperature(di);
+		val->intval = bq27200_temperature(bq);
 		break;
 	default:
 		return -EINVAL;
@@ -165,30 +165,29 @@ static int bq27200_get_property(struct power_supply *psy,
 }
 
 static int bq27200_battery_probe(struct i2c_client *client,
-				 const struct i2c_device_id *id)
+		const struct i2c_device_id *id)
 {
-	struct bq27200_device_info *di;
+	struct bq27200 *bq;
 	int retval = 0;
 
-	di = kzalloc(sizeof(*di), GFP_KERNEL);
-	if (!di) {
+	bq = kzalloc(sizeof(*bq), GFP_KERNEL);
+	if (!bq) {
 		dev_err(&client->dev, "failed to allocate device info data\n");
 		retval = -ENOMEM;
 		goto batt_failed_1;
 	}
 
-	i2c_set_clientdata(client, di);
-	di->client = client;
-	di->bat.name = client->name;
-	di->client = client;
+	i2c_set_clientdata(client, bq);
+	bq->client = client;
+	bq->bat.name = client->name;
+	bq->client = client;
 
-	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
-	di->bat.properties = bq27200_props;
-	di->bat.num_properties = ARRAY_SIZE(bq27200_props);
-	di->bat.get_property = bq27200_get_property;
-	di->bat.external_power_changed = NULL;
+	bq->bat.type = POWER_SUPPLY_TYPE_BATTERY;
+	bq->bat.properties = bq27200_props;
+	bq->bat.num_properties = ARRAY_SIZE(bq27200_props);
+	bq->bat.get_property = bq27200_get_property;
 
-	retval = power_supply_register(&client->dev, &di->bat);
+	retval = power_supply_register(&client->dev, &bq->bat);
 	if (retval) {
 		dev_err(&client->dev, "failed to register battery\n");
 		goto batt_failed_2;
@@ -197,7 +196,7 @@ static int bq27200_battery_probe(struct i2c_client *client,
 	return 0;
 
 batt_failed_2:
-	kfree(di);
+	kfree(bq);
 
 batt_failed_1:
 	return retval;
@@ -205,10 +204,10 @@ batt_failed_1:
 
 static int bq27200_battery_remove(struct i2c_client *client)
 {
-	struct bq27200_device_info *di = i2c_get_clientdata(client);
+	struct bq27200 *bq = i2c_get_clientdata(client);
 
-	power_supply_unregister(&di->bat);
-	kfree(di);
+	power_supply_unregister(&bq->bat);
+	kfree(bq);
 
 	return 0;
 }
-- 
1.6.1.3

--
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