Staging: remove driver_data direct access of struct device

In the near future, the driver core is going to not allow direct access
to the driver_data pointer in struct device.  Instead, the functions
dev_get_drvdata() and dev_set_drvdata() should be used.  These functions
have been around since the beginning, so are backwards compatible with
all older kernel versions.

Cc: Leon Woestenberg <leon@sidebranch.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2009-04-30 14:43:31 -07:00
parent 5355d8cac2
commit 7690e63dea

View File

@ -783,7 +783,7 @@ static int __devinit probe(struct pci_dev *dev, const struct pci_device_id *id)
goto err_ape;
}
ape->pci_dev = dev;
dev->dev.driver_data = (void *)ape;
dev_set_drvdata(&dev->dev, ape);
printk(KERN_DEBUG "probe() ape = 0x%p\n", ape);
printk(KERN_DEBUG "sizeof(struct ape_chdma_table) = %d.\n",
@ -946,19 +946,11 @@ static int __devinit probe(struct pci_dev *dev, const struct pci_device_id *id)
static void __devexit remove(struct pci_dev *dev)
{
struct ape_dev *ape;
struct ape_dev *ape = dev_get_drvdata(&dev->dev);
printk(KERN_DEBUG "remove(0x%p)\n", dev);
if ((dev == 0) || (dev->dev.driver_data == 0)) {
printk(KERN_DEBUG "remove(dev = 0x%p) dev->dev.driver_data = 0x%p\n",
dev, (dev? dev->dev.driver_data: NULL));
return;
}
ape = (struct ape_dev *)dev->dev.driver_data;
printk(KERN_DEBUG "remove(dev = 0x%p) where dev->dev.driver_data = 0x%p\n", dev, ape);
if (ape->pci_dev != dev) {
printk(KERN_DEBUG "dev->dev.driver_data->pci_dev (0x%08lx) != dev (0x%08lx)\n",
(unsigned long)ape->pci_dev, (unsigned long)dev);
}
printk(KERN_DEBUG "remove(dev = 0x%p) where ape = 0x%p\n", dev, ape);
/* remove character device */
#if ALTPCIECHDMA_CDEV
sg_exit(ape);