All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Alexey Starikovskiy <aystarik@gmail.com>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 13/77] ACPI: battery: syntax cleanup
Date: Sun, 22 Jul 2007 05:13:58 -0400	[thread overview]
Message-ID: <1185095715506-git-send-email-len.brown@intel.com> (raw)
Message-ID: <78490d82129f7331d1366737c8704c1c053221a3.1185095456.git.len.brown@intel.com> (raw)
In-Reply-To: <1185095714699-git-send-email-len.brown@intel.com>
In-Reply-To: <a1f0eff21edac1bd87e397f56c4258b9611b5a50.1185095456.git.len.brown@intel.com>

From: Alexey Starikovskiy <aystarik@gmail.com>

In response to review comments from Andrew Morton

Signed-off-by: Alexey Starikovskiy <aystarik@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/acpi/battery.c |  418 ++++++++++++++++++++----------------------------
 1 files changed, 172 insertions(+), 246 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b5df318..cad932d 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -43,9 +43,6 @@
 #define ACPI_BATTERY_CLASS		"battery"
 #define ACPI_BATTERY_HID		"PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
-#define ACPI_BATTERY_FILE_INFO		"info"
-#define ACPI_BATTERY_FILE_STATE		"state"
-#define ACPI_BATTERY_FILE_ALARM		"alarm"
 #define ACPI_BATTERY_NOTIFY_STATUS	0x80
 #define ACPI_BATTERY_NOTIFY_INFO	0x81
 #define ACPI_BATTERY_UNITS_WATTS	"mW"
@@ -111,13 +108,18 @@ struct acpi_battery_info {
 	acpi_string oem_info;
 };
 
+enum acpi_battery_files{
+	ACPI_BATTERY_INFO = 0,
+	ACPI_BATTERY_STATE,
+	ACPI_BATTERY_ALARM,
+	ACPI_BATTERY_NUMFILES,
+};
+
 struct acpi_battery_flags {
 	u8 battery_present_prev;
 	u8 alarm_present;
 	u8 init_update;
-	u8 info_update;
-	u8 state_update;
-	u8 alarm_update;
+	u8 update[ACPI_BATTERY_NUMFILES];
 	u8 power_unit;
 };
 
@@ -128,47 +130,37 @@ struct acpi_battery {
 	struct acpi_buffer bif_data;
 	struct acpi_buffer bst_data;
 	unsigned long alarm;
-	unsigned long info_update_time;
-	unsigned long state_update_time;
-	unsigned long alarm_update_time;
+	unsigned long update_time[ACPI_BATTERY_NUMFILES];
 };
 
-#define acpi_battery_present(battery) battery->device->status.battery_present
-#define acpi_battery_present_prev(battery) battery->flags.battery_present_prev
-#define acpi_battery_alarm_present(battery) battery->flags.alarm_present
-#define acpi_battery_init_update_flag(battery) battery->flags.init_update
-#define acpi_battery_info_update_flag(battery) battery->flags.info_update
-#define acpi_battery_state_update_flag(battery) battery->flags.state_update
-#define acpi_battery_alarm_update_flag(battery) battery->flags.alarm_update
-#define acpi_battery_power_units(battery) battery->flags.power_unit ? \
-		ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS
-#define acpi_battery_handle(battery) battery->device->handle
-#define acpi_battery_inserted(battery) (!acpi_battery_present_prev(battery) & acpi_battery_present(battery))
-#define acpi_battery_removed(battery) (acpi_battery_present_prev(battery) & !acpi_battery_present(battery))
-#define acpi_battery_bid(battery) acpi_device_bid(battery->device)
-#define acpi_battery_status_str(battery) acpi_battery_present(battery) ? "present" : "absent"
-
-/* --------------------------------------------------------------------------
-                               Battery Management
-   -------------------------------------------------------------------------- */
-
-static void acpi_battery_mutex_lock(struct acpi_battery *battery)
+inline int acpi_battery_present(struct acpi_battery *battery)
 {
-	mutex_lock(&battery->mutex);
+	return battery->device->status.battery_present;
+}
+inline char *acpi_battery_power_units(struct acpi_battery *battery)
+{
+	if (battery->flags.power_unit)
+		return ACPI_BATTERY_UNITS_AMPS;
+	else
+		return ACPI_BATTERY_UNITS_WATTS;
 }
 
