From: Aivils S. <ai...@us...> - 2004-04-30 09:32:56
|
Update of /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/pci In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27884/drivers/pci Modified Files: proc.c Log Message: fix forgotten drivers-pci-proc Index: proc.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/pci/proc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- proc.c 5 Feb 2004 11:53:56 -0000 1.2 +++ proc.c 30 Apr 2004 09:32:47 -0000 1.3 @@ -16,15 +16,13 @@ #include <asm/uaccess.h> #include <asm/byteorder.h> -#define PCI_CFG_SPACE_SIZE 256 - static int proc_initialized; /* = 0 */ //from xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h -#define PCI_CMD_STAT_REG 0x04 -#define PCI_CMD_IO_ENABLE 0x01 -#define PCI_CMD_MEM_ENABLE 0x02 -#define PCI_CMD_MASTER_ENABLE 0x04 +#define PCI_CMD_STAT_REG 0x04 +#define PCI_CMD_IO_ENABLE 0x01 +#define PCI_CMD_MEM_ENABLE 0x02 +#define PCI_CMD_MASTER_ENABLE 0x04 static int pci_hackvideo=0; @@ -32,8 +30,9 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence) { loff_t new = -1; + struct inode *inode = file->f_dentry->d_inode; - down(&file->f_dentry->d_inode->i_sem); + down(&inode->i_sem); switch (whence) { case 0: new = off; @@ -42,15 +41,15 @@ new = file->f_pos + off; break; case 2: - new = PCI_CFG_SPACE_SIZE + off; + new = inode->i_size + off; break; } - if (new < 0 || new > PCI_CFG_SPACE_SIZE) - new = -EINVAL; - else - file->f_pos = new; - up(&file->f_dentry->d_inode->i_sem); - return new; + if (new < 0 || new > inode->i_size) + new = -EINVAL; + else + file->f_pos = new; + up(&inode->i_sem); + return new; } static ssize_t @@ -69,7 +68,7 @@ */ if (capable(CAP_SYS_ADMIN)) - size = PCI_CFG_SPACE_SIZE; + size = dev->cfg_size; else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) size = 128; else @@ -142,20 +141,21 @@ const struct proc_dir_entry *dp = PDE(ino); struct pci_dev *dev = dp->data; int pos = *ppos; + int size = dev->cfg_size; int cnt; - if (pci_hackvideo && (pos == PCI_CMD_STAT_REG) && - (buf[0] <= PCI_CMD_MASTER_ENABLE) && - ((dev->class>>8) == 0x0300 || - (dev->class>>8) == 0x0400 || - (dev->class>>8) == 0x0000 ) ) - return -EINVAL; - if (pos >= PCI_CFG_SPACE_SIZE) + if (pci_hackvideo && (pos == PCI_CMD_STAT_REG) && + (buf[0] <= PCI_CMD_MASTER_ENABLE) && + ((dev->class>>8) == 0x0300 || + (dev->class>>8) == 0x0400 || + (dev->class>>8) == 0x0000 ) ) + return -EINVAL; + if (pos >= size) return 0; - if (nbytes >= PCI_CFG_SPACE_SIZE) - nbytes = PCI_CFG_SPACE_SIZE; - if (pos + nbytes > PCI_CFG_SPACE_SIZE) - nbytes = PCI_CFG_SPACE_SIZE - pos; + if (nbytes >= size) + nbytes = size; + if (pos + nbytes > size) + nbytes = size - pos; cnt = nbytes; if (!access_ok(VERIFY_READ, buf, cnt)) @@ -417,7 +417,7 @@ return -ENOMEM; e->proc_fops = &proc_bus_pci_operations; e->data = dev; - e->size = PCI_CFG_SPACE_SIZE; + e->size = dev->cfg_size; return 0; } |