[PATCH] briq_panel: read() and write() get __user pointers, damnit
[linux-2.6/verdex.git] / arch / mips / kernel / irixinv.c
blobde8584f623113556166d7756cc06b97ecd424eae
1 /*
2 * Support the inventory interface for IRIX binaries
3 * This is invoked before the mm layer is working, so we do not
4 * use the linked lists for the inventory yet.
6 * Miguel de Icaza, 1997.
7 */
8 #include <linux/mm.h>
9 #include <asm/inventory.h>
10 #include <asm/uaccess.h>
12 #define MAX_INVENTORY 50
13 int inventory_items = 0;
15 static inventory_t inventory [MAX_INVENTORY];
17 void add_to_inventory (int class, int type, int controller, int unit, int state)
19 inventory_t *ni = &inventory [inventory_items];
21 if (inventory_items == MAX_INVENTORY)
22 return;
24 ni->inv_class = class;
25 ni->inv_type = type;
26 ni->inv_controller = controller;
27 ni->inv_unit = unit;
28 ni->inv_state = state;
29 ni->inv_next = ni;
30 inventory_items++;
33 int dump_inventory_to_user (void __user *userbuf, int size)
35 inventory_t *inv = &inventory [0];
36 inventory_t __user *user = userbuf;
37 int v;
39 if (!access_ok(VERIFY_WRITE, userbuf, size))
40 return -EFAULT;
42 for (v = 0; v < inventory_items; v++){
43 inv = &inventory [v];
44 if (copy_to_user (user, inv, sizeof (inventory_t)))
45 return -EFAULT;
46 user++;
48 return inventory_items * sizeof (inventory_t);
51 int __init init_inventory(void)
54 * gross hack while we put the right bits all over the kernel
55 * most likely this will not let just anyone run the X server
56 * until we put the right values all over the place
58 add_to_inventory (10, 3, 0, 0, 16400);
59 add_to_inventory (1, 1, 150, -1, 12);
60 add_to_inventory (1, 3, 0, 0, 8976);
61 add_to_inventory (1, 2, 0, 0, 8976);
62 add_to_inventory (4, 8, 0, 0, 2);
63 add_to_inventory (5, 5, 0, 0, 1);
64 add_to_inventory (3, 3, 0, 0, 32768);
65 add_to_inventory (3, 4, 0, 0, 32768);
66 add_to_inventory (3, 8, 0, 0, 524288);
67 add_to_inventory (3, 9, 0, 0, 64);
68 add_to_inventory (3, 1, 0, 0, 67108864);
69 add_to_inventory (12, 3, 0, 0, 16);
70 add_to_inventory (8, 7, 17, 0, 16777472);
71 add_to_inventory (8, 0, 0, 0, 1);
72 add_to_inventory (2, 1, 0, 13, 2);
73 add_to_inventory (2, 2, 0, 2, 0);
74 add_to_inventory (2, 2, 0, 1, 0);
75 add_to_inventory (7, 14, 0, 0, 6);
77 return 0;