-static void acpi_battery_mutex_unlock(struct acpi_battery *battery)
+inline acpi_handle acpi_battery_handle(struct acpi_battery *battery)
 {
-	mutex_unlock(&battery->mutex);
+	return battery->device->handle;
 }
 
+/* --------------------------------------------------------------------------
+                               Battery Management
+   -------------------------------------------------------------------------- */
+
 static void acpi_battery_check_result(struct acpi_battery *battery, int result)
 {
 	if (!battery)
 		return;
 
 	if (result) {
-		acpi_battery_init_update_flag(battery) = 1;
+		battery->flags.init_update = 1;
 	}
 }
 
@@ -189,9 +181,7 @@ static int acpi_battery_extract_package(struct acpi_battery *battery,
 	}
 
 	if (data_null.length != data->length) {
-		if (data->pointer) {
-			kfree(data->pointer);
-		}
+		kfree(data->pointer);
 		data->pointer = kzalloc(data_null.length, GFP_KERNEL);
 		if (!data->pointer) {
 			ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()"));
@@ -234,12 +224,12 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
 	struct acpi_buffer *data = NULL;
 	struct acpi_battery_info *bif = NULL;
 
-	battery->info_update_time = get_seconds();
+	battery->update_time[ACPI_BATTERY_INFO] = get_seconds();
 
 	if (!acpi_battery_present(battery))
 		return 0;
 
-	/* Evalute _BIF */
+	/* Evaluate _BIF */
 
 	status =
 	    acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
@@ -263,9 +253,7 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
 
       end:
 
-	if (buffer.pointer) {
-		kfree(buffer.pointer);
-	}
+	kfree(buffer.pointer);
 
 	if (!result) {
 		bif = data->pointer;
@@ -286,12 +274,12 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
 	union acpi_object *package = NULL;
 	struct acpi_buffer *data = NULL;
 
-	battery->state_update_time = get_seconds();
+	battery->update_time[ACPI_BATTERY_STATE] = get_seconds();
 
 	if (!acpi_battery_present(battery))
 		return 0;
 
-	/* Evalute _BST */
+	/* Evaluate _BST */
 
 	status =
 	    acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
@@ -314,16 +302,14 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
 		goto end;
 
       end:
-	if (buffer.pointer) {
-		kfree(buffer.pointer);
-	}
+	kfree(buffer.pointer);
 
 	return result;
 }
 
 static int acpi_battery_get_alarm(struct acpi_battery *battery)
 {
-	battery->alarm_update_time = get_seconds();
+	battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
 
 	return 0;
 }
@@ -335,12 +321,12 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery,
 	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
 	struct acpi_object_list arg_list = { 1, &arg0 };
 
-	battery->alarm_update_time = get_seconds();
+	battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
 
 	if (!acpi_battery_present(battery))
 		return -ENODEV;
 
-	if (!acpi_battery_alarm_present(battery))
+	if (!battery->flags.alarm_present)
 		return -ENODEV;
 
 	arg0.integer.value = alarm;
@@ -370,7 +356,7 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery)
 
 	status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle);
 	if (ACPI_SUCCESS(status)) {
-		acpi_battery_alarm_present(battery) = 1;
+		battery->flags.alarm_present = 1;
 		if (!alarm && bif) {
 			alarm = bif->design_capacity_warning;
 		}
@@ -378,7 +364,7 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery)
 		if (result)
 			goto end;
 	} else {
-		acpi_battery_alarm_present(battery) = 0;
+		battery->flags.alarm_present = 0;
 	}
 
       end:
@@ -394,7 +380,7 @@ static int acpi_battery_init_update(struct acpi_battery *battery)
 	if (result)
 		return result;
 
