patch-2.4.10 linux/drivers/acpi/ospm/battery/bt_osl.c

Next file: linux/drivers/acpi/ospm/busmgr/Makefile
Previous file: linux/drivers/acpi/ospm/battery/bt.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/battery/bt_osl.c linux/drivers/acpi/ospm/battery/bt_osl.c
@@ -1,7 +1,7 @@
 /******************************************************************************
  *
  * Module Name: bt_osl.c
- *   $Revision: 18 $
+ *   $Revision: 22 $
  *
  *****************************************************************************/
 
@@ -44,6 +44,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Control Method Battery Driver");
+MODULE_LICENSE("GPL");
 
 
 #define BT_PROC_ROOT		"battery"
@@ -55,18 +56,18 @@
 
 
 /****************************************************************************
- * 
+ *
  * FUNCTION:	bt_osl_proc_read_info
  *
  ****************************************************************************/
 
 static int
 bt_osl_proc_read_info (
-	char			*page, 
-	char			**start, 
-	off_t			off, 
-	int 			count, 
-	int 			*eof, 
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
 	void			*context)
 {
 	BT_CONTEXT		*battery = NULL;
@@ -105,17 +106,17 @@
 		p += sprintf(p, "Design Capacity:         unknown\n");
 	}
 	else {
-		p += sprintf(p, "Design Capacity:         %d %sh\n", 
-			 battery_info->design_capacity, 
+		p += sprintf(p, "Design Capacity:         %d %sh\n",
+			 battery_info->design_capacity,
 			 battery->power_units);
 	}
 	
 	if (battery_info->last_full_capacity == BT_UNKNOWN) {
 		p += sprintf(p, "Last Full Capacity:      unknown\n");
-	} 
+	}
 	else {
-		p += sprintf(p, "Last Full Capacity:      %d %sh\n", 
-			 battery_info->last_full_capacity, 
+		p += sprintf(p, "Last Full Capacity:      %d %sh\n",
+			 battery_info->last_full_capacity,
 			 battery->power_units);
 	}
 
@@ -133,29 +134,29 @@
 		p += sprintf(p, "Design Voltage:          unknown\n");
 	}
 	else {
-		p += sprintf(p, "Design Voltage:          %d mV\n", 
+		p += sprintf(p, "Design Voltage:          %d mV\n",
 			 battery_info->design_voltage);
 	}
 	
 	p += sprintf(p, "Design Capacity Warning: %d %sh\n",
-		battery_info->design_capacity_warning, 
+		battery_info->design_capacity_warning,
 		battery->power_units);
 	p += sprintf(p, "Design Capacity Low:     %d %sh\n",
-		battery_info->design_capacity_low, 
+		battery_info->design_capacity_low,
 		battery->power_units);
 	p += sprintf(p, "Capacity Granularity 1:  %d %sh\n",
-		battery_info->battery_capacity_granularity_1, 
+		battery_info->battery_capacity_granularity_1,
 		battery->power_units);
 	p += sprintf(p, "Capacity Granularity 2:  %d %sh\n",
-		battery_info->battery_capacity_granularity_2, 
+		battery_info->battery_capacity_granularity_2,
 		battery->power_units);
-	p += sprintf(p, "Model Number:            %s\n", 
+	p += sprintf(p, "Model Number:            %s\n",
 		battery_info->model_number);
-	p += sprintf(p, "Serial Number:           %s\n", 
+	p += sprintf(p, "Serial Number:           %s\n",
 		battery_info->serial_number);
-	p += sprintf(p, "Battery Type:            %s\n", 
+	p += sprintf(p, "Battery Type:            %s\n",
 		battery_info->battery_type);
-	p += sprintf(p, "OEM Info:                %s\n", 
+	p += sprintf(p, "OEM Info:                %s\n",
 		battery_info->oem_info);
 	
 end:
@@ -173,18 +174,18 @@
 
 
 /****************************************************************************
- * 
+ *
  * FUNCTION:	bt_osl_proc_read_status
  *
  ****************************************************************************/
 
 static int
 bt_osl_proc_read_status (
-	char			*page, 
-	char			**start, 
-	off_t			off, 
-	int 			count, 
-	int 			*eof, 
+	char			*page,
+	char			**start,
+	off_t			off,
+	int 			count,
+	int 			*eof,
 	void			*context)
 {
 	BT_CONTEXT		*battery = NULL;
@@ -225,7 +226,7 @@
 	 */
 
 	if (!battery_status->state) {
-		p += sprintf(p, "State:                   ok\n"); 
+		p += sprintf(p, "State:                   ok\n");
 	}
 	else {
 		if (battery_status->state & 0x1)
@@ -241,7 +242,7 @@
 	}
 	else {
 		p += sprintf(p, "Present Rate:            %d %s\n",
-			battery_status->present_rate, 
+			battery_status->present_rate,
 			battery->power_units);
 	}
 
@@ -250,7 +251,7 @@
 	}
 	else {
 		p += sprintf(p, "Remaining Capacity:      %d %sh\n",
-			battery_status->remaining_capacity, 
+			battery_status->remaining_capacity,
 			battery->power_units);
 	}
 
@@ -282,7 +283,7 @@
  *
  ****************************************************************************/
 
-ACPI_STATUS
+acpi_status
 bt_osl_add_device(
 	BT_CONTEXT		*battery)
 {
@@ -304,10 +305,10 @@
 		return(AE_ERROR);
 	}
 
-	create_proc_read_entry(BT_PROC_STATUS, S_IFREG | S_IRUGO, 
+	create_proc_read_entry(BT_PROC_STATUS, S_IFREG | S_IRUGO,
 		proc_entry, bt_osl_proc_read_status, (void*)battery);
 
-	create_proc_read_entry(BT_PROC_INFO, S_IFREG | S_IRUGO, 
+	create_proc_read_entry(BT_PROC_INFO, S_IFREG | S_IRUGO,
 		proc_entry, bt_osl_proc_read_info, (void*)battery);
 
 	return(AE_OK);
@@ -320,7 +321,7 @@
  *
  ****************************************************************************/
 
-ACPI_STATUS
+acpi_status
 bt_osl_remove_device (
 	BT_CONTEXT		*battery)
 {
@@ -349,12 +350,12 @@
  *
  ****************************************************************************/
 
-ACPI_STATUS
+acpi_status
 bt_osl_generate_event (
 	u32			event,
 	BT_CONTEXT		*battery)
 {
-	ACPI_STATUS		status = AE_OK;
+	acpi_status		status = AE_OK;
 
 	if (!battery) {
 		return(AE_BAD_PARAMETER);
@@ -364,7 +365,7 @@
 
 	case BT_NOTIFY_STATUS_CHANGE:
 	case BT_NOTIFY_INFORMATION_CHANGE:
-		status = bm_osl_generate_event(battery->device_handle, 
+		status = bm_osl_generate_event(battery->device_handle,
 			BT_PROC_ROOT, battery->uid, event, 0);
 		break;
 
@@ -389,10 +390,14 @@
  *
  ****************************************************************************/
 
-static int __init 
+static int __init
 bt_osl_init (void)
 {
-	ACPI_STATUS		status = AE_OK;
+	acpi_status		status = AE_OK;
+
+	/* abort if no busmgr */
+	if (!bm_proc_root)
+		return -ENODEV;
 
 	bt_proc_root = proc_mkdir(BT_PROC_ROOT, bm_proc_root);
 	if (!bt_proc_root) {
@@ -421,7 +426,7 @@
  *
  ****************************************************************************/
 
-static void __exit 
+static void __exit
 bt_osl_cleanup (void)
 {
 	bt_terminate();

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)