[PLUG] PCI driver not writing to config space

Giriprasad Deviprasad g_pr21 at yahoo.in
Wed Jul 20 03:53:09 PDT 2011


Hi All,

 I have a pci driver like:

define VENDOR_ID 0x1415
#define DEVICE_ID1 0xc140

#include<linux/module.h>
#include<linux/version.h>
#include<linux/kernel.h>
#include<linux/pci.h>
#include<linux/ioport.h>
#include<asm/unistd.h>
#include<linux/slab.h>
#include<linux/fs.h>
#include<asm/uaccess.h>
#include<asm/io.h>
#include<linux/kdev_t.h>
#include<asm/fcntl.h>
#include<linux/sched.h>
#include<linux/wait.h>
#include<linux/errno.h>
#include<asm/irq.h>
#include<asm/ioctl.h>
#include<linux/string.h>
#include<linux/interrupt.h>

init_module (void)
{
        short int curr_device;


        dev = pci_find_device (VENDOR_ID, DEVICE_ID1, NULL);
        j = pci_enable_device (dev);
        curr_device = 0;
        printk("Init : Reading and writing Config space.........\n");
        pci_read_config_word (dev, 0x02, (u16 *)&curr_device);
        printk("Init : Current Device id = %x\n", (curr_device & 0x00FFFF));
        curr_device = 0xc145;
        pci_write_config_word (dev, 0x02, curr_device);
        pci_read_config_word (dev, 0x02, (u16 *)&curr_device);
        printk("Init : After writing to Config space, Current Device id = %x\n", (curr_device & 0x00FFFF));
        return 0;
}

        void
cleanup_module (void)
{
        printk ("Closing pci \n");
}

When I insmod this driver after build, it shows:
Jul 20 15:11:03 localhost kernel: Init : Reading and writing Config space.........
Jul 20 15:11:03 localhost kernel: Init : Current Device id = c140
Jul 20 15:11:03 localhost kernel: Init : After writing to Config space, Current Device id = c140

Any clues as to why is not writing 0xc145 to the pci config space?
        curr_device = 0xc145;
       pci_write_config_word (dev, 0x02, curr_device);

Thanks & Regards,
D.Giriprasad




More information about the plug-mail mailing list