-	acpi_battery_present_prev(battery) = acpi_battery_present(battery);
+	battery->flags.battery_present_prev = acpi_battery_present(battery);
 
 	if (acpi_battery_present(battery)) {
 		result = acpi_battery_get_info(battery);
@@ -420,20 +406,20 @@ static int acpi_battery_update(struct acpi_battery *battery,
 		update = 1;
 	}
 
-	if (acpi_battery_init_update_flag(battery)) {
+	if (battery->flags.init_update) {
 		result = acpi_battery_init_update(battery);
 		if (result)
-			goto end;;
+			goto end;
 		update_result = ACPI_BATTERY_INIT_UPDATE;
 	} else if (update) {
 		result = acpi_battery_get_status(battery);
 		if (result)
-			goto end;;
-		if (acpi_battery_inserted(battery)
-		    || acpi_battery_removed(battery)) {
+			goto end;
+		if ((!battery->flags.battery_present_prev & acpi_battery_present(battery))
+		    || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) {
 			result = acpi_battery_init_update(battery);
 			if (result)
-				goto end;;
+				goto end;
 			update_result = ACPI_BATTERY_INIT_UPDATE;
 		} else {
 			update_result = ACPI_BATTERY_EASY_UPDATE;
@@ -442,7 +428,7 @@ static int acpi_battery_update(struct acpi_battery *battery,
 
       end:
 
-	acpi_battery_init_update_flag(battery) = (result != 0);
+	battery->flags.init_update = (result != 0);
 
 	*update_result_ptr = update_result;
 
@@ -453,16 +439,19 @@ static void acpi_battery_notify_update(struct acpi_battery *battery)
 {
 	acpi_battery_get_status(battery);
 
-	if (acpi_battery_init_update_flag(battery)) {
+	if (battery->flags.init_update) {
 		return;
 	}
 
-	if (acpi_battery_inserted(battery) || acpi_battery_removed(battery)) {
-		acpi_battery_init_update_flag(battery) = 1;
+	if ((!battery->flags.battery_present_prev &
+	     acpi_battery_present(battery)) ||
+	    (battery->flags.battery_present_prev &
+	     !acpi_battery_present(battery))) {
+		battery->flags.init_update = 1;
 	} else {
-		acpi_battery_info_update_flag(battery) = 1;
-		acpi_battery_state_update_flag(battery) = 1;
-		acpi_battery_alarm_update_flag(battery) = 1;
+		battery->flags.update[ACPI_BATTERY_INFO] = 1;
+		battery->flags.update[ACPI_BATTERY_STATE] = 1;
+		battery->flags.update[ACPI_BATTERY_ALARM] = 1;
 	}
 }
 
@@ -472,7 +461,7 @@ static void acpi_battery_notify_update(struct acpi_battery *battery)
 
 static struct proc_dir_entry *acpi_battery_dir;
 
-static int acpi_battery_read_info_print(struct seq_file *seq, int result)
+static int acpi_battery_print_info(struct seq_file *seq, int result)
 {
 	struct acpi_battery *battery = seq->private;
 	struct acpi_battery_info *bif = NULL;
@@ -549,49 +538,7 @@ static int acpi_battery_read_info_print(struct seq_file *seq, int result)
 	return result;
 }
 
-static int acpi_battery_read_info(struct seq_file *seq, void *offset)
-{
-	struct acpi_battery *battery = seq->private;
-	int result = 0;
-	int update_result = ACPI_BATTERY_NONE_UPDATE;
-	int update = 0;
-
-	acpi_battery_mutex_lock(battery);
-
-	update = (get_seconds() - battery->info_update_time >= update_time);
-	update = (update | acpi_battery_info_update_flag(battery));
-
-	result = acpi_battery_update(battery, update, &update_result);
-	if (result)
-		goto end;
-
-	/* Battery Info (_BIF) */
-
-	if (update_result == ACPI_BATTERY_EASY_UPDATE) {
-		result = acpi_battery_get_info(battery);
-		if (result)
-			goto end;
-	}
-
-      end:
-
-	result = acpi_battery_read_info_print(seq, result);
-
-	acpi_battery_check_result(battery, result);
-
-	acpi_battery_info_update_flag(battery) = result;
-
-	acpi_battery_mutex_unlock(battery);
-
-	return result;
-}
-
-static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
-{
-	return single_open(file, acpi_battery_read_info, PDE(inode)->data);
-}
-
-static int acpi_battery_read_state_print(struct seq_file *seq, int result)
+static int acpi_battery_print_state(struct seq_file *seq, int result)
 {
 	struct acpi_battery *battery = seq->private;
 	struct acpi_battery_state *bst = NULL;
@@ -661,49 +608,7 @@ static int acpi_battery_read_state_print(struct seq_file *seq, int result)
 	return result;
 }
 
-static int acpi_battery_read_state(struct seq_file *seq, void *offset)
-{
-	struct acpi_battery *battery = seq->private;
-	int result = 0;
-	int update_result = ACPI_BATTERY_NONE_UPDATE;
-	int update = 0;
-
-	acpi_battery_mutex_lock(battery);
-
-	update = (get_seconds() - battery->state_update_time >= update_time);
-	update = (update | acpi_battery_state_update_flag(battery));
-
-	result = acpi_battery_update(battery, update, &update_result);
-	if (result)
-		goto end;
-
-	/* Battery State (_BST) */
-
-	if (update_result == ACPI_BATTERY_EASY_UPDATE) {
-		result = acpi_battery_get_state(battery);
-		if (result)
-			goto end;
-	}
-
-      end:
-
-	result = acpi_battery_read_state_print(seq, result);
-
-	acpi_battery_check_result(battery, result);
-
-	acpi_battery_state_update_flag(battery) = result;
-
-	acpi_battery_mutex_unlock(battery);
-
-	return result;
-}
-
-static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
-{
-	return single_open(file, acpi_battery_read_state, PDE(inode)->data);
-}
-
-static int acpi_battery_read_alarm_print(struct seq_file *seq, int result)
+static int acpi_battery_print_alarm(struct seq_file *seq, int result)
 {
 	struct acpi_battery *battery = seq->private;
 	char *units = "?";
@@ -734,43 +639,6 @@ static int acpi_battery_read_alarm_print(struct seq_file *seq, int result)
 	return result;
 }
 
-static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
-{
-	struct acpi_battery *battery = seq->private;
-	int result = 0;
-	int update_result = ACPI_BATTERY_NONE_UPDATE;
-	int update = 0;
-
-	acpi_battery_mutex_lock(battery);
-
-	update = (get_seconds() - battery->alarm_update_time >= update_time);
-	update = (update | acpi_battery_alarm_update_flag(battery));
-
-	result = acpi_battery_update(battery, update, &update_result);
-	if (result)
-		goto end;
-
-	/* Battery Alarm */
-
-	if (update_result == ACPI_BATTERY_EASY_UPDATE) {
-		result = acpi_battery_get_alarm(battery);
-		if (result)
-			goto end;
-	}
-
-      end:
-
-	result = acpi_battery_read_alarm_print(seq, result);
-
-	acpi_battery_check_result(battery, result);
-
-	acpi_battery_alarm_update_flag(battery) = result;
-
-	acpi_battery_mutex_unlock(battery);
-
-	return result;
-}
-
 static ssize_t
 acpi_battery_write_alarm(struct file *file,
 			 const char __user * buffer,
@@ -785,7 +653,7 @@ acpi_battery_write_alarm(struct file *file,
 	if (!battery || (count > sizeof(alarm_string) - 1))
 		return -EINVAL;
 
-	acpi_battery_mutex_lock(battery);
+	mutex_lock(&battery->mutex);
 
 	result = acpi_battery_update(battery, 1, &update_result);
 	if (result) {
@@ -817,44 +685,128 @@ acpi_battery_write_alarm(struct file *file,
 	if (!result)
 		result = count;
 
-	acpi_battery_mutex_unlock(battery);
+	mutex_unlock(&battery->mutex);
+
+	return result;
+}
+
+typedef int(*print_func)(struct seq_file *seq, int result);
+typedef int(*get_func)(struct acpi_battery *battery);
+
+static struct acpi_read_mux {
+	print_func print;
+	get_func get;
+} acpi_read_funcs[ACPI_BATTERY_NUMFILES] = {
+	{.get = acpi_battery_get_info, .print = acpi_battery_print_info},
+	{.get = acpi_battery_get_state, .print = acpi_battery_print_state},
+	{.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm},
+};
 
+static int acpi_battery_read(int fid, struct seq_file *seq)
+{
+	struct acpi_battery *battery = seq->private;
+	int result = 0;
+	int update_result = ACPI_BATTERY_NONE_UPDATE;
+	int update = 0;
+
+	mutex_lock(&battery->mutex);
+
+	update = (get_seconds() - battery->update_time[fid] >= update_time);
+	update = (update | battery->flags.update[fid]);
+
+	result = acpi_battery_update(battery, update, &update_result);
+	if (result)
+		goto end;
+
+	if (update_result == ACPI_BATTERY_EASY_UPDATE) {
+		result = acpi_read_funcs[fid].get(battery);
+		if (result)
+			goto end;
+	}
+
+      end:
+	result = acpi_read_funcs[fid].print(seq, result);
+	acpi_battery_check_result(battery, result);
+	battery->flags.update[fid] = result;
+	mutex_unlock(&battery->mutex);
 	return result;
 }
 
+static int acpi_battery_read_info(struct seq_file *seq, void *offset)
+{
+	return acpi_battery_read(ACPI_BATTERY_INFO, seq);
+}
+
+static int acpi_battery_read_state(struct seq_file *seq, void *offset)
+{
+	return acpi_battery_read(ACPI_BATTERY_STATE, seq);
+}
+
+static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
+{
+	return acpi_battery_read(ACPI_BATTERY_ALARM, seq);
+}
+
+static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_battery_read_info, PDE(inode)->data);
+}
+
+static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_battery_read_state, PDE(inode)->data);
+}
+
 static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
 {
 	return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
 }
 
-static const struct file_operations acpi_battery_info_ops = {
+static struct battery_file {
+	struct file_operations ops;
+	mode_t mode;
+	char *name;
+} acpi_battery_file[] = {
+	{
+	.name = "info",
+	.mode = S_IRUGO,
+	.ops = {
 	.open = acpi_battery_info_open_fs,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = single_release,
 	.owner = THIS_MODULE,
-};
-
-static const struct file_operations acpi_battery_state_ops = {
+	},
+	},
+	{
+	.name = "state",
+	.mode = S_IRUGO,
+	.ops = {
 	.open = acpi_battery_state_open_fs,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = single_release,
 	.owner = THIS_MODULE,
-};
-
-static const struct file_operations acpi_battery_alarm_ops = {
+	},
+	},
+	{
+	.name = "alarm",
+	.mode = S_IFREG | S_IRUGO | S_IWUSR,
+	.ops = {
 	.open = acpi_battery_alarm_open_fs,
 	.read = seq_read,
 	.write = acpi_battery_write_alarm,
 	.llseek = seq_lseek,
 	.release = single_release,
 	.owner = THIS_MODULE,
+	},
+	},
 };
 
 static int acpi_battery_add_fs(struct acpi_device *device)
 {
 	struct proc_dir_entry *entry = NULL;
+	int i;
 
 	if (!acpi_device_dir(device)) {
 		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@ -864,38 +816,16 @@ static int acpi_battery_add_fs(struct acpi_device *device)
 		acpi_device_dir(device)->owner = THIS_MODULE;
 	}
 
-	/* 'info' [R] */
-	entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
-				  S_IRUGO, acpi_device_dir(device));
-	if (!entry)
-		return -ENODEV;
-	else {
-		entry->proc_fops = &acpi_battery_info_ops;
-		entry->data = acpi_driver_data(device);
-		entry->owner = THIS_MODULE;
-	}
-
-	/* 'status' [R] */
-	entry = create_proc_entry(ACPI_BATTERY_FILE_STATE,
-				  S_IRUGO, acpi_device_dir(device));
-	if (!entry)
-		return -ENODEV;
-	else {
-		entry->proc_fops = &acpi_battery_state_ops;
-		entry->data = acpi_driver_data(device);
-		entry->owner = THIS_MODULE;
-	}
-
-	/* 'alarm' [R/W] */
-	entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
-				  S_IFREG | S_IRUGO | S_IWUSR,
-				  acpi_device_dir(device));
-	if (!entry)
-		return -ENODEV;
-	else {
-		entry->proc_fops = &acpi_battery_alarm_ops;
-		entry->data = acpi_driver_data(device);
-		entry->owner = THIS_MODULE;
+	for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
+		entry = create_proc_entry(acpi_battery_file[i].name,
+				  acpi_battery_file[i].mode, acpi_device_dir(device));
+		if (!entry)
+			return -ENODEV;
+		else {
+			entry->proc_fops = &acpi_battery_file[i].ops;
+			entry->data = acpi_driver_data(device);
+			entry->owner = THIS_MODULE;
+		}
 	}
 
 	return 0;
@@ -903,14 +833,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
 
 static int acpi_battery_remove_fs(struct acpi_device *device)
 {
+	int i;
 	if (acpi_device_dir(device)) {
-		remove_proc_entry(ACPI_BATTERY_FILE_ALARM,
-				  acpi_device_dir(device));
-		remove_proc_entry(ACPI_BATTERY_FILE_STATE,
-				  acpi_device_dir(device));
-		remove_proc_entry(ACPI_BATTERY_FILE_INFO,
+		for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
+			remove_proc_entry(acpi_battery_file[i].name,
 				  acpi_device_dir(device));
-
+		}
 		remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
 		acpi_device_dir(device) = NULL;
 	}
@@ -966,7 +894,7 @@ static int acpi_battery_add(struct acpi_device *device)
 
 	mutex_init(&battery->mutex);
 
-	acpi_battery_mutex_lock(battery);
+	mutex_lock(&battery->mutex);
 
 	battery->device = device;
 	strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
@@ -977,7 +905,7 @@ static int acpi_battery_add(struct acpi_device *device)
 	if (result)
 		goto end;
 
-	acpi_battery_init_update_flag(battery) = 1;
+	battery->flags.init_update = 1;
 
 	result = acpi_battery_add_fs(device);
 	if (result)
@@ -1003,7 +931,7 @@ static int acpi_battery_add(struct acpi_device *device)
 		kfree(battery);
 	}
 
-	acpi_battery_mutex_unlock(battery);
+	mutex_unlock(&battery->mutex);
 
 	return result;
 }
@@ -1018,7 +946,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
 
 	battery = acpi_driver_data(device);
 
-	acpi_battery_mutex_lock(battery);
+	mutex_lock(&battery->mutex);
 
 	status = acpi_remove_notify_handler(device->handle,
 					    ACPI_ALL_NOTIFY,
@@ -1026,13 +954,11 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
 
 	acpi_battery_remove_fs(device);
 
-	if (battery->bif_data.pointer)
-		kfree(battery->bif_data.pointer);
+	kfree(battery->bif_data.pointer);
 
-	if (battery->bst_data.pointer)
-		kfree(battery->bst_data.pointer);
+	kfree(battery->bst_data.pointer);
 
-	acpi_battery_mutex_unlock(battery);
+	mutex_unlock(&battery->mutex);
 
 	mutex_destroy(&battery->mutex);
 
@@ -1051,7 +977,7 @@ static int acpi_battery_resume(struct acpi_device *device)
 
 	battery = device->driver_data;
 
-	acpi_battery_init_update_flag(battery) = 1;
+	battery->flags.init_update = 1;
 
 	return 0;
 }
-- 
1.5.3.rc2.22.g69a9b

  parent reply	other threads:[~2007-07-22  9:15 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-22  9:13 ACPI patches for 2.6.23 Len Brown
2007-07-22  9:13 ` [PATCH 01/77] ACPI: battery: make internal names consistent with battery "state" Len Brown
2007-07-22  9:13   ` Len Brown
2007-07-22  9:13   ` [PATCH 02/77] ACPI: Cache battery status instead of re-evaluating AML Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 03/77] ACPI: battery: Lindent Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 04/77] process reading battery status hangs Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 05/77] ACPI: video: output switch sysfs support Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 06/77] ACPI: dock: cleanup the uid patch Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 07/77] ACPI: dock: fix opps after dock driver fails to initialize Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 08/77] ACPI: dock: use dynamically allocated platform device Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 09/77] ACPI: dock: add immediate_undock option Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 10/77] ACPI: dock: unsuppress uevents Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 11/77] ACPI: dock: send envp with uevent Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` [PATCH 12/77] ACPI: bay: unsuppress uevents Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:13   ` Len Brown [this message]
2007-07-22  9:13     ` [PATCH 13/77] ACPI: battery: syntax cleanup Len Brown
2007-07-22  9:13   ` [PATCH 14/77] ACPI: add ACPI 3.0 _TPC _TSS _PTC throttling support Len Brown
2007-07-22  9:13     ` Len Brown
2007-07-22  9:14   ` [PATCH 15/77] ACPI: Lindent processor throttling code Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 16/77] ACPI: bay: send envp with uevent Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 17/77] ACPI: Remove Dell Optiplex GX240 from the ACPI blacklist Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 18/77] ACPI: disable _OSI(Linux) by default Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 19/77] ACPI: Discard invalid elements in _PSS package Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 20/77] ACPI: asus_acpi: Do not load if no device has been found Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 21/77] ACPI: update MAINTAINERS for EC and battery Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 22/77] ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 23/77] ACPI EC: drop usage of ACPI_DEBUG_PRINT as too heavy weight Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 24/77] ACPI EC: Add support for non-AML EC query handlers Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 25/77] ACPI: sbs: probe smart battery vis SMBus controller Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 26/77] ACPI: static Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 27/77] " Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 28/77] ACPI: delete cmdline documentation for deleted hotkey code Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 29/77] ACPI video: Don't export sysfs backlight interface if query _BCL fail Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 30/77] ACPI: Use menuconfig objects Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 32/77] ACPICA: Update _OSI string list Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 33/77] ACPICA: Changes for Cygwin compatibility Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 34/77] ACPICA: Fixed possible corruption of global GPE list Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 35/77] ACPICA: Clear reserved fields for incoming ACPI 1.0 FADTs Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 36/77] ACPI: Export events via generic netlink Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 37/77] ACPI: netlink: remove unnecessary EXPORT_SYMBOL Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 38/77] ACPI: dock: fix oops when _DCK evaluation fails Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 39/77] ACPICA: fix memory leak in acpi_ev_pci_config_region_setup() error path Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 40/77] ACPI: Enable C3 even when PM2_control is zero Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 41/77] ACPI: thinkpad-acpi: add DMI-based modalias Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 42/77] ACPI: thinkpad-acpi: remove all uneeded initializers Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 43/77] ACPI: thinkpad-acpi: update information on T43 thermal sensor 0xc1 Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 44/77] ACPI: thinkpad-acpi: enable more hotkeys Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 45/77] ACPI: thinkpad-acpi: export hotkey maximum masks Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 46/77] ACPI: thinkpad-acpi: export to sysfs the state of the radio slider switch Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 47/77] ACPI: thinkpad-acpi: checkpoint sysfs interface version due to hotkey Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 48/77] ACPI: thinkpad-acpi: update CMOS commands documentation Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 49/77] ACPI: thinkpad-acpi: register input device Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 50/77] ACPI: thinkpad-acpi: add input device support to hotkey subdriver Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 51/77] ACPI: thinkpad-acpi: make the input event mode the default Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 52/77] ACPI: thinkpad-acpi: add power-management handler capability Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 53/77] ACPI: thinkpad-acpi: export EV_SW SW_RADIO events Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 54/77] ACPI: thinkpad-acpi: checkpoint sysfs interface version due to input layer Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 55/77] ACPI: thinkpad-acpi: rename pci HID constant Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 56/77] ACPI: thinkpad_acpi: use bool for boolean parameters Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 57/77] ACPI: thinkpad-acpi: store ThinkPad model information Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 58/77] ACPI: thinkpad-acpi: allow use of CMOS NVRAM for brightness control Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 59/77] ACPI: thinkpad-acpi: react to Lenovo ThinkPad differences in hot key Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 60/77] ACPI: thinkpad-acpi: make sure DSDT TMPx readings don't return +128 Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 61/77] ACPI: thinkpad-acpi: make EC-based thermal readings non-experimental Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 62/77] ACPI: thinkpad-acpi: bump up version to 0.15 Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 63/77] ACPI: thinkpad-acpi: add locking to brightness subdriver Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 64/77] sony-laptop: add new SNC handlers Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 65/77] sony-laptop: map wireless switch events to KEY_WLAN Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 66/77] sony-laptop: Add support for recent Vaios Fn keys (C series for now) Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 67/77] sony-laptop: Invoke _INI for SNC devices that provide it Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 68/77] sony-laptop: Make the driver use MSC_SCAN and a setkeycode and getkeycode key table Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 69/77] sony-laptop: Add Vaio FE to the special init sequence Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 70/77] sony-laptop: Fix event reading in sony-laptop Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 71/77] ACPI: drivers/acpi/pci_link.c: lower printk severity Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 72/77] ACPI: fix empty macros found by -Wextra Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 73/77] ACPI: export ACPI events via acpi_mc_group multicast group Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:14   ` [PATCH 74/77] ACPI: update feature-removal-schedule.txt, /sys/firmware/acpi/namespace is gone Len Brown
2007-07-22  9:14     ` Len Brown
2007-07-22  9:15   ` [PATCH 75/77] ACPI: update ACPI proc I/F removal schedule Len Brown
2007-07-22  9:15     ` Len Brown
2007-07-22  9:15   ` [PATCH 76/77] ACPI: create CONFIG_ACPI_DEBUG_FUNC_TRACE Len Brown
2007-07-22  9:15     ` Len Brown
2007-07-22  9:15   ` [PATCH 77/77] ACPI: Populate /sys/firmware/acpi/tables/ Len Brown
2007-07-22  9:15     ` Len Brown

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=1185095715506-git-send-email-len.brown@intel.com \
    --to=len.brown@intel.com \
    --cc=aystarik@gmail.com \
    --cc=linux-acpi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.