diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-12-15 18:51:12 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-15 23:58:00 -0500 |
commit | 887965e6576a78f71b9b98dec43fd1c73becd2e8 (patch) | |
tree | a39b687c964f2f79d45dd1f50554d3364ffb8b4f | |
parent | 0d204c34e85d1d63e5fdd3e3192747daf0ee7ec1 (diff) |
thinkpad-acpi: convert to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 285 |
1 files changed, 132 insertions, 153 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index e0fbe73b8dff..c21c35e2dcc6 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -61,6 +61,7 @@ | |||
61 | 61 | ||
62 | #include <linux/nvram.h> | 62 | #include <linux/nvram.h> |
63 | #include <linux/proc_fs.h> | 63 | #include <linux/proc_fs.h> |
64 | #include <linux/seq_file.h> | ||
64 | #include <linux/sysfs.h> | 65 | #include <linux/sysfs.h> |
65 | #include <linux/backlight.h> | 66 | #include <linux/backlight.h> |
66 | #include <linux/fb.h> | 67 | #include <linux/fb.h> |
@@ -261,7 +262,7 @@ struct tp_acpi_drv_struct { | |||
261 | struct ibm_struct { | 262 | struct ibm_struct { |
262 | char *name; | 263 | char *name; |
263 | 264 | ||
264 | int (*read) (char *); | 265 | int (*read) (struct seq_file *); |
265 | int (*write) (char *); | 266 | int (*write) (char *); |
266 | void (*exit) (void); | 267 | void (*exit) (void); |
267 | void (*resume) (void); | 268 | void (*resume) (void); |
@@ -789,36 +790,25 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm) | |||
789 | **************************************************************************** | 790 | **************************************************************************** |
790 | ****************************************************************************/ | 791 | ****************************************************************************/ |
791 | 792 | ||
792 | static int dispatch_procfs_read(char *page, char **start, off_t off, | 793 | static int dispatch_proc_show(struct seq_file *m, void *v) |
793 | int count, int *eof, void *data) | ||
794 | { | 794 | { |
795 | struct ibm_struct *ibm = data; | 795 | struct ibm_struct *ibm = m->private; |
796 | int len; | ||
797 | 796 | ||
798 | if (!ibm || !ibm->read) | 797 | if (!ibm || !ibm->read) |
799 | return -EINVAL; | 798 | return -EINVAL; |
799 | return ibm->read(m); | ||
800 | } | ||
800 | 801 | ||
801 | len = ibm->read(page); | 802 | static int dispatch_proc_open(struct inode *inode, struct file *file) |
802 | if (len < 0) | 803 | { |
803 | return len; | 804 | return single_open(file, dispatch_proc_show, PDE(inode)->data); |
804 | |||
805 | if (len <= off + count) | ||
806 | *eof = 1; | ||
807 | *start = page + off; | ||
808 | len -= off; | ||
809 | if (len > count) | ||
810 | len = count; | ||
811 | if (len < 0) | ||
812 | len = 0; | ||
813 | |||
814 | return len; | ||
815 | } | 805 | } |
816 | 806 | ||
817 | static int dispatch_procfs_write(struct file *file, | 807 | static ssize_t dispatch_proc_write(struct file *file, |
818 | const char __user *userbuf, | 808 | const char __user *userbuf, |
819 | unsigned long count, void *data) | 809 | size_t count, loff_t *pos) |
820 | { | 810 | { |
821 | struct ibm_struct *ibm = data; | 811 | struct ibm_struct *ibm = PDE(file->f_path.dentry->d_inode)->data; |
822 | char *kernbuf; | 812 | char *kernbuf; |
823 | int ret; | 813 | int ret; |
824 | 814 | ||
@@ -847,6 +837,15 @@ static int dispatch_procfs_write(struct file *file, | |||
847 | return ret; | 837 | return ret; |
848 | } | 838 | } |
849 | 839 | ||
840 | static const struct file_operations dispatch_proc_fops = { | ||
841 | .owner = THIS_MODULE, | ||
842 | .open = dispatch_proc_open, | ||
843 | .read = seq_read, | ||
844 | .llseek = seq_lseek, | ||
845 | .release = single_release, | ||
846 | .write = dispatch_proc_write, | ||
847 | }; | ||
848 | |||
850 | static char *next_cmd(char **cmds) | 849 | static char *next_cmd(char **cmds) |
851 | { | 850 | { |
852 | char *start = *cmds; | 851 | char *start = *cmds; |
@@ -1401,12 +1400,10 @@ static ssize_t tpacpi_rfk_sysfs_enable_store(const enum tpacpi_rfk_id id, | |||
1401 | } | 1400 | } |
1402 | 1401 | ||
1403 | /* procfs -------------------------------------------------------------- */ | 1402 | /* procfs -------------------------------------------------------------- */ |
1404 | static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, char *p) | 1403 | static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, struct seq_file *m) |
1405 | { | 1404 | { |
1406 | int len = 0; | ||
1407 | |||
1408 | if (id >= TPACPI_RFK_SW_MAX) | 1405 | if (id >= TPACPI_RFK_SW_MAX) |
1409 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 1406 | seq_printf(m, "status:\t\tnot supported\n"); |
1410 | else { | 1407 | else { |
1411 | int status; | 1408 | int status; |
1412 | 1409 | ||
@@ -1420,13 +1417,13 @@ static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, char *p) | |||
1420 | return status; | 1417 | return status; |
1421 | } | 1418 | } |
1422 | 1419 | ||
1423 | len += sprintf(p + len, "status:\t\t%s\n", | 1420 | seq_printf(m, "status:\t\t%s\n", |
1424 | (status == TPACPI_RFK_RADIO_ON) ? | 1421 | (status == TPACPI_RFK_RADIO_ON) ? |
1425 | "enabled" : "disabled"); | 1422 | "enabled" : "disabled"); |
1426 | len += sprintf(p + len, "commands:\tenable, disable\n"); | 1423 | seq_printf(m, "commands:\tenable, disable\n"); |
1427 | } | 1424 | } |
1428 | 1425 | ||
1429 | return len; | 1426 | return 0; |
1430 | } | 1427 | } |
1431 | 1428 | ||
1432 | static int tpacpi_rfk_procfs_write(const enum tpacpi_rfk_id id, char *buf) | 1429 | static int tpacpi_rfk_procfs_write(const enum tpacpi_rfk_id id, char *buf) |
@@ -1904,14 +1901,11 @@ static int __init thinkpad_acpi_driver_init(struct ibm_init_struct *iibm) | |||
1904 | return 0; | 1901 | return 0; |
1905 | } | 1902 | } |
1906 | 1903 | ||
1907 | static int thinkpad_acpi_driver_read(char *p) | 1904 | static int thinkpad_acpi_driver_read(struct seq_file *m) |
1908 | { | 1905 | { |
1909 | int len = 0; | 1906 | seq_printf(m, "driver:\t\t%s\n", TPACPI_DESC); |
1910 | 1907 | seq_printf(m, "version:\t%s\n", TPACPI_VERSION); | |
1911 | len += sprintf(p + len, "driver:\t\t%s\n", TPACPI_DESC); | 1908 | return 0; |
1912 | len += sprintf(p + len, "version:\t%s\n", TPACPI_VERSION); | ||
1913 | |||
1914 | return len; | ||
1915 | } | 1909 | } |
1916 | 1910 | ||
1917 | static struct ibm_struct thinkpad_acpi_driver_data = { | 1911 | static struct ibm_struct thinkpad_acpi_driver_data = { |
@@ -3759,14 +3753,13 @@ static void hotkey_resume(void) | |||
3759 | } | 3753 | } |
3760 | 3754 | ||
3761 | /* procfs -------------------------------------------------------------- */ | 3755 | /* procfs -------------------------------------------------------------- */ |
3762 | static int hotkey_read(char *p) | 3756 | static int hotkey_read(struct seq_file *m) |
3763 | { | 3757 | { |
3764 | int res, status; | 3758 | int res, status; |
3765 | int len = 0; | ||
3766 | 3759 | ||
3767 | if (!tp_features.hotkey) { | 3760 | if (!tp_features.hotkey) { |
3768 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 3761 | seq_printf(m, "status:\t\tnot supported\n"); |
3769 | return len; | 3762 | return 0; |
3770 | } | 3763 | } |
3771 | 3764 | ||
3772 | if (mutex_lock_killable(&hotkey_mutex)) | 3765 | if (mutex_lock_killable(&hotkey_mutex)) |
@@ -3778,17 +3771,16 @@ static int hotkey_read(char *p) | |||
3778 | if (res) | 3771 | if (res) |
3779 | return res; | 3772 | return res; |
3780 | 3773 | ||
3781 | len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); | 3774 | seq_printf(m, "status:\t\t%s\n", enabled(status, 0)); |
3782 | if (hotkey_all_mask) { | 3775 | if (hotkey_all_mask) { |
3783 | len += sprintf(p + len, "mask:\t\t0x%08x\n", hotkey_user_mask); | 3776 | seq_printf(m, "mask:\t\t0x%08x\n", hotkey_user_mask); |
3784 | len += sprintf(p + len, | 3777 | seq_printf(m, "commands:\tenable, disable, reset, <mask>\n"); |
3785 | "commands:\tenable, disable, reset, <mask>\n"); | ||
3786 | } else { | 3778 | } else { |
3787 | len += sprintf(p + len, "mask:\t\tnot supported\n"); | 3779 | seq_printf(m, "mask:\t\tnot supported\n"); |
3788 | len += sprintf(p + len, "commands:\tenable, disable, reset\n"); | 3780 | seq_printf(m, "commands:\tenable, disable, reset\n"); |
3789 | } | 3781 | } |
3790 | 3782 | ||
3791 | return len; | 3783 | return 0; |
3792 | } | 3784 | } |
3793 | 3785 | ||
3794 | static void hotkey_enabledisable_warn(bool enable) | 3786 | static void hotkey_enabledisable_warn(bool enable) |
@@ -4054,9 +4046,9 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
4054 | } | 4046 | } |
4055 | 4047 | ||
4056 | /* procfs -------------------------------------------------------------- */ | 4048 | /* procfs -------------------------------------------------------------- */ |
4057 | static int bluetooth_read(char *p) | 4049 | static int bluetooth_read(struct seq_file *m) |
4058 | { | 4050 | { |
4059 | return tpacpi_rfk_procfs_read(TPACPI_RFK_BLUETOOTH_SW_ID, p); | 4051 | return tpacpi_rfk_procfs_read(TPACPI_RFK_BLUETOOTH_SW_ID, m); |
4060 | } | 4052 | } |
4061 | 4053 | ||
4062 | static int bluetooth_write(char *buf) | 4054 | static int bluetooth_write(char *buf) |
@@ -4244,9 +4236,9 @@ static int __init wan_init(struct ibm_init_struct *iibm) | |||
4244 | } | 4236 | } |
4245 | 4237 | ||
4246 | /* procfs -------------------------------------------------------------- */ | 4238 | /* procfs -------------------------------------------------------------- */ |
4247 | static int wan_read(char *p) | 4239 | static int wan_read(struct seq_file *m) |
4248 | { | 4240 | { |
4249 | return tpacpi_rfk_procfs_read(TPACPI_RFK_WWAN_SW_ID, p); | 4241 | return tpacpi_rfk_procfs_read(TPACPI_RFK_WWAN_SW_ID, m); |
4250 | } | 4242 | } |
4251 | 4243 | ||
4252 | static int wan_write(char *buf) | 4244 | static int wan_write(char *buf) |
@@ -4621,14 +4613,13 @@ static int video_expand_toggle(void) | |||
4621 | /* not reached */ | 4613 | /* not reached */ |
4622 | } | 4614 | } |
4623 | 4615 | ||
4624 | static int video_read(char *p) | 4616 | static int video_read(struct seq_file *m) |
4625 | { | 4617 | { |
4626 | int status, autosw; | 4618 | int status, autosw; |
4627 | int len = 0; | ||
4628 | 4619 | ||
4629 | if (video_supported == TPACPI_VIDEO_NONE) { | 4620 | if (video_supported == TPACPI_VIDEO_NONE) { |
4630 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 4621 | seq_printf(m, "status:\t\tnot supported\n"); |
4631 | return len; | 4622 | return 0; |
4632 | } | 4623 | } |
4633 | 4624 | ||
4634 | status = video_outputsw_get(); | 4625 | status = video_outputsw_get(); |
@@ -4639,20 +4630,20 @@ static int video_read(char *p) | |||
4639 | if (autosw < 0) | 4630 | if (autosw < 0) |
4640 | return autosw; | 4631 | return autosw; |
4641 | 4632 | ||
4642 | len += sprintf(p + len, "status:\t\tsupported\n"); | 4633 | seq_printf(m, "status:\t\tsupported\n"); |
4643 | len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0)); | 4634 | seq_printf(m, "lcd:\t\t%s\n", enabled(status, 0)); |
4644 | len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1)); | 4635 | seq_printf(m, "crt:\t\t%s\n", enabled(status, 1)); |
4645 | if (video_supported == TPACPI_VIDEO_NEW) | 4636 | if (video_supported == TPACPI_VIDEO_NEW) |
4646 | len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3)); | 4637 | seq_printf(m, "dvi:\t\t%s\n", enabled(status, 3)); |
4647 | len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0)); | 4638 | seq_printf(m, "auto:\t\t%s\n", enabled(autosw, 0)); |
4648 | len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n"); | 4639 | seq_printf(m, "commands:\tlcd_enable, lcd_disable\n"); |
4649 | len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n"); | 4640 | seq_printf(m, "commands:\tcrt_enable, crt_disable\n"); |
4650 | if (video_supported == TPACPI_VIDEO_NEW) | 4641 | if (video_supported == TPACPI_VIDEO_NEW) |
4651 | len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n"); | 4642 | seq_printf(m, "commands:\tdvi_enable, dvi_disable\n"); |
4652 | len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n"); | 4643 | seq_printf(m, "commands:\tauto_enable, auto_disable\n"); |
4653 | len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n"); | 4644 | seq_printf(m, "commands:\tvideo_switch, expand_toggle\n"); |
4654 | 4645 | ||
4655 | return len; | 4646 | return 0; |
4656 | } | 4647 | } |
4657 | 4648 | ||
4658 | static int video_write(char *buf) | 4649 | static int video_write(char *buf) |
@@ -4844,25 +4835,24 @@ static void light_exit(void) | |||
4844 | flush_workqueue(tpacpi_wq); | 4835 | flush_workqueue(tpacpi_wq); |
4845 | } | 4836 | } |
4846 | 4837 | ||
4847 | static int light_read(char *p) | 4838 | static int light_read(struct seq_file *m) |
4848 | { | 4839 | { |
4849 | int len = 0; | ||
4850 | int status; | 4840 | int status; |
4851 | 4841 | ||
4852 | if (!tp_features.light) { | 4842 | if (!tp_features.light) { |
4853 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 4843 | seq_printf(m, "status:\t\tnot supported\n"); |
4854 | } else if (!tp_features.light_status) { | 4844 | } else if (!tp_features.light_status) { |
4855 | len += sprintf(p + len, "status:\t\tunknown\n"); | 4845 | seq_printf(m, "status:\t\tunknown\n"); |
4856 | len += sprintf(p + len, "commands:\ton, off\n"); | 4846 | seq_printf(m, "commands:\ton, off\n"); |
4857 | } else { | 4847 | } else { |
4858 | status = light_get_status(); | 4848 | status = light_get_status(); |
4859 | if (status < 0) | 4849 | if (status < 0) |
4860 | return status; | 4850 | return status; |
4861 | len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0)); | 4851 | seq_printf(m, "status:\t\t%s\n", onoff(status, 0)); |
4862 | len += sprintf(p + len, "commands:\ton, off\n"); | 4852 | seq_printf(m, "commands:\ton, off\n"); |
4863 | } | 4853 | } |
4864 | 4854 | ||
4865 | return len; | 4855 | return 0; |
4866 | } | 4856 | } |
4867 | 4857 | ||
4868 | static int light_write(char *buf) | 4858 | static int light_write(char *buf) |
@@ -4940,20 +4930,18 @@ static void cmos_exit(void) | |||
4940 | device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); | 4930 | device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); |
4941 | } | 4931 | } |
4942 | 4932 | ||
4943 | static int cmos_read(char *p) | 4933 | static int cmos_read(struct seq_file *m) |
4944 | { | 4934 | { |
4945 | int len = 0; | ||
4946 | |||
4947 | /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, | 4935 | /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, |
4948 | R30, R31, T20-22, X20-21 */ | 4936 | R30, R31, T20-22, X20-21 */ |
4949 | if (!cmos_handle) | 4937 | if (!cmos_handle) |
4950 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 4938 | seq_printf(m, "status:\t\tnot supported\n"); |
4951 | else { | 4939 | else { |
4952 | len += sprintf(p + len, "status:\t\tsupported\n"); | 4940 | seq_printf(m, "status:\t\tsupported\n"); |
4953 | len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-21)\n"); | 4941 | seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); |
4954 | } | 4942 | } |
4955 | 4943 | ||
4956 | return len; | 4944 | return 0; |
4957 | } | 4945 | } |
4958 | 4946 | ||
4959 | static int cmos_write(char *buf) | 4947 | static int cmos_write(char *buf) |
@@ -5328,15 +5316,13 @@ static int __init led_init(struct ibm_init_struct *iibm) | |||
5328 | ((s) == TPACPI_LED_OFF ? "off" : \ | 5316 | ((s) == TPACPI_LED_OFF ? "off" : \ |
5329 | ((s) == TPACPI_LED_ON ? "on" : "blinking")) | 5317 | ((s) == TPACPI_LED_ON ? "on" : "blinking")) |
5330 | 5318 | ||
5331 | static int led_read(char *p) | 5319 | static int led_read(struct seq_file *m) |
5332 | { | 5320 | { |
5333 | int len = 0; | ||
5334 | |||
5335 | if (!led_supported) { | 5321 | if (!led_supported) { |
5336 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 5322 | seq_printf(m, "status:\t\tnot supported\n"); |
5337 | return len; | 5323 | return 0; |
5338 | } | 5324 | } |
5339 | len += sprintf(p + len, "status:\t\tsupported\n"); | 5325 | seq_printf(m, "status:\t\tsupported\n"); |
5340 | 5326 | ||
5341 | if (led_supported == TPACPI_LED_570) { | 5327 | if (led_supported == TPACPI_LED_570) { |
5342 | /* 570 */ | 5328 | /* 570 */ |
@@ -5345,15 +5331,15 @@ static int led_read(char *p) | |||
5345 | status = led_get_status(i); | 5331 | status = led_get_status(i); |
5346 | if (status < 0) | 5332 | if (status < 0) |
5347 | return -EIO; | 5333 | return -EIO; |
5348 | len += sprintf(p + len, "%d:\t\t%s\n", | 5334 | seq_printf(m, "%d:\t\t%s\n", |
5349 | i, str_led_status(status)); | 5335 | i, str_led_status(status)); |
5350 | } | 5336 | } |
5351 | } | 5337 | } |
5352 | 5338 | ||
5353 | len += sprintf(p + len, "commands:\t" | 5339 | seq_printf(m, "commands:\t" |
5354 | "<led> on, <led> off, <led> blink (<led> is 0-15)\n"); | 5340 | "<led> on, <led> off, <led> blink (<led> is 0-15)\n"); |
5355 | 5341 | ||
5356 | return len; | 5342 | return 0; |
5357 | } | 5343 | } |
5358 | 5344 | ||
5359 | static int led_write(char *buf) | 5345 | static int led_write(char *buf) |
@@ -5426,18 +5412,16 @@ static int __init beep_init(struct ibm_init_struct *iibm) | |||
5426 | return (beep_handle)? 0 : 1; | 5412 | return (beep_handle)? 0 : 1; |
5427 | } | 5413 | } |
5428 | 5414 | ||
5429 | static int beep_read(char *p) | 5415 | static int beep_read(struct seq_file *m) |
5430 | { | 5416 | { |
5431 | int len = 0; | ||
5432 | |||
5433 | if (!beep_handle) | 5417 | if (!beep_handle) |
5434 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 5418 | seq_printf(m, "status:\t\tnot supported\n"); |
5435 | else { | 5419 | else { |
5436 | len += sprintf(p + len, "status:\t\tsupported\n"); | 5420 | seq_printf(m, "status:\t\tsupported\n"); |
5437 | len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-17)\n"); | 5421 | seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); |
5438 | } | 5422 | } |
5439 | 5423 | ||
5440 | return len; | 5424 | return 0; |
5441 | } | 5425 | } |
5442 | 5426 | ||
5443 | static int beep_write(char *buf) | 5427 | static int beep_write(char *buf) |
@@ -5798,9 +5782,8 @@ static void thermal_exit(void) | |||
5798 | } | 5782 | } |
5799 | } | 5783 | } |
5800 | 5784 | ||
5801 | static int thermal_read(char *p) | 5785 | static int thermal_read(struct seq_file *m) |
5802 | { | 5786 | { |
5803 | int len = 0; | ||
5804 | int n, i; | 5787 | int n, i; |
5805 | struct ibm_thermal_sensors_struct t; | 5788 | struct ibm_thermal_sensors_struct t; |
5806 | 5789 | ||
@@ -5808,16 +5791,16 @@ static int thermal_read(char *p) | |||
5808 | if (unlikely(n < 0)) | 5791 | if (unlikely(n < 0)) |
5809 | return n; | 5792 | return n; |
5810 | 5793 | ||
5811 | len += sprintf(p + len, "temperatures:\t"); | 5794 | seq_printf(m, "temperatures:\t"); |
5812 | 5795 | ||
5813 | if (n > 0) { | 5796 | if (n > 0) { |
5814 | for (i = 0; i < (n - 1); i++) | 5797 | for (i = 0; i < (n - 1); i++) |
5815 | len += sprintf(p + len, "%d ", t.temp[i] / 1000); | 5798 | seq_printf(m, "%d ", t.temp[i] / 1000); |
5816 | len += sprintf(p + len, "%d\n", t.temp[i] / 1000); | 5799 | seq_printf(m, "%d\n", t.temp[i] / 1000); |
5817 | } else | 5800 | } else |
5818 | len += sprintf(p + len, "not supported\n"); | 5801 | seq_printf(m, "not supported\n"); |
5819 | 5802 | ||
5820 | return len; | 5803 | return 0; |
5821 | } | 5804 | } |
5822 | 5805 | ||
5823 | static struct ibm_struct thermal_driver_data = { | 5806 | static struct ibm_struct thermal_driver_data = { |
@@ -5832,39 +5815,38 @@ static struct ibm_struct thermal_driver_data = { | |||
5832 | 5815 | ||
5833 | static u8 ecdump_regs[256]; | 5816 | static u8 ecdump_regs[256]; |
5834 | 5817 | ||
5835 | static int ecdump_read(char *p) | 5818 | static int ecdump_read(struct seq_file *m) |
5836 | { | 5819 | { |
5837 | int len = 0; | ||
5838 | int i, j; | 5820 | int i, j; |
5839 | u8 v; | 5821 | u8 v; |
5840 | 5822 | ||
5841 | len += sprintf(p + len, "EC " | 5823 | seq_printf(m, "EC " |
5842 | " +00 +01 +02 +03 +04 +05 +06 +07" | 5824 | " +00 +01 +02 +03 +04 +05 +06 +07" |
5843 | " +08 +09 +0a +0b +0c +0d +0e +0f\n"); | 5825 | " +08 +09 +0a +0b +0c +0d +0e +0f\n"); |
5844 | for (i = 0; i < 256; i += 16) { | 5826 | for (i = 0; i < 256; i += 16) { |
5845 | len += sprintf(p + len, "EC 0x%02x:", i); | 5827 | seq_printf(m, "EC 0x%02x:", i); |
5846 | for (j = 0; j < 16; j++) { | 5828 | for (j = 0; j < 16; j++) { |
5847 | if (!acpi_ec_read(i + j, &v)) | 5829 | if (!acpi_ec_read(i + j, &v)) |
5848 | break; | 5830 | break; |
5849 | if (v != ecdump_regs[i + j]) | 5831 | if (v != ecdump_regs[i + j]) |
5850 | len += sprintf(p + len, " *%02x", v); | 5832 | seq_printf(m, " *%02x", v); |
5851 | else | 5833 | else |
5852 | len += sprintf(p + len, " %02x", v); | 5834 | seq_printf(m, " %02x", v); |
5853 | ecdump_regs[i + j] = v; | 5835 | ecdump_regs[i + j] = v; |
5854 | } | 5836 | } |
5855 | len += sprintf(p + len, "\n"); | 5837 | seq_putc(m, '\n'); |
5856 | if (j != 16) | 5838 | if (j != 16) |
5857 | break; | 5839 | break; |
5858 | } | 5840 | } |
5859 | 5841 | ||
5860 | /* These are way too dangerous to advertise openly... */ | 5842 | /* These are way too dangerous to advertise openly... */ |
5861 | #if 0 | 5843 | #if 0 |
5862 | len += sprintf(p + len, "commands:\t0x<offset> 0x<value>" | 5844 | seq_printf(m, "commands:\t0x<offset> 0x<value>" |
5863 | " (<offset> is 00-ff, <value> is 00-ff)\n"); | 5845 | " (<offset> is 00-ff, <value> is 00-ff)\n"); |
5864 | len += sprintf(p + len, "commands:\t0x<offset> <value> " | 5846 | seq_printf(m, "commands:\t0x<offset> <value> " |
5865 | " (<offset> is 00-ff, <value> is 0-255)\n"); | 5847 | " (<offset> is 00-ff, <value> is 0-255)\n"); |
5866 | #endif | 5848 | #endif |
5867 | return len; | 5849 | return 0; |
5868 | } | 5850 | } |
5869 | 5851 | ||
5870 | static int ecdump_write(char *buf) | 5852 | static int ecdump_write(char *buf) |
@@ -6317,23 +6299,22 @@ static void brightness_exit(void) | |||
6317 | tpacpi_brightness_checkpoint_nvram(); | 6299 | tpacpi_brightness_checkpoint_nvram(); |
6318 | } | 6300 | } |
6319 | 6301 | ||
6320 | static int brightness_read(char *p) | 6302 | static int brightness_read(struct seq_file *m) |
6321 | { | 6303 | { |
6322 | int len = 0; | ||
6323 | int level; | 6304 | int level; |
6324 | 6305 | ||
6325 | level = brightness_get(NULL); | 6306 | level = brightness_get(NULL); |
6326 | if (level < 0) { | 6307 | if (level < 0) { |
6327 | len += sprintf(p + len, "level:\t\tunreadable\n"); | 6308 | seq_printf(m, "level:\t\tunreadable\n"); |
6328 | } else { | 6309 | } else { |
6329 | len += sprintf(p + len, "level:\t\t%d\n", level); | 6310 | seq_printf(m, "level:\t\t%d\n", level); |
6330 | len += sprintf(p + len, "commands:\tup, down\n"); | 6311 | seq_printf(m, "commands:\tup, down\n"); |
6331 | len += sprintf(p + len, "commands:\tlevel <level>" | 6312 | seq_printf(m, "commands:\tlevel <level>" |
6332 | " (<level> is 0-%d)\n", | 6313 | " (<level> is 0-%d)\n", |
6333 | (tp_features.bright_16levels) ? 15 : 7); | 6314 | (tp_features.bright_16levels) ? 15 : 7); |
6334 | } | 6315 | } |
6335 | 6316 | ||
6336 | return len; | 6317 | return 0; |
6337 | } | 6318 | } |
6338 | 6319 | ||
6339 | static int brightness_write(char *buf) | 6320 | static int brightness_write(char *buf) |
@@ -6921,29 +6902,28 @@ static int __init volume_init(struct ibm_init_struct *iibm) | |||
6921 | return 0; | 6902 | return 0; |
6922 | } | 6903 | } |
6923 | 6904 | ||
6924 | static int volume_read(char *p) | 6905 | static int volume_read(struct seq_file *m) |
6925 | { | 6906 | { |
6926 | int len = 0; | ||
6927 | u8 status; | 6907 | u8 status; |
6928 | 6908 | ||
6929 | if (volume_get_status(&status) < 0) { | 6909 | if (volume_get_status(&status) < 0) { |
6930 | len += sprintf(p + len, "level:\t\tunreadable\n"); | 6910 | seq_printf(m, "level:\t\tunreadable\n"); |
6931 | } else { | 6911 | } else { |
6932 | if (tp_features.mixer_no_level_control) | 6912 | if (tp_features.mixer_no_level_control) |
6933 | len += sprintf(p + len, "level:\t\tunsupported\n"); | 6913 | seq_printf(m, "level:\t\tunsupported\n"); |
6934 | else | 6914 | else |
6935 | len += sprintf(p + len, "level:\t\t%d\n", | 6915 | seq_printf(m, "level:\t\t%d\n", |
6936 | status & TP_EC_AUDIO_LVL_MSK); | 6916 | status & TP_EC_AUDIO_LVL_MSK); |
6937 | 6917 | ||
6938 | len += sprintf(p + len, "mute:\t\t%s\n", | 6918 | seq_printf(m, "mute:\t\t%s\n", |
6939 | onoff(status, TP_EC_AUDIO_MUTESW)); | 6919 | onoff(status, TP_EC_AUDIO_MUTESW)); |
6940 | 6920 | ||
6941 | if (volume_control_allowed) { | 6921 | if (volume_control_allowed) { |
6942 | len += sprintf(p + len, "commands:\tunmute, mute\n"); | 6922 | seq_printf(m, "commands:\tunmute, mute\n"); |
6943 | if (!tp_features.mixer_no_level_control) { | 6923 | if (!tp_features.mixer_no_level_control) { |
6944 | len += sprintf(p + len, | 6924 | seq_printf(m, |
6945 | "commands:\tup, down\n"); | 6925 | "commands:\tup, down\n"); |
6946 | len += sprintf(p + len, | 6926 | seq_printf(m, |
6947 | "commands:\tlevel <level>" | 6927 | "commands:\tlevel <level>" |
6948 | " (<level> is 0-%d)\n", | 6928 | " (<level> is 0-%d)\n", |
6949 | TP_EC_VOLUME_MAX); | 6929 | TP_EC_VOLUME_MAX); |
@@ -6951,7 +6931,7 @@ static int volume_read(char *p) | |||
6951 | } | 6931 | } |
6952 | } | 6932 | } |
6953 | 6933 | ||
6954 | return len; | 6934 | return 0; |
6955 | } | 6935 | } |
6956 | 6936 | ||
6957 | static int volume_write(char *buf) | 6937 | static int volume_write(char *buf) |
@@ -8113,9 +8093,8 @@ static void fan_resume(void) | |||
8113 | } | 8093 | } |
8114 | } | 8094 | } |
8115 | 8095 | ||
8116 | static int fan_read(char *p) | 8096 | static int fan_read(struct seq_file *m) |
8117 | { | 8097 | { |
8118 | int len = 0; | ||
8119 | int rc; | 8098 | int rc; |
8120 | u8 status; | 8099 | u8 status; |
8121 | unsigned int speed = 0; | 8100 | unsigned int speed = 0; |
@@ -8127,7 +8106,7 @@ static int fan_read(char *p) | |||
8127 | if (rc < 0) | 8106 | if (rc < 0) |
8128 | return rc; | 8107 | return rc; |
8129 | 8108 | ||
8130 | len += sprintf(p + len, "status:\t\t%s\n" | 8109 | seq_printf(m, "status:\t\t%s\n" |
8131 | "level:\t\t%d\n", | 8110 | "level:\t\t%d\n", |
8132 | (status != 0) ? "enabled" : "disabled", status); | 8111 | (status != 0) ? "enabled" : "disabled", status); |
8133 | break; | 8112 | break; |
@@ -8138,54 +8117,54 @@ static int fan_read(char *p) | |||
8138 | if (rc < 0) | 8117 | if (rc < 0) |
8139 | return rc; | 8118 | return rc; |
8140 | 8119 | ||
8141 | len += sprintf(p + len, "status:\t\t%s\n", | 8120 | seq_printf(m, "status:\t\t%s\n", |
8142 | (status != 0) ? "enabled" : "disabled"); | 8121 | (status != 0) ? "enabled" : "disabled"); |
8143 | 8122 | ||
8144 | rc = fan_get_speed(&speed); | 8123 | rc = fan_get_speed(&speed); |
8145 | if (rc < 0) | 8124 | if (rc < 0) |
8146 | return rc; | 8125 | return rc; |
8147 | 8126 | ||
8148 | len += sprintf(p + len, "speed:\t\t%d\n", speed); | 8127 | seq_printf(m, "speed:\t\t%d\n", speed); |
8149 | 8128 | ||
8150 | if (status & TP_EC_FAN_FULLSPEED) | 8129 | if (status & TP_EC_FAN_FULLSPEED) |
8151 | /* Disengaged mode takes precedence */ | 8130 | /* Disengaged mode takes precedence */ |
8152 | len += sprintf(p + len, "level:\t\tdisengaged\n"); | 8131 | seq_printf(m, "level:\t\tdisengaged\n"); |
8153 | else if (status & TP_EC_FAN_AUTO) | 8132 | else if (status & TP_EC_FAN_AUTO) |
8154 | len += sprintf(p + len, "level:\t\tauto\n"); | 8133 | seq_printf(m, "level:\t\tauto\n"); |
8155 | else | 8134 | else |
8156 | len += sprintf(p + len, "level:\t\t%d\n", status); | 8135 | seq_printf(m, "level:\t\t%d\n", status); |
8157 | break; | 8136 | break; |
8158 | 8137 | ||
8159 | case TPACPI_FAN_NONE: | 8138 | case TPACPI_FAN_NONE: |
8160 | default: | 8139 | default: |
8161 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 8140 | seq_printf(m, "status:\t\tnot supported\n"); |
8162 | } | 8141 | } |
8163 | 8142 | ||
8164 | if (fan_control_commands & TPACPI_FAN_CMD_LEVEL) { | 8143 | if (fan_control_commands & TPACPI_FAN_CMD_LEVEL) { |
8165 | len += sprintf(p + len, "commands:\tlevel <level>"); | 8144 | seq_printf(m, "commands:\tlevel <level>"); |
8166 | 8145 | ||
8167 | switch (fan_control_access_mode) { | 8146 | switch (fan_control_access_mode) { |
8168 | case TPACPI_FAN_WR_ACPI_SFAN: | 8147 | case TPACPI_FAN_WR_ACPI_SFAN: |
8169 | len += sprintf(p + len, " (<level> is 0-7)\n"); | 8148 | seq_printf(m, " (<level> is 0-7)\n"); |
8170 | break; | 8149 | break; |
8171 | 8150 | ||
8172 | default: | 8151 | default: |
8173 | len += sprintf(p + len, " (<level> is 0-7, " | 8152 | seq_printf(m, " (<level> is 0-7, " |
8174 | "auto, disengaged, full-speed)\n"); | 8153 | "auto, disengaged, full-speed)\n"); |
8175 | break; | 8154 | break; |
8176 | } | 8155 | } |
8177 | } | 8156 | } |
8178 | 8157 | ||
8179 | if (fan_control_commands & TPACPI_FAN_CMD_ENABLE) | 8158 | if (fan_control_commands & TPACPI_FAN_CMD_ENABLE) |
8180 | len += sprintf(p + len, "commands:\tenable, disable\n" | 8159 | seq_printf(m, "commands:\tenable, disable\n" |
8181 | "commands:\twatchdog <timeout> (<timeout> " | 8160 | "commands:\twatchdog <timeout> (<timeout> " |
8182 | "is 0 (off), 1-120 (seconds))\n"); | 8161 | "is 0 (off), 1-120 (seconds))\n"); |
8183 | 8162 | ||
8184 | if (fan_control_commands & TPACPI_FAN_CMD_SPEED) | 8163 | if (fan_control_commands & TPACPI_FAN_CMD_SPEED) |
8185 | len += sprintf(p + len, "commands:\tspeed <speed>" | 8164 | seq_printf(m, "commands:\tspeed <speed>" |
8186 | " (<speed> is 0-65535)\n"); | 8165 | " (<speed> is 0-65535)\n"); |
8187 | 8166 | ||
8188 | return len; | 8167 | return 0; |
8189 | } | 8168 | } |
8190 | 8169 | ||
8191 | static int fan_write_cmd_level(const char *cmd, int *rc) | 8170 | static int fan_write_cmd_level(const char *cmd, int *rc) |
@@ -8472,19 +8451,19 @@ static int __init ibm_init(struct ibm_init_struct *iibm) | |||
8472 | "%s installed\n", ibm->name); | 8451 | "%s installed\n", ibm->name); |
8473 | 8452 | ||
8474 | if (ibm->read) { | 8453 | if (ibm->read) { |
8475 | entry = create_proc_entry(ibm->name, | 8454 | mode_t mode; |
8476 | S_IFREG | S_IRUGO | S_IWUSR, | 8455 | |
8477 | proc_dir); | 8456 | mode = S_IRUGO; |
8457 | if (ibm->write) | ||
8458 | mode |= S_IWUSR; | ||
8459 | entry = proc_create_data(ibm->name, mode, proc_dir, | ||
8460 | &dispatch_proc_fops, ibm); | ||
8478 | if (!entry) { | 8461 | if (!entry) { |
8479 | printk(TPACPI_ERR "unable to create proc entry %s\n", | 8462 | printk(TPACPI_ERR "unable to create proc entry %s\n", |
8480 | ibm->name); | 8463 | ibm->name); |
8481 | ret = -ENODEV; | 8464 | ret = -ENODEV; |
8482 | goto err_out; | 8465 | goto err_out; |
8483 | } | 8466 | } |
8484 | entry->data = ibm; | ||
8485 | entry->read_proc = &dispatch_procfs_read; | ||
8486 | if (ibm->write) | ||
8487 | entry->write_proc = &dispatch_procfs_write; | ||
8488 | ibm->flags.proc_created = 1; | 8467 | ibm->flags.proc_created = 1; |
8489 | } | 8468 | } |
8490 | 8469 | ||