equal
deleted
inserted
replaced
172 static int me8100_read_icsr(unsigned char *, me8100_info_type *); |
172 static int me8100_read_icsr(unsigned char *, me8100_info_type *); |
173 static int me8100_get_board_info(me8100_info_type *, me8100_info_type *); |
173 static int me8100_get_board_info(me8100_info_type *, me8100_info_type *); |
174 static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_type *); |
174 static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_type *); |
175 |
175 |
176 static inline int DEVICE(int i) { return i & 0x0f; } |
176 static inline int DEVICE(int i) { return i & 0x0f; } |
177 static inline int SUBDEVICE(int i) { return i >> 4; } |
177 static inline int SUBDEVICE(int i) { return (i >> 4) - 1; } |
178 |
178 |
179 |
179 |
180 /* File operations provided by the driver */ |
180 /* File operations provided by the driver */ |
181 static struct file_operations me8100_file_operations = { |
181 static struct file_operations me8100_file_operations = { |
182 #ifdef LINUX_24 |
182 #ifdef LINUX_24 |
608 subinfo->ctrl_reg |= ME8100_CTRL_ENIO | ME8100_CTRL_SOURCE; |
608 subinfo->ctrl_reg |= ME8100_CTRL_ENIO | ME8100_CTRL_SOURCE; |
609 PDEBUG("*** setting ENIO+SOURCE mode: ctrl: 0x%x\n", subinfo->ctrl_reg); |
609 PDEBUG("*** setting ENIO+SOURCE mode: ctrl: 0x%x\n", subinfo->ctrl_reg); |
610 outw(subinfo->ctrl_reg, subinfo->regbase + ME8100_CTRL_REG); |
610 outw(subinfo->ctrl_reg, subinfo->regbase + ME8100_CTRL_REG); |
611 } |
611 } |
612 } |
612 } |
|
613 |
|
614 if (file_ptr->f_mode & FMODE_READ) { |
|
615 PDEBUG("*** open for reading\n"); |
|
616 } |
613 |
617 |
614 MOD_INC_USE_COUNT; |
618 MOD_INC_USE_COUNT; |
615 |
619 |
616 return 0; |
620 return 0; |
617 } |
621 } |
2109 } |
2113 } |
2110 } |
2114 } |
2111 |
2115 |
2112 ssize_t me8100_read(struct file * file_ptr, char *buffer, size_t len, loff_t *offset) |
2116 ssize_t me8100_read(struct file * file_ptr, char *buffer, size_t len, loff_t *offset) |
2113 { |
2117 { |
|
2118 int err; |
|
2119 unsigned short val; |
|
2120 int minor; |
|
2121 |
2114 PDEBUG("me8100_read(%d) called\n", len); |
2122 PDEBUG("me8100_read(%d) called\n", len); |
2115 return -EINVAL; |
2123 |
|
2124 minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev); |
|
2125 |
|
2126 if (len == 0) return 0; /* do we really need this check? */ |
|
2127 if (len < 0) return -EINVAL; /* do we really need this check? */ |
|
2128 |
|
2129 val = inw(info_vec[DEVICE(minor)].subinfo[SUBDEVICE(minor)].regbase + ME8100_DI_REG); |
|
2130 PDEBUG("me8100_read: val=0x%0x\n", val); |
|
2131 |
|
2132 if (len >= sizeof(val)) { |
|
2133 err = put_user(val, (unsigned short*) buffer); |
|
2134 len = sizeof(val); |
|
2135 } else { |
|
2136 err = put_user(val, (char*) buffer); |
|
2137 } |
|
2138 |
|
2139 return len; |
|
2140 |
2116 } |
2141 } |
2117 |
2142 |
2118 /* Writing: we do only write one word (an unsigned short) and return immediatly. Yes, |
2143 /* Writing: we do only write one word (an unsigned short) and return immediatly. Yes, |
2119 * we could loop over the complete buffer, but it's not expected to get more data |
2144 * we could loop over the complete buffer, but it's not expected to get more data |
2120 * than one word. If there's more output, the responsibility is transferred back |
2145 * than one word. If there's more output, the responsibility is transferred back |
2131 |
2156 |
2132 if (len == 0) return 0; /* do we need this? */ |
2157 if (len == 0) return 0; /* do we need this? */ |
2133 if (len < 0) return -EINVAL; /* do we need this? */ |
2158 if (len < 0) return -EINVAL; /* do we need this? */ |
2134 |
2159 |
2135 /* Take care of "short" writes! */ |
2160 /* Take care of "short" writes! */ |
2136 if (len >= sizeof(unsigned short)) { |
2161 if (len >= sizeof(val)) { |
2137 err = get_user(val, (unsigned short*) buffer); |
2162 err = get_user(val, (unsigned short*) buffer); |
2138 len = sizeof(unsigned short); |
2163 len = sizeof(val); |
2139 } else { |
2164 } else { |
2140 err = get_user(val, (char*) buffer); |
2165 err = get_user(val, (char*) buffer); |
2141 val &= 0xff; |
2166 val &= 0xff; |
2142 } |
2167 } |
2143 |
2168 |