aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/ans-lcd.c45
-rw-r--r--drivers/macintosh/mac_hid.c17
2 files changed, 34 insertions, 28 deletions
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index 6a8221893256..a3d25da2f275 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -3,7 +3,6 @@
3 */ 3 */
4 4
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/smp_lock.h>
7#include <linux/errno.h> 6#include <linux/errno.h>
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/miscdevice.h> 8#include <linux/miscdevice.h>
@@ -26,6 +25,7 @@
26static unsigned long anslcd_short_delay = 80; 25static unsigned long anslcd_short_delay = 80;
27static unsigned long anslcd_long_delay = 3280; 26static unsigned long anslcd_long_delay = 3280;
28static volatile unsigned char __iomem *anslcd_ptr; 27static volatile unsigned char __iomem *anslcd_ptr;
28static DEFINE_MUTEX(anslcd_mutex);
29 29
30#undef DEBUG 30#undef DEBUG
31 31
@@ -65,26 +65,31 @@ anslcd_write( struct file * file, const char __user * buf,
65 65
66 if (!access_ok(VERIFY_READ, buf, count)) 66 if (!access_ok(VERIFY_READ, buf, count))
67 return -EFAULT; 67 return -EFAULT;
68
69 mutex_lock(&anslcd_mutex);
68 for ( i = *ppos; count > 0; ++i, ++p, --count ) 70 for ( i = *ppos; count > 0; ++i, ++p, --count )
69 { 71 {
70 char c; 72 char c;
71 __get_user(c, p); 73 __get_user(c, p);
72 anslcd_write_byte_data( c ); 74 anslcd_write_byte_data( c );
73 } 75 }
76 mutex_unlock(&anslcd_mutex);
74 *ppos = i; 77 *ppos = i;
75 return p - buf; 78 return p - buf;
76} 79}
77 80
78static int 81static long
79anslcd_ioctl( struct inode * inode, struct file * file, 82anslcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
80 unsigned int cmd, unsigned long arg )
81{ 83{
82 char ch, __user *temp; 84 char ch, __user *temp;
85 long ret = 0;
83 86
84#ifdef DEBUG 87#ifdef DEBUG
85 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg); 88 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
86#endif 89#endif
87 90
91 mutex_lock(&anslcd_mutex);
92
88 switch ( cmd ) 93 switch ( cmd )
89 { 94 {
90 case ANSLCD_CLEAR: 95 case ANSLCD_CLEAR:
@@ -93,7 +98,7 @@ anslcd_ioctl( struct inode * inode, struct file * file,
93 anslcd_write_byte_ctrl ( 0x06 ); 98 anslcd_write_byte_ctrl ( 0x06 );
94 anslcd_write_byte_ctrl ( 0x01 ); 99 anslcd_write_byte_ctrl ( 0x01 );
95 anslcd_write_byte_ctrl ( 0x02 ); 100 anslcd_write_byte_ctrl ( 0x02 );
96 return 0; 101 break;
97 case ANSLCD_SENDCTRL: 102 case ANSLCD_SENDCTRL:
98 temp = (char __user *) arg; 103 temp = (char __user *) arg;
99 __get_user(ch, temp); 104 __get_user(ch, temp);
@@ -101,33 +106,37 @@ anslcd_ioctl( struct inode * inode, struct file * file,
101 anslcd_write_byte_ctrl ( ch ); 106 anslcd_write_byte_ctrl ( ch );
102 __get_user(ch, temp); 107 __get_user(ch, temp);
103 } 108 }
104 return 0; 109 break;
105 case ANSLCD_SETSHORTDELAY: 110 case ANSLCD_SETSHORTDELAY:
106 if (!capable(CAP_SYS_ADMIN)) 111 if (!capable(CAP_SYS_ADMIN))
107 return -EACCES; 112 ret =-EACCES;
108 anslcd_short_delay=arg; 113 else
109 return 0; 114 anslcd_short_delay=arg;
115 break;
110 case ANSLCD_SETLONGDELAY: 116 case ANSLCD_SETLONGDELAY:
111 if (!capable(CAP_SYS_ADMIN)) 117 if (!capable(CAP_SYS_ADMIN))
112 return -EACCES; 118 ret = -EACCES;
113 anslcd_long_delay=arg; 119 else
114 return 0; 120 anslcd_long_delay=arg;
121 break;
115 default: 122 default:
116 return -EINVAL; 123 ret = -EINVAL;
117 } 124 }
125
126 mutex_unlock(&anslcd_mutex);
127 return ret;
118} 128}
119 129
120static int 130static int
121anslcd_open( struct inode * inode, struct file * file ) 131anslcd_open( struct inode * inode, struct file * file )
122{ 132{
123 cycle_kernel_lock();
124 return 0; 133 return 0;
125} 134}
126 135
127const struct file_operations anslcd_fops = { 136const struct file_operations anslcd_fops = {
128 .write = anslcd_write, 137 .write = anslcd_write,
129 .ioctl = anslcd_ioctl, 138 .unlocked_ioctl = anslcd_ioctl,
130 .open = anslcd_open, 139 .open = anslcd_open,
131}; 140};
132 141
133static struct miscdevice anslcd_dev = { 142static struct miscdevice anslcd_dev = {
@@ -168,6 +177,7 @@ anslcd_init(void)
168 printk(KERN_DEBUG "LCD: init\n"); 177 printk(KERN_DEBUG "LCD: init\n");
169#endif 178#endif
170 179
180 mutex_lock(&anslcd_mutex);
171 anslcd_write_byte_ctrl ( 0x38 ); 181 anslcd_write_byte_ctrl ( 0x38 );
172 anslcd_write_byte_ctrl ( 0x0c ); 182 anslcd_write_byte_ctrl ( 0x0c );
173 anslcd_write_byte_ctrl ( 0x06 ); 183 anslcd_write_byte_ctrl ( 0x06 );
@@ -176,6 +186,7 @@ anslcd_init(void)
176 for(a=0;a<80;a++) { 186 for(a=0;a<80;a++) {
177 anslcd_write_byte_data(anslcd_logo[a]); 187 anslcd_write_byte_data(anslcd_logo[a]);
178 } 188 }
189 mutex_unlock(&anslcd_mutex);
179 return 0; 190 return 0;
180} 191}
181 192
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index cc9f27514aef..7b4ef5bb556b 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -27,54 +27,49 @@ static int mouse_last_keycode;
27/* file(s) in /proc/sys/dev/mac_hid */ 27/* file(s) in /proc/sys/dev/mac_hid */
28static ctl_table mac_hid_files[] = { 28static ctl_table mac_hid_files[] = {
29 { 29 {
30 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON_EMULATION,
31 .procname = "mouse_button_emulation", 30 .procname = "mouse_button_emulation",
32 .data = &mouse_emulate_buttons, 31 .data = &mouse_emulate_buttons,
33 .maxlen = sizeof(int), 32 .maxlen = sizeof(int),
34 .mode = 0644, 33 .mode = 0644,
35 .proc_handler = &proc_dointvec, 34 .proc_handler = proc_dointvec,
36 }, 35 },
37 { 36 {
38 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE,
39 .procname = "mouse_button2_keycode", 37 .procname = "mouse_button2_keycode",
40 .data = &mouse_button2_keycode, 38 .data = &mouse_button2_keycode,
41 .maxlen = sizeof(int), 39 .maxlen = sizeof(int),
42 .mode = 0644, 40 .mode = 0644,
43 .proc_handler = &proc_dointvec, 41 .proc_handler = proc_dointvec,
44 }, 42 },
45 { 43 {
46 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE,
47 .procname = "mouse_button3_keycode", 44 .procname = "mouse_button3_keycode",
48 .data = &mouse_button3_keycode, 45 .data = &mouse_button3_keycode,
49 .maxlen = sizeof(int), 46 .maxlen = sizeof(int),
50 .mode = 0644, 47 .mode = 0644,
51 .proc_handler = &proc_dointvec, 48 .proc_handler = proc_dointvec,
52 }, 49 },
53 { .ctl_name = 0 } 50 { }
54}; 51};
55 52
56/* dir in /proc/sys/dev */ 53/* dir in /proc/sys/dev */
57static ctl_table mac_hid_dir[] = { 54static ctl_table mac_hid_dir[] = {
58 { 55 {
59 .ctl_name = DEV_MAC_HID,
60 .procname = "mac_hid", 56 .procname = "mac_hid",
61 .maxlen = 0, 57 .maxlen = 0,
62 .mode = 0555, 58 .mode = 0555,
63 .child = mac_hid_files, 59 .child = mac_hid_files,
64 }, 60 },
65 { .ctl_name = 0 } 61 { }
66}; 62};
67 63
68/* /proc/sys/dev itself, in case that is not there yet */ 64/* /proc/sys/dev itself, in case that is not there yet */
69static ctl_table mac_hid_root_dir[] = { 65static ctl_table mac_hid_root_dir[] = {
70 { 66 {
71 .ctl_name = CTL_DEV,
72 .procname = "dev", 67 .procname = "dev",
73 .maxlen = 0, 68 .maxlen = 0,
74 .mode = 0555, 69 .mode = 0555,
75 .child = mac_hid_dir, 70 .child = mac_hid_dir,
76 }, 71 },
77 { .ctl_name = 0 } 72 { }
78}; 73};
79 74
80static struct ctl_table_header *mac_hid_sysctl_header; 75static struct ctl_table_header *mac_hid_sysctl_header;