--- a/me8100.c Thu Jan 24 18:53:47 2002 +0100
+++ b/me8100.c Fri Jan 25 16:55:00 2002 +0100
@@ -3,6 +3,7 @@
* ========================================
*
* Copyright (C) 2001 Meilhaus Electronic GmbH (support@meilhaus.de)
+ * Portions Copyright (C) 2002 Heiko Schlittermann <hs@schlittermann.de>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -115,7 +116,7 @@
/* Board specific data are kept global */
-static me8100_info_type info_vec[SORT_COUNT * ME8100_MAX_DEVICES];
+static me8100_info_t info_vec[SORT_COUNT * ME8100_MAX_DEVICES];
/* Number of boards, detected from the BIOS */
@@ -136,42 +137,42 @@
static ssize_t me8100_write(struct file *, const char *, size_t, loff_t *);
static unsigned int me8100_poll(struct file *, struct poll_table_struct *);
-static int me8100_init_board(me8100_info_type *, struct pci_dev *);
-static int me8100_reset_board(me8100_info_type *);
+static int me8100_init_board(me8100_info_t *, struct pci_dev *);
+static int me8100_reset_board(me8100_info_t *);
-static int me8100_read_id_a(unsigned short *, me8100_info_type *);
-static int me8100_write_ctrl_a(unsigned short *, me8100_info_type *);
-static int me8100_res_int_a(me8100_info_type *);
-static int me8100_read_di_a(unsigned short *, me8100_info_type *);
-static int me8100_write_do_a(unsigned short *, me8100_info_type *);
-static int me8100_write_pattern_a(unsigned short *, me8100_info_type *);
-static int me8100_write_mask_a(unsigned short *, me8100_info_type *);
-static int me8100_read_int_di_a(unsigned short *, me8100_info_type *);
+static int me8100_read_id_a(unsigned short *, me8100_info_t *);
+static int me8100_write_ctrl_a(unsigned short *, me8100_info_t *);
+static int me8100_res_int_a(me8100_info_t *);
+static int me8100_read_di_a(unsigned short *, me8100_info_t *);
+static int me8100_write_do_a(unsigned short *, me8100_info_t *);
+static int me8100_write_pattern_a(unsigned short *, me8100_info_t *);
+static int me8100_write_mask_a(unsigned short *, me8100_info_t *);
+static int me8100_read_int_di_a(unsigned short *, me8100_info_t *);
-static int me8100_read_id_b(unsigned short *, me8100_info_type *);
-static int me8100_write_ctrl_b(unsigned short *, me8100_info_type *);
-static int me8100_res_int_b(me8100_info_type *);
-static int me8100_read_di_b(unsigned short *, me8100_info_type *);
-static int me8100_write_do_b(unsigned short *, me8100_info_type *);
-static int me8100_write_pattern_b(unsigned short *, me8100_info_type *);
-static int me8100_write_mask_b(unsigned short *, me8100_info_type *);
-static int me8100_read_int_di_b(unsigned short *, me8100_info_type *);
+static int me8100_read_id_b(unsigned short *, me8100_info_t *);
+static int me8100_write_ctrl_b(unsigned short *, me8100_info_t *);
+static int me8100_res_int_b(me8100_info_t *);
+static int me8100_read_di_b(unsigned short *, me8100_info_t *);
+static int me8100_write_do_b(unsigned short *, me8100_info_t *);
+static int me8100_write_pattern_b(unsigned short *, me8100_info_t *);
+static int me8100_write_mask_b(unsigned short *, me8100_info_t *);
+static int me8100_read_int_di_b(unsigned short *, me8100_info_t *);
-static int me8100_write_counter_0(unsigned char *, me8100_info_type *);
-static int me8100_write_counter_1(unsigned char *, me8100_info_type *);
-static int me8100_write_counter_2(unsigned char *, me8100_info_type *);
-static int me8100_read_counter_0(unsigned char *, me8100_info_type *);
-static int me8100_read_counter_1(unsigned char *, me8100_info_type *);
-static int me8100_read_counter_2(unsigned char *, me8100_info_type *);
-static int me8100_setup_counter(unsigned char *, me8100_info_type *);
+static int me8100_write_counter_0(unsigned char *, me8100_info_t *);
+static int me8100_write_counter_1(unsigned char *, me8100_info_t *);
+static int me8100_write_counter_2(unsigned char *, me8100_info_t *);
+static int me8100_read_counter_0(unsigned char *, me8100_info_t *);
+static int me8100_read_counter_1(unsigned char *, me8100_info_t *);
+static int me8100_read_counter_2(unsigned char *, me8100_info_t *);
+static int me8100_setup_counter(unsigned char *, me8100_info_t *);
-static int me8100_get_serial(unsigned int *, me8100_info_type *);
-static int me8100_get_name(me8100_version_enum_type *, me8100_info_type *);
-static int me8100_int_occur(me8100_int_occur_type *, me8100_info_type *);
-static int me8100_setup_icsr(unsigned char *, me8100_info_type *);
-static int me8100_read_icsr(unsigned char *, me8100_info_type *);
-static int me8100_get_board_info(me8100_info_type *, me8100_info_type *);
-static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_type *);
+static int me8100_get_serial(unsigned int *, me8100_info_t *);
+static int me8100_get_name(me8100_version_enum_type *, me8100_info_t *);
+static int me8100_int_occur(me8100_int_occur_type *, me8100_info_t *);
+static int me8100_setup_icsr(unsigned char *, me8100_info_t *);
+static int me8100_read_icsr(unsigned char *, me8100_info_t *);
+static int me8100_get_board_info(me8100_info_t *, me8100_info_t *);
+static int me8100_get_int_count(me8100_int_occur_type *, me8100_info_t *);
static inline int DEVICE(int i) { return i & 0x0f; }
static inline int SUBDEVICE(int i) { return (i >> 4) - 1; }
@@ -326,7 +327,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *pci_dev_ptr struct pci_dev read List with all pci devices.
- * *info me8100_info_type read Global board context.
+ * *info me8100_info_t read Global board context.
*
* Result:
* On success the return value is 0, else failure.
@@ -338,7 +339,7 @@
* for compatibility. (GG)
*
*/
-static int me8100_init_board(me8100_info_type *info,
+static int me8100_init_board(me8100_info_t *info,
struct pci_dev *pci_dev_ptr){
int i;
int result = 0;
@@ -480,7 +481,7 @@
info->subinfo[0].regbase = info->me8100_regbase;
info->subinfo[1].regbase = info->me8100_regbase + 0x0C;
- for (i = 0; i <= 1; ++i) {
+ for (i = 0; i < MAX_SUBDEVICES; ++i) {
info->subinfo[i].int_seen = jiffies; /* suppose we got just the first irq */
info->subinfo[i].fasync_ptr = NULL;
init_waitqueue_head(&info->subinfo[i].readq);
@@ -529,7 +530,7 @@
* Author: GG
* Modification:
*/
-static int me8100_reset_board(me8100_info_type *info){
+static int me8100_reset_board(me8100_info_t *info){
int i;
unsigned char icsr = 0x12;
@@ -539,7 +540,7 @@
PDEBUG("me8100_reset_board(): plx_mode = 0x%X\n", icsr);
outb(icsr, info->plx_regbase + PLX_ICSR);
- for (i = 0; i <= 1; ++i) {
+ for (i = 0; i < MAX_SUBDEVICES; ++i) {
/* Ports to high impedance, interrupts deactivated */
outw(0x00, info->subinfo[i].regbase + ME8100_CTRL_REG);
/* Reset any pending interrupt */
@@ -574,28 +575,39 @@
*/
static int me8100_open(struct inode *inode_ptr, struct file *file_ptr){
int device, subdevice;
- me8100_info_type *info;
- struct me8100_subinfo *subinfo;
+ me8100_info_t *info;
+ me8100_subinfo_t *subinfo;
+ me8100_private_data_t *priv;
- PDEBUG("*** me8100_open() is executed\n");
device = DEVICE(MINOR(inode_ptr->i_rdev));
subdevice = SUBDEVICE(MINOR(inode_ptr->i_rdev));
- PDEBUG("*** device: %d, subdevice %d with flags %0x\n", device, subdevice, file_ptr->f_flags);
+
+ PDEBUG("me8100_open() device: %d.%d\n", device, subdevice);
if(device >= me8100_board_count){
printk(KERN_ERR"ME8100:me8100_open():Board %d doesn't exist\n", device);
return -ENODEV;
}
- /* Currently we can't support the old style minor numbers. */
+ /* Currently we can't support the old style minor numbers. .hs */
if (subdevice < 0) {
- printk(KERN_ERR "ME8100:me8100_open(): Bad subdevice %d\n", subdevice);
+ printk(KERN_ERR "ME8100:me8100_open(): Bad device %d.%d\n", device, subdevice);
return -ENODEV;
}
+ if (NULL == (priv = kmalloc(sizeof(*priv), GFP_KERNEL))) {
+ printk(KERN_ERR "ME8100: me8100_open(): kmalloc() failed\n");
+ return -EIO;
+ }
+ file_ptr->private_data = priv;
+
+ memset(priv, 0, sizeof(*priv));
+
info = &info_vec[device];
subinfo = &info->subinfo[subdevice];
+ priv->info = info;
+ priv->subinfo = subinfo;
MOD_INC_USE_COUNT;
@@ -622,22 +634,8 @@
* pointer passed. We need this to keep track of timestamps for
* read data. */
- struct me8100_private_data *priv;
-
PDEBUG("*** open for reading\n");
- /* Allocate memory for the private data. If allocating fails,
- * call m8100_release() (which in turn decrements the mod-in-use-count)
- * and return IO error. */
- if (NULL == (priv = kmalloc(sizeof(*priv), GFP_KERNEL))) {
- printk(KERN_ERR"ME8100:me8100_open: kmalloc() failed.\n");
- me8100_release(inode_ptr, file_ptr);
- return -EIO;
- }
-
- priv->last_read = 0;
- file_ptr->private_data = priv;
-
/* The first reader should setup the IRQs (enabling IRQ handling
* with the full bit mask. It might be modified later. */
if (0 == subinfo->num_reader++) {
@@ -702,15 +700,12 @@
static int me8100_release(struct inode *inode_ptr, struct file *file_ptr){
int device;
int err;
- me8100_info_type *info;
- struct me8100_subinfo* subinfo;
+ me8100_info_t *info = ((me8100_private_data_t*)file_ptr->private_data)->info;
+ me8100_subinfo_t* subinfo = ((me8100_private_data_t*)file_ptr->private_data)->subinfo;
- PDEBUG("me8100_release() is executed\n");
-
+ PDEBUG("me8100_release()\n");
device = DEVICE(MINOR(inode_ptr->i_rdev));
- info = &info_vec[device];
- subinfo = &info->subinfo[SUBDEVICE(MINOR(inode_ptr->i_rdev))];
/* Resetting write mode if last writer is gone */
if (file_ptr->f_mode & FMODE_WRITE) {
@@ -870,7 +865,7 @@
case ME8100_READ_ICSR:
return me8100_read_icsr((unsigned char *) arg, &info_vec[device]);
case ME8100_GET_BOARD_INFO:
- return me8100_get_board_info((me8100_info_type *)arg, &info_vec[device]);
+ return me8100_get_board_info((me8100_info_t *)arg, &info_vec[device]);
case ME8100_GET_INT_COUNT:
return me8100_get_int_count((me8100_int_occur_type *)arg,&info_vec[device]);
default:
@@ -909,21 +904,12 @@
* Modufication:
*/
static int me8100_fasync(int fd, struct file *file_ptr, int mode){
- int val;
- int device, subdevice;
- me8100_info_type *info;
- struct me8100_subinfo *subinfo;
+ me8100_subinfo_t *subinfo;
- device = DEVICE(MINOR(file_ptr->f_dentry->d_inode->i_rdev));
- subdevice = SUBDEVICE(MINOR(file_ptr->f_dentry->d_inode->i_rdev));
- info = &info_vec[device];
- subinfo = &info_vec[device].subinfo[subdevice];
+ subinfo = ((me8100_private_data_t*) file_ptr->private_data)->subinfo;
- PDEBUG("me8100_fasync() is executed\n");
- PDEBUG("** fasync_ptr: %p\n", subinfo->fasync_ptr);
- val = fasync_helper(fd, file_ptr, mode, &subinfo->fasync_ptr);
- PDEBUG("** fasync_ptr: %p\n", subinfo->fasync_ptr);
- return val;
+ PDEBUG("me8100_fasync()\n");
+ return fasync_helper(fd, file_ptr, mode, &subinfo->fasync_ptr);
}
@@ -938,8 +924,8 @@
* Parameter list:
* Name Type Access Description
*--------------------------------------------------------------------------
- * *arg me8100_info_type w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *arg me8100_info_t w Carries the value to user.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -947,12 +933,12 @@
* Author: GG
* Modification:
*/
-static int me8100_get_board_info(me8100_info_type *arg,
- me8100_info_type *info){
+static int me8100_get_board_info(me8100_info_t *arg,
+ me8100_info_t *info){
PDEBUG("me8100_get_board_info() is executed\n");
- if(copy_to_user(arg, info, sizeof(me8100_info_type)))
+ if(copy_to_user(arg, info, sizeof(me8100_info_t)))
return -EFAULT;
return 0;
}
@@ -972,7 +958,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -980,7 +966,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_id_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_id_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short id_a;
@@ -1010,7 +996,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1018,7 +1004,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_ctrl_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_ctrl_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short ctrl_a = 0;
@@ -1049,7 +1035,7 @@
* Parameter list:
* Name Type Access Description
*--------------------------------------------------------------------------
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1057,7 +1043,7 @@
* Author: GG
* Modification:
*/
-static int me8100_res_int_a(me8100_info_type *info){
+static int me8100_res_int_a(me8100_info_t *info){
PDEBUG("me8100_res_int_a() is executed\n");
@@ -1081,7 +1067,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1089,7 +1075,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_di_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_di_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short di_a;
@@ -1118,7 +1104,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure
@@ -1126,7 +1112,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_do_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_do_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short do_a = 0;
@@ -1155,7 +1141,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1163,7 +1149,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_pattern_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_pattern_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short pattern_a = 0;
@@ -1195,7 +1181,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1203,7 +1189,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_mask_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_mask_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short mask_a = 0;
@@ -1236,7 +1222,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1244,7 +1230,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_int_di_a(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_int_di_a(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short int_di_a;
@@ -1275,7 +1261,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1283,7 +1269,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_id_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_id_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short id_b;
@@ -1321,7 +1307,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_ctrl_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_ctrl_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short ctrl_b = 0;
@@ -1352,7 +1338,7 @@
* Parameter list:
* Name Type Access Description
*--------------------------------------------------------------------------
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1360,7 +1346,7 @@
* Author: GG
* Modification:
*/
-static int me8100_res_int_b(me8100_info_type *info){
+static int me8100_res_int_b(me8100_info_t *info){
PDEBUG("me8100_res_int_b() is executed\n");
inw(info->me8100_regbase + ME8100_RES_INT_REG_B);
@@ -1383,7 +1369,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1391,7 +1377,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_di_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_di_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short di_b;
@@ -1420,7 +1406,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1428,7 +1414,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_do_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_do_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short do_b = 0;
@@ -1459,7 +1445,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1467,7 +1453,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_pattern_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_pattern_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short pattern_b = 0;
@@ -1499,7 +1485,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1507,7 +1493,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_mask_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_write_mask_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short mask_b = 0;
@@ -1540,7 +1526,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned short w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1548,7 +1534,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_int_di_b(unsigned short *arg, me8100_info_type *info){
+static int me8100_read_int_di_b(unsigned short *arg, me8100_info_t *info){
int err = 0;
unsigned short int_di_b;
@@ -1579,7 +1565,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1587,7 +1573,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_counter_0(unsigned char *arg, me8100_info_type *info){
+static int me8100_write_counter_0(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value = 0;
@@ -1621,7 +1607,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1629,7 +1615,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_counter_1(unsigned char *arg, me8100_info_type *info){
+static int me8100_write_counter_1(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value = 0;
@@ -1663,7 +1649,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1671,7 +1657,7 @@
* Author: GG
* Modification:
*/
-static int me8100_write_counter_2(unsigned char *arg, me8100_info_type *info){
+static int me8100_write_counter_2(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value = 0;
@@ -1704,7 +1690,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1712,7 +1698,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_counter_0(unsigned char *arg, me8100_info_type *info){
+static int me8100_read_counter_0(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value;
@@ -1742,7 +1728,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1750,7 +1736,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_counter_1(unsigned char *arg, me8100_info_type *info){
+static int me8100_read_counter_1(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value;
@@ -1788,7 +1774,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_counter_2(unsigned char *arg, me8100_info_type *info){
+static int me8100_read_counter_2(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value;
@@ -1816,7 +1802,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1824,7 +1810,7 @@
* Author: GG
* Modification:
*/
-static int me8100_setup_counter(unsigned char *arg, me8100_info_type *info){
+static int me8100_setup_counter(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value = 0;
@@ -1856,7 +1842,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned int w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1864,7 +1850,7 @@
* Author: GG
* Modification:
*/
-static int me8100_get_serial(unsigned int *arg, me8100_info_type *info){
+static int me8100_get_serial(unsigned int *arg, me8100_info_t *info){
int err = 0;
unsigned int value;
@@ -1893,7 +1879,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned int w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1901,7 +1887,7 @@
* Author: GG
* Modification:
*/
-static int me8100_get_name(me8100_version_enum_type *arg, me8100_info_type *info){
+static int me8100_get_name(me8100_version_enum_type *arg, me8100_info_t *info){
int err = 0;
unsigned int value;
@@ -1930,7 +1916,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg me8100_int_occur_type w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1938,7 +1924,7 @@
* Author: GG
* Modification:
*/
-static int me8100_int_occur(me8100_int_occur_type *arg, me8100_info_type *info){
+static int me8100_int_occur(me8100_int_occur_type *arg, me8100_info_t *info){
int err = 0;
unsigned long flags;
me8100_int_occur_type int_occur;
@@ -1972,7 +1958,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char r Carries the value from user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -1980,7 +1966,7 @@
* Author: GG
* Modification:
*/
-static int me8100_setup_icsr(unsigned char *arg, me8100_info_type *info){
+static int me8100_setup_icsr(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value = 0;
@@ -2012,7 +1998,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg unsigned char w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -2020,7 +2006,7 @@
* Author: GG
* Modification:
*/
-static int me8100_read_icsr(unsigned char *arg, me8100_info_type *info){
+static int me8100_read_icsr(unsigned char *arg, me8100_info_t *info){
int err = 0;
unsigned char value;
@@ -2048,7 +2034,7 @@
* Name Type Access Description
*--------------------------------------------------------------------------
* *arg int w Carries the value to user.
- * *info me8100_info_type r Global board context.
+ * *info me8100_info_t r Global board context.
*
* Result:
* On success the return value is 0, else is failure.
@@ -2057,7 +2043,7 @@
* Modification:
*/
static int me8100_get_int_count(me8100_int_occur_type *arg,
- me8100_info_type *info){
+ me8100_info_t *info){
me8100_int_occur_type int_count;
unsigned long flags;
@@ -2107,16 +2093,15 @@
static void me8100_isr(int irq, void *dev_id, struct pt_regs *regs){
int i;
unsigned char icsr;
- me8100_info_type *info;
+ me8100_info_t *info;
- /* A: 0x04 & 0x40 & 0x01 */
- /* B: 0x20 & 0x40 & 0x08 */
+ /* A: 0x04 & 0x40 & 0x01 for irq at port A */
+ /* B: 0x20 & 0x40 & 0x08 for irq at port B */
unsigned short icsr_mask[] = { 0x45, 0x68 };
- info = (me8100_info_type *) dev_id;
+ info = (me8100_info_t *) dev_id;
- PDEBUG("=====> me8100_isr() is executed\n");
-
+ PDEBUG("INT: me8100_isr()\n");
if(irq != info->int_line){
PDEBUG("me8100_isr():incorrect interrupt num: %d\n", irq);
@@ -2125,16 +2110,16 @@
icsr = inb(info->plx_regbase + PLX_ICSR);
- PDEBUG("== ICSR: 0x%04x\n", icsr);
+ PDEBUG("ICSR: 0x%04x\n", icsr);
/* We got an interrupt. Now try each possible subdevice in turn.
- * (There is the possibility that all subdevices raised an intterupt
+ * (There is the possibility that all subdevices raised an interupt
* at the same time. I don't know how this is resolved by the board.
* So we've to try each subdevice in turn.) */
- for (i = 0; i <= 1; ++i) {
+ for (i = 0; i < MAX_SUBDEVICES; ++i) {
if ((icsr & icsr_mask[i]) == icsr_mask[i]) {
- struct me8100_subinfo *subinfo = &info->subinfo[i];
+ me8100_subinfo_t *subinfo = &info->subinfo[i];
subinfo->int_seen = jiffies;
++subinfo->int_count;
@@ -2205,16 +2190,14 @@
{
int err;
unsigned short val;
- int minor;
- struct me8100_private_data *priv;
- struct me8100_subinfo *subinfo;
+ me8100_subinfo_t *subinfo;
+ me8100_private_data_t *priv;
- PDEBUG("me8100_read() called\n");
+ priv = file_ptr->private_data;
+ subinfo = priv->subinfo;
- minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
- subinfo = &info_vec[DEVICE(minor)].subinfo[SUBDEVICE(minor)];
- priv = file_ptr->private_data;
-
+ PDEBUG("me8100_read()\n");
+
if (len == 0) return 0; /* do we really need this check? */
if (len < 0) return -EINVAL; /* do we really need this check? */
@@ -2265,9 +2248,10 @@
{
int err;
unsigned short val;
- int minor;
-
- minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
+ me8100_subinfo_t *subinfo;
+
+ subinfo = ((me8100_private_data_t*) file_ptr->private_data)->subinfo;
+
PDEBUG("me8100_write(%d) called\n", len);
if (len == 0) return 0; /* do we need this? */
@@ -2285,21 +2269,21 @@
if (err) return err;
PDEBUG("*** me8100_write: val=0x%04x\n", val);
- outw(val, info_vec[DEVICE(minor)].subinfo[SUBDEVICE(minor)].regbase + ME8100_DO_REG);
+ outw(val, subinfo->regbase + ME8100_DO_REG);
return len;
}
static unsigned int me8100_poll(struct file *file_ptr, struct poll_table_struct *wait)
{
- int minor = MINOR(file_ptr->f_dentry->d_inode->i_rdev);
- me8100_info_type *info = &info_vec[DEVICE(minor)];
- struct me8100_subinfo *subinfo = &info->subinfo[SUBDEVICE(minor)];
- struct me8100_private_data *priv = file_ptr->private_data;
+ me8100_private_data_t *priv;
+ me8100_subinfo_t *subinfo;
- PDEBUG("*** me8100_poll()\n");
+ priv = file_ptr->private_data;
+ subinfo = priv->subinfo;
+
+ PDEBUG("me8100_poll()\n");
poll_wait(file_ptr, &subinfo->readq, wait);
- PDEBUG("*** me8100_poll()\n");
if (priv->last_read >= subinfo->int_seen) return 0;
return POLLIN | POLLRDNORM;