aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pcmcia_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c92
1 files changed, 68 insertions, 24 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 30cf71d2ee23..c4d7908fa37f 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -58,17 +58,6 @@ typedef struct user_info_t {
58} user_info_t; 58} user_info_t;
59 59
60 60
61#ifdef CONFIG_PCMCIA_DEBUG
62extern int ds_pc_debug;
63
64#define ds_dbg(lvl, fmt, arg...) do { \
65 if (ds_pc_debug >= lvl) \
66 printk(KERN_DEBUG "ds: " fmt , ## arg); \
67} while (0)
68#else
69#define ds_dbg(lvl, fmt, arg...) do { } while (0)
70#endif
71
72static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s, 61static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s,
73 unsigned int function) 62 unsigned int function)
74{ 63{
@@ -229,6 +218,61 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
229 return (ret); 218 return (ret);
230} 219}
231 220
221
222/** pcmcia_get_window
223 */
224static int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *wh_out,
225 window_handle_t wh, win_req_t *req)
226{
227 pccard_mem_map *win;
228 window_handle_t w;
229
230 wh--;
231 if (!s || !(s->state & SOCKET_PRESENT))
232 return -ENODEV;
233 if (wh >= MAX_WIN)
234 return -EINVAL;
235 for (w = wh; w < MAX_WIN; w++)
236 if (s->state & SOCKET_WIN_REQ(w))
237 break;
238 if (w == MAX_WIN)
239 return -EINVAL;
240 win = &s->win[w];
241 req->Base = win->res->start;
242 req->Size = win->res->end - win->res->start + 1;
243 req->AccessSpeed = win->speed;
244 req->Attributes = 0;
245 if (win->flags & MAP_ATTRIB)
246 req->Attributes |= WIN_MEMORY_TYPE_AM;
247 if (win->flags & MAP_ACTIVE)
248 req->Attributes |= WIN_ENABLE;
249 if (win->flags & MAP_16BIT)
250 req->Attributes |= WIN_DATA_WIDTH_16;
251 if (win->flags & MAP_USE_WAIT)
252 req->Attributes |= WIN_USE_WAIT;
253
254 *wh_out = w + 1;
255 return 0;
256} /* pcmcia_get_window */
257
258
259/** pcmcia_get_mem_page
260 *
261 * Change the card address of an already open memory window.
262 */
263static int pcmcia_get_mem_page(struct pcmcia_socket *skt, window_handle_t wh,
264 memreq_t *req)
265{
266 wh--;
267 if (wh >= MAX_WIN)
268 return -EINVAL;
269
270 req->Page = 0;
271 req->CardOffset = skt->win[wh].card_start;
272 return 0;
273} /* pcmcia_get_mem_page */
274
275
232/** pccard_get_status 276/** pccard_get_status
233 * 277 *
234 * Get the current socket state bits. We don't support the latched 278 * Get the current socket state bits. We don't support the latched
@@ -431,7 +475,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
431 if (!s) 475 if (!s)
432 return -EINVAL; 476 return -EINVAL;
433 477
434 ds_dbg(2, "bind_request(%d, '%s')\n", s->sock, 478 pr_debug("bind_request(%d, '%s')\n", s->sock,
435 (char *)bind_info->dev_info); 479 (char *)bind_info->dev_info);
436 480
437 p_drv = get_pcmcia_driver(&bind_info->dev_info); 481 p_drv = get_pcmcia_driver(&bind_info->dev_info);
@@ -623,7 +667,7 @@ static int ds_open(struct inode *inode, struct file *file)
623 static int warning_printed = 0; 667 static int warning_printed = 0;
624 int ret = 0; 668 int ret = 0;
625 669
626 ds_dbg(0, "ds_open(socket %d)\n", i); 670 pr_debug("ds_open(socket %d)\n", i);
627 671
628 lock_kernel(); 672 lock_kernel();
629 s = pcmcia_get_socket_by_nr(i); 673 s = pcmcia_get_socket_by_nr(i);
@@ -685,7 +729,7 @@ static int ds_release(struct inode *inode, struct file *file)
685 struct pcmcia_socket *s; 729 struct pcmcia_socket *s;
686 user_info_t *user, **link; 730 user_info_t *user, **link;
687 731
688 ds_dbg(0, "ds_release(socket %d)\n", iminor(inode)); 732 pr_debug("ds_release(socket %d)\n", iminor(inode));
689 733
690 user = file->private_data; 734 user = file->private_data;
691 if (CHECK_USER(user)) 735 if (CHECK_USER(user))
@@ -719,7 +763,7 @@ static ssize_t ds_read(struct file *file, char __user *buf,
719 user_info_t *user; 763 user_info_t *user;
720 int ret; 764 int ret;
721 765
722 ds_dbg(2, "ds_read(socket %d)\n", iminor(file->f_path.dentry->d_inode)); 766 pr_debug("ds_read(socket %d)\n", iminor(file->f_path.dentry->d_inode));
723 767
724 if (count < 4) 768 if (count < 4)
725 return -EINVAL; 769 return -EINVAL;
@@ -744,7 +788,7 @@ static ssize_t ds_read(struct file *file, char __user *buf,
744static ssize_t ds_write(struct file *file, const char __user *buf, 788static ssize_t ds_write(struct file *file, const char __user *buf,
745 size_t count, loff_t *ppos) 789 size_t count, loff_t *ppos)
746{ 790{
747 ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_path.dentry->d_inode)); 791 pr_debug("ds_write(socket %d)\n", iminor(file->f_path.dentry->d_inode));
748 792
749 if (count != 4) 793 if (count != 4)
750 return -EINVAL; 794 return -EINVAL;
@@ -762,7 +806,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)
762 struct pcmcia_socket *s; 806 struct pcmcia_socket *s;
763 user_info_t *user; 807 user_info_t *user;
764 808
765 ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_path.dentry->d_inode)); 809 pr_debug("ds_poll(socket %d)\n", iminor(file->f_path.dentry->d_inode));
766 810
767 user = file->private_data; 811 user = file->private_data;
768 if (CHECK_USER(user)) 812 if (CHECK_USER(user))
@@ -790,7 +834,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
790 ds_ioctl_arg_t *buf; 834 ds_ioctl_arg_t *buf;
791 user_info_t *user; 835 user_info_t *user;
792 836
793 ds_dbg(2, "ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg); 837 pr_debug("ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg);
794 838
795 user = file->private_data; 839 user = file->private_data;
796 if (CHECK_USER(user)) 840 if (CHECK_USER(user))
@@ -809,13 +853,13 @@ static int ds_ioctl(struct inode * inode, struct file * file,
809 853
810 if (cmd & IOC_IN) { 854 if (cmd & IOC_IN) {
811 if (!access_ok(VERIFY_READ, uarg, size)) { 855 if (!access_ok(VERIFY_READ, uarg, size)) {
812 ds_dbg(3, "ds_ioctl(): verify_read = %d\n", -EFAULT); 856 pr_debug("ds_ioctl(): verify_read = %d\n", -EFAULT);
813 return -EFAULT; 857 return -EFAULT;
814 } 858 }
815 } 859 }
816 if (cmd & IOC_OUT) { 860 if (cmd & IOC_OUT) {
817 if (!access_ok(VERIFY_WRITE, uarg, size)) { 861 if (!access_ok(VERIFY_WRITE, uarg, size)) {
818 ds_dbg(3, "ds_ioctl(): verify_write = %d\n", -EFAULT); 862 pr_debug("ds_ioctl(): verify_write = %d\n", -EFAULT);
819 return -EFAULT; 863 return -EFAULT;
820 } 864 }
821 } 865 }
@@ -927,15 +971,15 @@ static int ds_ioctl(struct inode * inode, struct file * file,
927 goto free_out; 971 goto free_out;
928 break; 972 break;
929 case DS_GET_FIRST_WINDOW: 973 case DS_GET_FIRST_WINDOW:
930 ret = pcmcia_get_window(s, &buf->win_info.handle, 0, 974 ret = pcmcia_get_window(s, &buf->win_info.handle, 1,
931 &buf->win_info.window); 975 &buf->win_info.window);
932 break; 976 break;
933 case DS_GET_NEXT_WINDOW: 977 case DS_GET_NEXT_WINDOW:
934 ret = pcmcia_get_window(s, &buf->win_info.handle, 978 ret = pcmcia_get_window(s, &buf->win_info.handle,
935 buf->win_info.handle->index + 1, &buf->win_info.window); 979 buf->win_info.handle + 1, &buf->win_info.window);
936 break; 980 break;
937 case DS_GET_MEM_PAGE: 981 case DS_GET_MEM_PAGE:
938 ret = pcmcia_get_mem_page(buf->win_info.handle, 982 ret = pcmcia_get_mem_page(s, buf->win_info.handle,
939 &buf->win_info.map); 983 &buf->win_info.map);
940 break; 984 break;
941 case DS_REPLACE_CIS: 985 case DS_REPLACE_CIS:
@@ -962,7 +1006,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
962 } 1006 }
963 1007
964 if ((err == 0) && (ret != 0)) { 1008 if ((err == 0) && (ret != 0)) {
965 ds_dbg(2, "ds_ioctl: ret = %d\n", ret); 1009 pr_debug("ds_ioctl: ret = %d\n", ret);
966 switch (ret) { 1010 switch (ret) {
967 case -ENODEV: 1011 case -ENODEV:
968 case -EINVAL: 1012 case -EINVAL: