aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Starikovskiy <astarikovskiy@suse.de>2007-09-26 11:43:54 -0400
committerLen Brown <len.brown@intel.com>2007-09-27 15:50:23 -0400
commit66e4b72bfa7347fd1017b9b82dce77a410f2e4a1 (patch)
tree1fb3acc97cf51277137d21333ac0f1eb8e132940
parent94f6c0860139da9219255b8ff45ad42117dda859 (diff)
ACPI: SBS: Add ACPI_PROCFS around procfs handling code.
Make procfs support optional under ACPI_PROCFS Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/sbs.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index c4f9641147c4..aae65e8f70f3 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -29,9 +29,11 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31 31
32#ifdef CONFIG_ACPI_PROCFS
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 34#include <linux/seq_file.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
36#endif
35 37
36#include <linux/acpi.h> 38#include <linux/acpi.h>
37#include <linux/timer.h> 39#include <linux/timer.h>
@@ -86,7 +88,9 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
86struct acpi_battery { 88struct acpi_battery {
87 struct power_supply bat; 89 struct power_supply bat;
88 struct acpi_sbs *sbs; 90 struct acpi_sbs *sbs;
91#ifdef CONFIG_ACPI_PROCFS
89 struct proc_dir_entry *proc_entry; 92 struct proc_dir_entry *proc_entry;
93#endif
90 unsigned long update_time; 94 unsigned long update_time;
91 char name[8]; 95 char name[8];
92 char manufacturer_name[ACPI_SBS_BLOCK_MAX]; 96 char manufacturer_name[ACPI_SBS_BLOCK_MAX];
@@ -118,7 +122,9 @@ struct acpi_sbs {
118 struct acpi_device *device; 122 struct acpi_device *device;
119 struct acpi_smb_hc *hc; 123 struct acpi_smb_hc *hc;
120 struct mutex lock; 124 struct mutex lock;
125#ifdef CONFIG_ACPI_PROCFS
121 struct proc_dir_entry *charger_entry; 126 struct proc_dir_entry *charger_entry;
127#endif
122 struct acpi_battery battery[MAX_SBS_BAT]; 128 struct acpi_battery battery[MAX_SBS_BAT];
123 u8 batteries_supported:4; 129 u8 batteries_supported:4;
124 u8 manager_present:1; 130 u8 manager_present:1;
@@ -380,6 +386,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
380 return result; 386 return result;
381} 387}
382 388
389#ifdef CONFIG_ACPI_PROCFS
390
383static int acpi_battery_get_alarm(struct acpi_battery *battery) 391static int acpi_battery_get_alarm(struct acpi_battery *battery)
384{ 392{
385 return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, 393 return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD,
@@ -416,6 +424,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
416 return ret; 424 return ret;
417} 425}
418 426
427#endif
428
419static int acpi_ac_get_present(struct acpi_sbs *sbs) 429static int acpi_ac_get_present(struct acpi_sbs *sbs)
420{ 430{
421 int result; 431 int result;
@@ -432,6 +442,7 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)
432 FS Interface (/proc/acpi) 442 FS Interface (/proc/acpi)
433 -------------------------------------------------------------------------- */ 443 -------------------------------------------------------------------------- */
434 444
445#ifdef CONFIG_ACPI_PROCFS
435/* Generic Routines */ 446/* Generic Routines */
436static int 447static int
437acpi_sbs_add_fs(struct proc_dir_entry **dir, 448acpi_sbs_add_fs(struct proc_dir_entry **dir,
@@ -705,6 +716,8 @@ static struct file_operations acpi_ac_state_fops = {
705 .owner = THIS_MODULE, 716 .owner = THIS_MODULE,
706}; 717};
707 718
719#endif
720
708/* -------------------------------------------------------------------------- 721/* --------------------------------------------------------------------------
709 Driver Interface 722 Driver Interface
710 -------------------------------------------------------------------------- */ 723 -------------------------------------------------------------------------- */
@@ -750,10 +763,12 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
750 return result; 763 return result;
751 764
752 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); 765 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
766#ifdef CONFIG_ACPI_PROCFS
753 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, 767 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir,
754 battery->name, &acpi_battery_info_fops, 768 battery->name, &acpi_battery_info_fops,
755 &acpi_battery_state_fops, &acpi_battery_alarm_fops, 769 &acpi_battery_state_fops, &acpi_battery_alarm_fops,
756 battery); 770 battery);
771#endif
757 battery->bat.name = battery->name; 772 battery->bat.name = battery->name;
758 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; 773 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
759 if (!acpi_battery_mode(battery)) { 774 if (!acpi_battery_mode(battery)) {
@@ -777,10 +792,12 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
777{ 792{
778 if (sbs->battery[id].bat.dev) 793 if (sbs->battery[id].bat.dev)
779 power_supply_unregister(&sbs->battery[id].bat); 794 power_supply_unregister(&sbs->battery[id].bat);
795#ifdef CONFIG_ACPI_PROCFS
780 if (sbs->battery[id].proc_entry) { 796 if (sbs->battery[id].proc_entry) {
781 acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), 797 acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry),
782 acpi_battery_dir); 798 acpi_battery_dir);
783 } 799 }
800#endif
784} 801}
785 802
786static int acpi_charger_add(struct acpi_sbs *sbs) 803static int acpi_charger_add(struct acpi_sbs *sbs)
@@ -790,11 +807,13 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
790 result = acpi_ac_get_present(sbs); 807 result = acpi_ac_get_present(sbs);
791 if (result) 808 if (result)
792 goto end; 809 goto end;
810#ifdef CONFIG_ACPI_PROCFS
793 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, 811 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir,
794 ACPI_AC_DIR_NAME, NULL, 812 ACPI_AC_DIR_NAME, NULL,
795 &acpi_ac_state_fops, NULL, sbs); 813 &acpi_ac_state_fops, NULL, sbs);
796 if (result) 814 if (result)
797 goto end; 815 goto end;
816#endif
798 sbs->charger.name = "sbs-charger"; 817 sbs->charger.name = "sbs-charger";
799 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; 818 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
800 sbs->charger.properties = sbs_ac_props; 819 sbs->charger.properties = sbs_ac_props;
@@ -812,8 +831,10 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
812{ 831{
813 if (sbs->charger.dev) 832 if (sbs->charger.dev)
814 power_supply_unregister(&sbs->charger); 833 power_supply_unregister(&sbs->charger);
834#ifdef CONFIG_ACPI_PROCFS
815 if (sbs->charger_entry) 835 if (sbs->charger_entry)
816 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); 836 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
837#endif
817} 838}
818 839
819void acpi_sbs_callback(void *context) 840void acpi_sbs_callback(void *context)
@@ -916,6 +937,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type)
916 937
917static void acpi_sbs_rmdirs(void) 938static void acpi_sbs_rmdirs(void)
918{ 939{
940#ifdef CONFIG_ACPI_PROCFS
919 if (acpi_ac_dir) { 941 if (acpi_ac_dir) {
920 acpi_unlock_ac_dir(acpi_ac_dir); 942 acpi_unlock_ac_dir(acpi_ac_dir);
921 acpi_ac_dir = NULL; 943 acpi_ac_dir = NULL;
@@ -924,6 +946,7 @@ static void acpi_sbs_rmdirs(void)
924 acpi_unlock_battery_dir(acpi_battery_dir); 946 acpi_unlock_battery_dir(acpi_battery_dir);
925 acpi_battery_dir = NULL; 947 acpi_battery_dir = NULL;
926 } 948 }
949#endif
927} 950}
928 951
929static int acpi_sbs_resume(struct acpi_device *device) 952static int acpi_sbs_resume(struct acpi_device *device)
@@ -953,6 +976,7 @@ static int __init acpi_sbs_init(void)
953 976
954 if (acpi_disabled) 977 if (acpi_disabled)
955 return -ENODEV; 978 return -ENODEV;
979#ifdef CONFIG_ACPI_PROCFS
956 acpi_ac_dir = acpi_lock_ac_dir(); 980 acpi_ac_dir = acpi_lock_ac_dir();
957 if (!acpi_ac_dir) 981 if (!acpi_ac_dir)
958 return -ENODEV; 982 return -ENODEV;
@@ -961,6 +985,7 @@ static int __init acpi_sbs_init(void)
961 acpi_sbs_rmdirs(); 985 acpi_sbs_rmdirs();
962 return -ENODEV; 986 return -ENODEV;
963 } 987 }
988#endif
964 result = acpi_bus_register_driver(&acpi_sbs_driver); 989 result = acpi_bus_register_driver(&acpi_sbs_driver);
965 if (result < 0) { 990 if (result < 0) {
966 acpi_sbs_rmdirs(); 991 acpi_sbs_rmdirs();