Commit 66e4b72b authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown

ACPI: SBS: Add ACPI_PROCFS around procfs handling code.

Make procfs support optional under ACPI_PROCFS
Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 94f6c086
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#ifdef CONFIG_ACPI_PROCFS
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#endif
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/timer.h> #include <linux/timer.h>
...@@ -86,7 +88,9 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids); ...@@ -86,7 +88,9 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
struct acpi_battery { struct acpi_battery {
struct power_supply bat; struct power_supply bat;
struct acpi_sbs *sbs; struct acpi_sbs *sbs;
#ifdef CONFIG_ACPI_PROCFS
struct proc_dir_entry *proc_entry; struct proc_dir_entry *proc_entry;
#endif
unsigned long update_time; unsigned long update_time;
char name[8]; char name[8];
char manufacturer_name[ACPI_SBS_BLOCK_MAX]; char manufacturer_name[ACPI_SBS_BLOCK_MAX];
...@@ -118,7 +122,9 @@ struct acpi_sbs { ...@@ -118,7 +122,9 @@ struct acpi_sbs {
struct acpi_device *device; struct acpi_device *device;
struct acpi_smb_hc *hc; struct acpi_smb_hc *hc;
struct mutex lock; struct mutex lock;
#ifdef CONFIG_ACPI_PROCFS
struct proc_dir_entry *charger_entry; struct proc_dir_entry *charger_entry;
#endif
struct acpi_battery battery[MAX_SBS_BAT]; struct acpi_battery battery[MAX_SBS_BAT];
u8 batteries_supported:4; u8 batteries_supported:4;
u8 manager_present:1; u8 manager_present:1;
...@@ -380,6 +386,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery) ...@@ -380,6 +386,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
return result; return result;
} }
#ifdef CONFIG_ACPI_PROCFS
static int acpi_battery_get_alarm(struct acpi_battery *battery) static int acpi_battery_get_alarm(struct acpi_battery *battery)
{ {
return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, 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,6 +424,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
return ret; return ret;
} }
#endif
static int acpi_ac_get_present(struct acpi_sbs *sbs) static int acpi_ac_get_present(struct acpi_sbs *sbs)
{ {
int result; int result;
...@@ -432,6 +442,7 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs) ...@@ -432,6 +442,7 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)
FS Interface (/proc/acpi) FS Interface (/proc/acpi)
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_PROCFS
/* Generic Routines */ /* Generic Routines */
static int static int
acpi_sbs_add_fs(struct proc_dir_entry **dir, acpi_sbs_add_fs(struct proc_dir_entry **dir,
...@@ -705,6 +716,8 @@ static struct file_operations acpi_ac_state_fops = { ...@@ -705,6 +716,8 @@ static struct file_operations acpi_ac_state_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#endif
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Driver Interface Driver Interface
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
...@@ -750,10 +763,12 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) ...@@ -750,10 +763,12 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
return result; return result;
sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
#ifdef CONFIG_ACPI_PROCFS
acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir,
battery->name, &acpi_battery_info_fops, battery->name, &acpi_battery_info_fops,
&acpi_battery_state_fops, &acpi_battery_alarm_fops, &acpi_battery_state_fops, &acpi_battery_alarm_fops,
battery); battery);
#endif
battery->bat.name = battery->name; battery->bat.name = battery->name;
battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
if (!acpi_battery_mode(battery)) { if (!acpi_battery_mode(battery)) {
...@@ -777,10 +792,12 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) ...@@ -777,10 +792,12 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
{ {
if (sbs->battery[id].bat.dev) if (sbs->battery[id].bat.dev)
power_supply_unregister(&sbs->battery[id].bat); power_supply_unregister(&sbs->battery[id].bat);
#ifdef CONFIG_ACPI_PROCFS
if (sbs->battery[id].proc_entry) { if (sbs->battery[id].proc_entry) {
acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry),
acpi_battery_dir); acpi_battery_dir);
} }
#endif
} }
static int acpi_charger_add(struct acpi_sbs *sbs) static int acpi_charger_add(struct acpi_sbs *sbs)
...@@ -790,11 +807,13 @@ static int acpi_charger_add(struct acpi_sbs *sbs) ...@@ -790,11 +807,13 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
result = acpi_ac_get_present(sbs); result = acpi_ac_get_present(sbs);
if (result) if (result)
goto end; goto end;
#ifdef CONFIG_ACPI_PROCFS
result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir,
ACPI_AC_DIR_NAME, NULL, ACPI_AC_DIR_NAME, NULL,
&acpi_ac_state_fops, NULL, sbs); &acpi_ac_state_fops, NULL, sbs);
if (result) if (result)
goto end; goto end;
#endif
sbs->charger.name = "sbs-charger"; sbs->charger.name = "sbs-charger";
sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
sbs->charger.properties = sbs_ac_props; sbs->charger.properties = sbs_ac_props;
...@@ -812,8 +831,10 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) ...@@ -812,8 +831,10 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
{ {
if (sbs->charger.dev) if (sbs->charger.dev)
power_supply_unregister(&sbs->charger); power_supply_unregister(&sbs->charger);
#ifdef CONFIG_ACPI_PROCFS
if (sbs->charger_entry) if (sbs->charger_entry)
acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
#endif
} }
void acpi_sbs_callback(void *context) void acpi_sbs_callback(void *context)
...@@ -916,6 +937,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type) ...@@ -916,6 +937,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type)
static void acpi_sbs_rmdirs(void) static void acpi_sbs_rmdirs(void)
{ {
#ifdef CONFIG_ACPI_PROCFS
if (acpi_ac_dir) { if (acpi_ac_dir) {
acpi_unlock_ac_dir(acpi_ac_dir); acpi_unlock_ac_dir(acpi_ac_dir);
acpi_ac_dir = NULL; acpi_ac_dir = NULL;
...@@ -924,6 +946,7 @@ static void acpi_sbs_rmdirs(void) ...@@ -924,6 +946,7 @@ static void acpi_sbs_rmdirs(void)
acpi_unlock_battery_dir(acpi_battery_dir); acpi_unlock_battery_dir(acpi_battery_dir);
acpi_battery_dir = NULL; acpi_battery_dir = NULL;
} }
#endif
} }
static int acpi_sbs_resume(struct acpi_device *device) static int acpi_sbs_resume(struct acpi_device *device)
...@@ -953,6 +976,7 @@ static int __init acpi_sbs_init(void) ...@@ -953,6 +976,7 @@ static int __init acpi_sbs_init(void)
if (acpi_disabled) if (acpi_disabled)
return -ENODEV; return -ENODEV;
#ifdef CONFIG_ACPI_PROCFS
acpi_ac_dir = acpi_lock_ac_dir(); acpi_ac_dir = acpi_lock_ac_dir();
if (!acpi_ac_dir) if (!acpi_ac_dir)
return -ENODEV; return -ENODEV;
...@@ -961,6 +985,7 @@ static int __init acpi_sbs_init(void) ...@@ -961,6 +985,7 @@ static int __init acpi_sbs_init(void)
acpi_sbs_rmdirs(); acpi_sbs_rmdirs();
return -ENODEV; return -ENODEV;
} }
#endif
result = acpi_bus_register_driver(&acpi_sbs_driver); result = acpi_bus_register_driver(&acpi_sbs_driver);
if (result < 0) { if (result < 0) {
acpi_sbs_rmdirs(); acpi_sbs_rmdirs();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment