aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLan Tianyu <tianyu.lan@intel.com>2013-10-10 21:54:09 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-11 18:19:44 -0400
commit2a68b995c8d5d36de50fd2a7c9c594d986f04c87 (patch)
tree2883833f8bbcc33e1a5e855d106c2a1371cbb820 /drivers
parent1e2d9cdfb4494fce682b4ae010d86a2766816d36 (diff)
ACPI / SBS: Remove SBS's proc directory
SBS's proc directory isn't useded and so remove it. Prepare for removing /proc/acpi directory. Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/sbs.c325
1 files changed, 4 insertions, 321 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index aef7e1cd1e5d..d465ae6cdd00 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -30,12 +30,6 @@
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32 32
33#ifdef CONFIG_ACPI_PROCFS_POWER
34#include <linux/proc_fs.h>
35#include <linux/seq_file.h>
36#include <asm/uaccess.h>
37#endif
38
39#include <linux/acpi.h> 33#include <linux/acpi.h>
40#include <linux/timer.h> 34#include <linux/timer.h>
41#include <linux/jiffies.h> 35#include <linux/jiffies.h>
@@ -67,11 +61,6 @@ static unsigned int cache_time = 1000;
67module_param(cache_time, uint, 0644); 61module_param(cache_time, uint, 0644);
68MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 62MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
69 63
70extern struct proc_dir_entry *acpi_lock_ac_dir(void);
71extern struct proc_dir_entry *acpi_lock_battery_dir(void);
72extern void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
73extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
74
75#define MAX_SBS_BAT 4 64#define MAX_SBS_BAT 4
76#define ACPI_SBS_BLOCK_MAX 32 65#define ACPI_SBS_BLOCK_MAX 32
77 66
@@ -84,9 +73,6 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
84struct acpi_battery { 73struct acpi_battery {
85 struct power_supply bat; 74 struct power_supply bat;
86 struct acpi_sbs *sbs; 75 struct acpi_sbs *sbs;
87#ifdef CONFIG_ACPI_PROCFS_POWER
88 struct proc_dir_entry *proc_entry;
89#endif
90 unsigned long update_time; 76 unsigned long update_time;
91 char name[8]; 77 char name[8];
92 char manufacturer_name[ACPI_SBS_BLOCK_MAX]; 78 char manufacturer_name[ACPI_SBS_BLOCK_MAX];
@@ -119,9 +105,6 @@ struct acpi_sbs {
119 struct acpi_device *device; 105 struct acpi_device *device;
120 struct acpi_smb_hc *hc; 106 struct acpi_smb_hc *hc;
121 struct mutex lock; 107 struct mutex lock;
122#ifdef CONFIG_ACPI_PROCFS_POWER
123 struct proc_dir_entry *charger_entry;
124#endif
125 struct acpi_battery battery[MAX_SBS_BAT]; 108 struct acpi_battery battery[MAX_SBS_BAT];
126 u8 batteries_supported:4; 109 u8 batteries_supported:4;
127 u8 manager_present:1; 110 u8 manager_present:1;
@@ -482,261 +465,6 @@ static struct device_attribute alarm_attr = {
482}; 465};
483 466
484/* -------------------------------------------------------------------------- 467/* --------------------------------------------------------------------------
485 FS Interface (/proc/acpi)
486 -------------------------------------------------------------------------- */
487
488#ifdef CONFIG_ACPI_PROCFS_POWER
489/* Generic Routines */
490static int
491acpi_sbs_add_fs(struct proc_dir_entry **dir,
492 struct proc_dir_entry *parent_dir,
493 char *dir_name,
494 const struct file_operations *info_fops,
495 const struct file_operations *state_fops,
496 const struct file_operations *alarm_fops, void *data)
497{
498 printk(KERN_WARNING PREFIX "Deprecated procfs I/F for SBS is loaded,"
499 " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
500 if (!*dir) {
501 *dir = proc_mkdir(dir_name, parent_dir);
502 if (!*dir) {
503 return -ENODEV;
504 }
505 }
506
507 /* 'info' [R] */
508 if (info_fops)
509 proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir,
510 info_fops, data);
511
512 /* 'state' [R] */
513 if (state_fops)
514 proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir,
515 state_fops, data);
516
517 /* 'alarm' [R/W] */
518 if (alarm_fops)
519 proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir,
520 alarm_fops, data);
521 return 0;
522}
523
524/* Smart Battery Interface */
525static struct proc_dir_entry *acpi_battery_dir = NULL;
526
527static inline char *acpi_battery_units(struct acpi_battery *battery)
528{
529 return acpi_battery_mode(battery) ? " mW" : " mA";
530}
531
532
533static int acpi_battery_read_info(struct seq_file *seq, void *offset)
534{
535 struct acpi_battery *battery = seq->private;
536 struct acpi_sbs *sbs = battery->sbs;
537 int result = 0;
538
539 mutex_lock(&sbs->lock);
540
541 seq_printf(seq, "present: %s\n",
542 (battery->present) ? "yes" : "no");
543 if (!battery->present)
544 goto end;
545
546 seq_printf(seq, "design capacity: %i%sh\n",
547 battery->design_capacity * acpi_battery_scale(battery),
548 acpi_battery_units(battery));
549 seq_printf(seq, "last full capacity: %i%sh\n",
550 battery->full_charge_capacity * acpi_battery_scale(battery),
551 acpi_battery_units(battery));
552 seq_printf(seq, "battery technology: rechargeable\n");
553 seq_printf(seq, "design voltage: %i mV\n",
554 battery->design_voltage * acpi_battery_vscale(battery));
555 seq_printf(seq, "design capacity warning: unknown\n");
556 seq_printf(seq, "design capacity low: unknown\n");
557 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
558 seq_printf(seq, "capacity granularity 1: unknown\n");
559 seq_printf(seq, "capacity granularity 2: unknown\n");
560 seq_printf(seq, "model number: %s\n", battery->device_name);
561 seq_printf(seq, "serial number: %i\n",
562 battery->serial_number);
563 seq_printf(seq, "battery type: %s\n",
564 battery->device_chemistry);
565 seq_printf(seq, "OEM info: %s\n",
566 battery->manufacturer_name);
567 end:
568 mutex_unlock(&sbs->lock);
569 return result;
570}
571
572static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
573{
574 return single_open(file, acpi_battery_read_info, PDE_DATA(inode));
575}
576
577static int acpi_battery_read_state(struct seq_file *seq, void *offset)
578{
579 struct acpi_battery *battery = seq->private;
580 struct acpi_sbs *sbs = battery->sbs;
581 int rate;
582
583 mutex_lock(&sbs->lock);
584 seq_printf(seq, "present: %s\n",
585 (battery->present) ? "yes" : "no");
586 if (!battery->present)
587 goto end;
588
589 acpi_battery_get_state(battery);
590 seq_printf(seq, "capacity state: %s\n",
591 (battery->state & 0x0010) ? "critical" : "ok");
592 seq_printf(seq, "charging state: %s\n",
593 (battery->rate_now < 0) ? "discharging" :
594 ((battery->rate_now > 0) ? "charging" : "charged"));
595 rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
596 rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
597 acpi_battery_vscale(battery)/1000):1;
598 seq_printf(seq, "present rate: %d%s\n", rate,
599 acpi_battery_units(battery));
600 seq_printf(seq, "remaining capacity: %i%sh\n",
601 battery->capacity_now * acpi_battery_scale(battery),
602 acpi_battery_units(battery));
603 seq_printf(seq, "present voltage: %i mV\n",
604 battery->voltage_now * acpi_battery_vscale(battery));
605
606 end:
607 mutex_unlock(&sbs->lock);
608 return 0;
609}
610
611static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
612{
613 return single_open(file, acpi_battery_read_state, PDE_DATA(inode));
614}
615
616static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
617{
618 struct acpi_battery *battery = seq->private;
619 struct acpi_sbs *sbs = battery->sbs;
620 int result = 0;
621
622 mutex_lock(&sbs->lock);
623
624 if (!battery->present) {
625 seq_printf(seq, "present: no\n");
626 goto end;
627 }
628
629 acpi_battery_get_alarm(battery);
630 seq_printf(seq, "alarm: ");
631 if (battery->alarm_capacity)
632 seq_printf(seq, "%i%sh\n",
633 battery->alarm_capacity *
634 acpi_battery_scale(battery),
635 acpi_battery_units(battery));
636 else
637 seq_printf(seq, "disabled\n");
638 end:
639 mutex_unlock(&sbs->lock);
640 return result;
641}
642
643static ssize_t
644acpi_battery_write_alarm(struct file *file, const char __user * buffer,
645 size_t count, loff_t * ppos)
646{
647 struct seq_file *seq = file->private_data;
648 struct acpi_battery *battery = seq->private;
649 struct acpi_sbs *sbs = battery->sbs;
650 char alarm_string[12] = { '\0' };
651 int result = 0;
652 mutex_lock(&sbs->lock);
653 if (!battery->present) {
654 result = -ENODEV;
655 goto end;
656 }
657 if (count > sizeof(alarm_string) - 1) {
658 result = -EINVAL;
659 goto end;
660 }
661 if (copy_from_user(alarm_string, buffer, count)) {
662 result = -EFAULT;
663 goto end;
664 }
665 alarm_string[count] = 0;
666 battery->alarm_capacity = simple_strtoul(alarm_string, NULL, 0) /
667 acpi_battery_scale(battery);
668 acpi_battery_set_alarm(battery);
669 end:
670 mutex_unlock(&sbs->lock);
671 if (result)
672 return result;
673 return count;
674}
675
676static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
677{
678 return single_open(file, acpi_battery_read_alarm, PDE_DATA(inode));
679}
680
681static const struct file_operations acpi_battery_info_fops = {
682 .open = acpi_battery_info_open_fs,
683 .read = seq_read,
684 .llseek = seq_lseek,
685 .release = single_release,
686 .owner = THIS_MODULE,
687};
688
689static const struct file_operations acpi_battery_state_fops = {
690 .open = acpi_battery_state_open_fs,
691 .read = seq_read,
692 .llseek = seq_lseek,
693 .release = single_release,
694 .owner = THIS_MODULE,
695};
696
697static const struct file_operations acpi_battery_alarm_fops = {
698 .open = acpi_battery_alarm_open_fs,
699 .read = seq_read,
700 .write = acpi_battery_write_alarm,
701 .llseek = seq_lseek,
702 .release = single_release,
703 .owner = THIS_MODULE,
704};
705
706/* Legacy AC Adapter Interface */
707
708static struct proc_dir_entry *acpi_ac_dir = NULL;
709
710static int acpi_ac_read_state(struct seq_file *seq, void *offset)
711{
712
713 struct acpi_sbs *sbs = seq->private;
714
715 mutex_lock(&sbs->lock);
716
717 seq_printf(seq, "state: %s\n",
718 sbs->charger_present ? "on-line" : "off-line");
719
720 mutex_unlock(&sbs->lock);
721 return 0;
722}
723
724static int acpi_ac_state_open_fs(struct inode *inode, struct file *file)
725{
726 return single_open(file, acpi_ac_read_state, PDE_DATA(inode));
727}
728
729static const struct file_operations acpi_ac_state_fops = {
730 .open = acpi_ac_state_open_fs,
731 .read = seq_read,
732 .llseek = seq_lseek,
733 .release = single_release,
734 .owner = THIS_MODULE,
735};
736
737#endif
738
739/* --------------------------------------------------------------------------
740 Driver Interface 468 Driver Interface
741 -------------------------------------------------------------------------- */ 469 -------------------------------------------------------------------------- */
742static int acpi_battery_read(struct acpi_battery *battery) 470static int acpi_battery_read(struct acpi_battery *battery)
@@ -781,12 +509,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
781 return result; 509 return result;
782 510
783 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); 511 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
784#ifdef CONFIG_ACPI_PROCFS_POWER
785 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir,
786 battery->name, &acpi_battery_info_fops,
787 &acpi_battery_state_fops, &acpi_battery_alarm_fops,
788 battery);
789#endif
790 battery->bat.name = battery->name; 512 battery->bat.name = battery->name;
791 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; 513 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
792 if (!acpi_battery_mode(battery)) { 514 if (!acpi_battery_mode(battery)) {
@@ -822,10 +544,6 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
822 device_remove_file(battery->bat.dev, &alarm_attr); 544 device_remove_file(battery->bat.dev, &alarm_attr);
823 power_supply_unregister(&battery->bat); 545 power_supply_unregister(&battery->bat);
824 } 546 }
825#ifdef CONFIG_ACPI_PROCFS_POWER
826 proc_remove(battery->proc_entry);
827 battery->proc_entry = NULL;
828#endif
829} 547}
830 548
831static int acpi_charger_add(struct acpi_sbs *sbs) 549static int acpi_charger_add(struct acpi_sbs *sbs)
@@ -835,13 +553,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
835 result = acpi_ac_get_present(sbs); 553 result = acpi_ac_get_present(sbs);
836 if (result) 554 if (result)
837 goto end; 555 goto end;
838#ifdef CONFIG_ACPI_PROCFS_POWER 556
839 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir,
840 ACPI_AC_DIR_NAME, NULL,
841 &acpi_ac_state_fops, NULL, sbs);
842 if (result)
843 goto end;
844#endif
845 sbs->charger.name = "sbs-charger"; 557 sbs->charger.name = "sbs-charger";
846 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; 558 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
847 sbs->charger.properties = sbs_ac_props; 559 sbs->charger.properties = sbs_ac_props;
@@ -859,10 +571,6 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
859{ 571{
860 if (sbs->charger.dev) 572 if (sbs->charger.dev)
861 power_supply_unregister(&sbs->charger); 573 power_supply_unregister(&sbs->charger);
862#ifdef CONFIG_ACPI_PROCFS_POWER
863 proc_remove(sbs->charger_entry);
864 sbs->charger_entry = NULL;
865#endif
866} 574}
867 575
868static void acpi_sbs_callback(void *context) 576static void acpi_sbs_callback(void *context)
@@ -950,20 +658,6 @@ static int acpi_sbs_remove(struct acpi_device *device)
950 return 0; 658 return 0;
951} 659}
952 660
953static void acpi_sbs_rmdirs(void)
954{
955#ifdef CONFIG_ACPI_PROCFS_POWER
956 if (acpi_ac_dir) {
957 acpi_unlock_ac_dir(acpi_ac_dir);
958 acpi_ac_dir = NULL;
959 }
960 if (acpi_battery_dir) {
961 acpi_unlock_battery_dir(acpi_battery_dir);
962 acpi_battery_dir = NULL;
963 }
964#endif
965}
966
967#ifdef CONFIG_PM_SLEEP 661#ifdef CONFIG_PM_SLEEP
968static int acpi_sbs_resume(struct device *dev) 662static int acpi_sbs_resume(struct device *dev)
969{ 663{
@@ -995,28 +689,17 @@ static int __init acpi_sbs_init(void)
995 689
996 if (acpi_disabled) 690 if (acpi_disabled)
997 return -ENODEV; 691 return -ENODEV;
998#ifdef CONFIG_ACPI_PROCFS_POWER 692
999 acpi_ac_dir = acpi_lock_ac_dir();
1000 if (!acpi_ac_dir)
1001 return -ENODEV;
1002 acpi_battery_dir = acpi_lock_battery_dir();
1003 if (!acpi_battery_dir) {
1004 acpi_sbs_rmdirs();
1005 return -ENODEV;
1006 }
1007#endif
1008 result = acpi_bus_register_driver(&acpi_sbs_driver); 693 result = acpi_bus_register_driver(&acpi_sbs_driver);
1009 if (result < 0) { 694 if (result < 0)
1010 acpi_sbs_rmdirs();
1011 return -ENODEV; 695 return -ENODEV;
1012 } 696
1013 return 0; 697 return 0;
1014} 698}
1015 699
1016static void __exit acpi_sbs_exit(void) 700static void __exit acpi_sbs_exit(void)
1017{ 701{
1018 acpi_bus_unregister_driver(&acpi_sbs_driver); 702 acpi_bus_unregister_driver(&acpi_sbs_driver);
1019 acpi_sbs_rmdirs();
1020 return; 703 return;
1021} 704}
1022 705