Re: PCI driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jiri Slaby wrote:
Manu Abraham napsal(a):

Jiri Slaby wrote:

Manu Abraham napsal(a):

Jiri Slaby wrote:

you do NOT do this at all, because you have pdev already (the param of the probe function)


I rewrote the entire thing like this including the pci_remove function too, but now it so seems that in the remove function, pci_get_drvdata(pdev) returns NULL, and hence i get an Oops at module removal.



Maybe because this is badly written driver.



I have not written the driver, but this is my first go at it ..


static int mantis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *mantis_pci_table)
{
    struct mantis_pci *mantis;
    struct mantis_eeprom eeprom;
    u8 revision, latency;
u8 data[2]; if (pci_enable_device(pdev)) { dprintk(verbose, MANTIS_DEBUG, 1, "Found a mantis chip"); if ((mantis = (struct mantis_pci *) kmalloc(sizeof (struct mantis_pci), GFP_KERNEL)) == NULL) {
            dprintk(verbose, MANTIS_ERROR, 1, "Out of memory");
            return -ENOMEM;
        }
        pci_set_master(pdev);
        mantis->mantis_addr = pci_resource_start(pdev, 0);
        if (!request_mem_region(pci_resource_start(pdev, 0),
            pci_resource_len(pdev, 0), DRIVER_NAME)) {
            kfree(mantis);
            return -EBUSY;
        }
        pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
        pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
        mantis->mantis_mmio = ioremap(mantis->mantis_addr, 0x1000);
pci_set_drvdata(pdev, mantis);



if pci_enable_device fails, you set this?? Maybe you haven't read the doc enough.




I just found that, pci_enable_device() fails. So what's the way to go ahead ?

JESUS.


What i meant is i do have to enable the device, not just exit.
I understood that i have to exit if pci_enable_device() fails, but what i am looking for is why i can't enable it in the first place.


int retval = 0;

if ((retval = pci_enable_device()))
    goto end;

...
pci_set_drvdata(pdev, mantis);
...

end:
    return retval;

not
if (pci_enable_device())
    do something


Regards,
Manu
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux