I'm writing a device driver, and using the
2.3.99-pre5 kernel. The device I am using
can be programmed to respond to memory addresses
other than the configuration address, so I need
to be able to map the device to an address range,
and it seemed to me that pci_assign_resource is
the perfect way to get an address range.
However, I'm having some problems. I perform
the call, and it seems to work fine. I can
look in /proc/iomem and see the area mapped there.
When I unload the driver, the real trouble starts.
After the unload, I cat /proc/iomem, and get
a Segmentation Violation.
Below is a sample that shows the
problem. Could someone
verify that I am doing this right, and that
there really is a bug somewhere else in the
kernel (I think that is what is going on)?
If I'm not doing it right, what is the right
way to go about this?
I noticed that there is only one driver in
the development distribution that uses this
call, and I don't have the hardware to see if
it exhibits this bug.
Thanks,
S. Baker
bakers@erols.com
#define MODULE
#define __KERNEL__
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/init.h>
#define U_DRIVER_NAME "udriver"
module_init(u_init_module);
module_exit(u_exit_module);
static struct pci_device_id u_pci_tbl[]
__devinitdata =
{
{PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
0, 0, 0 },
{0, },
};
MODULE_DEVICE_TABLE (pci, u_pci_tbl);
static void __devexit u_remove(struct pci_dev
*pdev)
{
}
static int __devinit u_probe(struct pci_dev *pdev,
const struct
pci_device_id *ent)
{
pdev->resource[7].name = U_DRIVER_NAME;
pdev->resource[7].start = 0;
pdev->resource[7].end = 256*1024*1024;
pdev->resource[7].flags = IORESOURCE_MEM;
if (pci_assign_resource(pdev, 7) != 0)
{
printk(KERN_ERR "cannot obtain resource\n");
return -ENODEV;
}
return 0;
}
static struct pci_driver u_driver =
{
name: U_DRIVER_NAME,
id_table: u_pci_tbl,
probe: u_probe,
remove: u_remove,
};
static int __devinit u_init_module(void)
{
if (pci_register_driver(&u_driver) > 0)
return 0;
pci_unregister_driver(&u_driver);
return -ENODEV;
}
static void __exit u_exit_module(void)
{
pci_unregister_driver(&u_driver);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:22 EST