[BATTERY] Run Lindent on drivers/battery/
David Woodhouse
dwmw2 at infradead.org
Tue Nov 7 22:38:26 EST 2006
Commit: 2c569104e3d59f809b0ba87691379975de49601b
Parent: 0aa9acc1c47dbb3c285d61bb55a1a363433c129f
commit 2c569104e3d59f809b0ba87691379975de49601b
Author: David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Wed Oct 25 12:48:12 2006 +0300
Commit: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Wed Oct 25 12:48:12 2006 +0300
[BATTERY] Run Lindent on drivers/battery/
It managed to become a horrid mix of spaces and tabs; possibly because
there was a certain amount of cut and paste from code using spaces.
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
drivers/battery/battery-class.c | 61 +++++++++++++------------
drivers/battery/olpc-battery.c | 96 +++++++++++++++++++--------------------
2 files changed, 79 insertions(+), 78 deletions(-)
diff --git a/drivers/battery/battery-class.c b/drivers/battery/battery-class.c
index 60325c4..31fdf97 100644
--- a/drivers/battery/battery-class.c
+++ b/drivers/battery/battery-class.c
@@ -28,7 +28,7 @@ static DEFINE_SPINLOCK(idr_lock);
ssize_t battery_attribute_show_status(char *buf, unsigned long status)
{
- ssize_t ret = 0;
+ ssize_t ret = 0;
if (status & BAT_STAT_PRESENT)
sprintf(buf, "present");
@@ -57,15 +57,17 @@ ssize_t battery_attribute_show_status(ch
strcat(buf, ",charge-done");
strcat(buf, "\n");
- ret = strlen(buf) + 1;
- return ret;
+ ret = strlen(buf) + 1;
+ return ret;
}
+
EXPORT_SYMBOL_GPL(battery_attribute_show_status);
ssize_t battery_attribute_show_ac_status(char *buf, unsigned long status)
{
- return 1 + sprintf(buf, "o%s-line\n", status?"n":"ff");
-}
+ return 1 + sprintf(buf, "o%s-line\n", status ? "n" : "ff");
+}
+
EXPORT_SYMBOL_GPL(battery_attribute_show_ac_status);
static ssize_t battery_attribute_show_name(struct device *dev,
@@ -95,46 +97,48 @@ static DEVICE_ATTR(type, 0444, battery_a
* @dev: The device to register.
* @battery_dev: the battery_dev structure for this device.
*/
-int battery_device_register(struct device *parent, struct battery_dev *battery_dev)
+int battery_device_register(struct device *parent,
+ struct battery_dev *battery_dev)
{
int err;
- if (battery_dev->type < PWRDEV_TYPE_BATTERY ||
- battery_dev->type > PWRDEV_TYPE_AC)
+ if (battery_dev->type < PWRDEV_TYPE_BATTERY
+ || battery_dev->type > PWRDEV_TYPE_AC)
return -EINVAL;
do {
if (unlikely(!idr_pre_get(&battery_idr, GFP_KERNEL)))
return -ENOMEM;
-
+
spin_lock(&idr_lock);
err = idr_get_new(&battery_idr, NULL, &battery_dev->id);
spin_unlock(&idr_lock);
- } while(err == -EAGAIN);
+ } while (err == -EAGAIN);
if (unlikely(err))
return err;
- battery_dev->dev = device_create(battery_class, parent, 0,
- "%d", battery_dev->id);
+ battery_dev->dev = device_create(battery_class, parent, 0,
+ "psu_%d", battery_dev->id);
- if (unlikely(IS_ERR(battery_dev->dev))) {
+ if (unlikely(IS_ERR(battery_dev->dev))) {
spin_lock(&idr_lock);
idr_remove(&battery_idr, battery_dev->id);
spin_unlock(&idr_lock);
- return PTR_ERR(battery_dev->dev);
+ return PTR_ERR(battery_dev->dev);
}
- dev_set_drvdata(battery_dev->dev, battery_dev);
+ dev_set_drvdata(battery_dev->dev, battery_dev);
- /* register the attributes */
- device_create_file(battery_dev->dev, &dev_attr_type);
- device_create_file(battery_dev->dev, &dev_attr_name);
+ /* register the attributes */
+ device_create_file(battery_dev->dev, &dev_attr_type);
+ device_create_file(battery_dev->dev, &dev_attr_name);
- dev_info(battery_dev->dev, "Registered power source\n");
+ dev_info(battery_dev->dev, "Registered power source\n");
- return 0;
+ return 0;
}
+
EXPORT_SYMBOL_GPL(battery_device_register);
/**
@@ -145,28 +149,29 @@ EXPORT_SYMBOL_GPL(battery_device_registe
*/
void battery_device_unregister(struct battery_dev *battery_dev)
{
- device_remove_file(battery_dev->dev, &dev_attr_type);
- device_remove_file(battery_dev->dev, &dev_attr_name);
+ device_remove_file(battery_dev->dev, &dev_attr_type);
+ device_remove_file(battery_dev->dev, &dev_attr_name);
- device_unregister(battery_dev->dev);
+ device_unregister(battery_dev->dev);
spin_lock(&idr_lock);
idr_remove(&battery_idr, battery_dev->id);
spin_unlock(&idr_lock);
}
+
EXPORT_SYMBOL_GPL(battery_device_unregister);
static int __init battery_init(void)
{
- battery_class = class_create(THIS_MODULE, "battery");
- if (IS_ERR(battery_class))
- return PTR_ERR(battery_class);
- return 0;
+ battery_class = class_create(THIS_MODULE, "battery");
+ if (IS_ERR(battery_class))
+ return PTR_ERR(battery_class);
+ return 0;
}
static void __exit battery_exit(void)
{
- class_destroy(battery_class);
+ class_destroy(battery_class);
}
subsys_initcall(battery_init);
diff --git a/drivers/battery/olpc-battery.c b/drivers/battery/olpc-battery.c
index 2057b7c..e62bbdb 100644
--- a/drivers/battery/olpc-battery.c
+++ b/drivers/battery/olpc-battery.c
@@ -17,11 +17,11 @@ #include <linux/err.h>
#include <linux/platform_device.h>
#include <asm/io.h>
-#define wBAT_VOLTAGE 0xf900 /* *9.76/32, mV */
-#define wBAT_CURRENT 0xf902 /* *15.625/120, mA */
-#define wBAT_TEMP 0xf906 /* *256/1000, °C */
-#define wAMB_TEMP 0xf908 /* *256/1000, °C */
-#define SOC 0xf910 /* percentage */
+#define wBAT_VOLTAGE 0xf900 /* *9.76/32, mV */
+#define wBAT_CURRENT 0xf902 /* *15.625/120, mA */
+#define wBAT_TEMP 0xf906 /* *256/1000, °C */
+#define wAMB_TEMP 0xf908 /* *256/1000, °C */
+#define SOC 0xf910 /* percentage */
#define sMBAT_STATUS 0xfaa4
#define sBAT_PRESENT 1
#define sBAT_FULL 2
@@ -41,17 +41,17 @@ #define ADAPTER_IN 1
static int lock_ec(void)
{
- unsigned long timeo = jiffies + HZ/20;
+ unsigned long timeo = jiffies + HZ / 20;
while (1) {
- unsigned char lock = inb(0x6c) & 0x80;
- if (!lock)
- return 0;
+ unsigned char lock = inb(0x6c) & 0x80;
+ if (!lock)
+ return 0;
if (time_after(jiffies, timeo)) {
printk(KERN_ERR "Failed to lock EC for battery access\n");
return 1;
}
- yield();
+ yield();
}
}
@@ -69,15 +69,14 @@ static unsigned char read_ec_byte(unsign
unsigned short read_ec_word(unsigned short adr)
{
- return (read_ec_byte(adr) << 8) | read_ec_byte(adr+1);
+ return (read_ec_byte(adr) << 8) | read_ec_byte(adr + 1);
}
/*********************************************************************
* Status flags
*********************************************************************/
static ssize_t olpc_ac_status_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+ struct device_attribute *attr, char *buf)
{
unsigned long status;
@@ -96,12 +95,11 @@ static ssize_t olpc_ac_status_show(struc
return battery_attribute_show_ac_status(buf, status);
}
-static struct device_attribute dev_attr_ac_status =
- __ATTR(status, 0444, olpc_ac_status_show, NULL);
+static struct device_attribute dev_attr_ac_status =
+__ATTR(status, 0444, olpc_ac_status_show, NULL);
static ssize_t olpc_bat_status_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+ struct device_attribute *attr, char *buf)
{
unsigned long status = 0;
unsigned short tmp;
@@ -110,7 +108,7 @@ static ssize_t olpc_bat_status_show(stru
return -EIO;
tmp = read_ec_byte(sMBAT_STATUS);
-
+
if (tmp & sBAT_PRESENT)
status |= BAT_STAT_PRESENT;
if (tmp & sBAT_FULL)
@@ -131,8 +129,8 @@ static ssize_t olpc_bat_status_show(stru
unlock_ec();
return battery_attribute_show_status(buf, status);
}
-static struct device_attribute dev_attr_bat_status =
- __ATTR(status, 0444, olpc_bat_status_show, NULL);
+static struct device_attribute dev_attr_bat_status =
+__ATTR(status, 0444, olpc_bat_status_show, NULL);
/*********************************************************************
* Integer attributes
@@ -154,8 +152,7 @@ #define ATTR_INT(_name, _adr, _mul, _div
}
static int olpc_bat_attr_int_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+ struct device_attribute *attr, char *buf)
{
struct olpc_bat_attr_int *battr = (void *)attr;
long value;
@@ -182,14 +179,13 @@ static int olpc_bat_attr_int_show(struct
}
static struct olpc_bat_attr_int attrs_int[] = {
- ATTR_INT(BAT_INFO_VOLTAGE, wBAT_VOLTAGE, 9760, 32000),
+ ATTR_INT(BAT_INFO_VOLTAGE, wBAT_VOLTAGE, 9760, 32000),
ATTR_INT(BAT_INFO_CURRENT, wBAT_CURRENT, 15625, 120000),
- ATTR_INT(BAT_INFO_TEMP1, wBAT_TEMP, 1000, 256),
- ATTR_INT(BAT_INFO_TEMP2, wAMB_TEMP, 1000, 256),
- ATTR_INT(BAT_INFO_CHARGE_PCT, SOC, 1, 1)
+ ATTR_INT(BAT_INFO_TEMP1, wBAT_TEMP, 1000, 256),
+ ATTR_INT(BAT_INFO_TEMP2, wAMB_TEMP, 1000, 256),
+ ATTR_INT(BAT_INFO_CHARGE_PCT, SOC, 1, 1)
};
-
/*********************************************************************
* String attributes
*********************************************************************/
@@ -207,8 +203,7 @@ #define ATTR_STR(_name, _str) { \
}
static int olpc_bat_attr_str_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+ struct device_attribute *attr, char *buf)
{
struct olpc_bat_attr_str *sattr = (void *)attr;
unsigned short tmp;
@@ -221,20 +216,21 @@ static int olpc_bat_attr_str_show(struct
if (lock_ec())
ret = -EIO;
-
+
if (!(read_ec_byte(sMBAT_STATUS) & sBAT_PRESENT))
ret = -ENODEV;
- else switch((unsigned long)sattr->str) {
- case 1:
- tmp = read_ec_byte(sMCHARGE_STATUS);
- if (tmp & sBAT_NiMH)
- ret = 1 + sprintf(buf, "NiMH\n");
- else
- ret = 1 + sprintf(buf, "unknown\n");
- break;
- default:
- printk(KERN_ERR "Unknown string type %p\n", sattr->str);
- }
+ else
+ switch ((unsigned long)sattr->str) {
+ case 1:
+ tmp = read_ec_byte(sMCHARGE_STATUS);
+ if (tmp & sBAT_NiMH)
+ ret = 1 + sprintf(buf, "NiMH\n");
+ else
+ ret = 1 + sprintf(buf, "unknown\n");
+ break;
+ default:
+ printk(KERN_ERR "Unknown string type %p\n", sattr->str);
+ }
unlock_ec();
return ret;
@@ -281,7 +277,8 @@ int __init olpc_bat_init(void)
return -ENODEV;
}
- bat_plat_dev = platform_device_register_simple("olpc-battery", 0, NULL, 0);
+ bat_plat_dev =
+ platform_device_register_simple("olpc-battery", 0, NULL, 0);
if (IS_ERR(bat_plat_dev))
goto out_rel;
@@ -292,20 +289,20 @@ int __init olpc_bat_init(void)
ret = battery_device_register(&bat_plat_dev->dev, &olpc_ac);
if (ret) {
battery_device_unregister(&olpc_bat);
- out_plat:
+ out_plat:
platform_device_unregister(bat_plat_dev);
- out_rel:
+ out_rel:
release_region(0x380, 4);
return ret;
}
- for (i=0; i < ARRAY_SIZE(attrs_int); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs_int); i++)
device_create_file(olpc_bat.dev, &attrs_int[i].dev_attr);
- for (i=0; i < ARRAY_SIZE(attrs_str); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs_str); i++)
device_create_file(olpc_bat.dev, &attrs_str[i].dev_attr);
device_create_file(olpc_bat.dev, &dev_attr_bat_status);
device_create_file(olpc_ac.dev, &dev_attr_ac_status);
-
+
return ret;
}
@@ -316,9 +313,9 @@ void __exit olpc_bat_exit(void)
device_remove_file(olpc_bat.dev, &dev_attr_bat_status);
device_remove_file(olpc_ac.dev, &dev_attr_ac_status);
- for (i=0; i < ARRAY_SIZE(attrs_int); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs_int); i++)
device_remove_file(olpc_bat.dev, &attrs_int[i].dev_attr);
- for (i=0; i < ARRAY_SIZE(attrs_str); i++)
+ for (i = 0; i < ARRAY_SIZE(attrs_str); i++)
device_remove_file(olpc_bat.dev, &attrs_str[i].dev_attr);
battery_device_unregister(&olpc_ac);
battery_device_unregister(&olpc_bat);
@@ -326,7 +323,6 @@ void __exit olpc_bat_exit(void)
release_region(0x380, 4);
}
-
module_init(olpc_bat_init);
module_exit(olpc_bat_exit);
More information about the Commits-kernel
mailing list