From: Greg Kroah-Hartman Date: Thu, 30 Apr 2009 21:43:31 +0000 (-0700) Subject: Staging: remove driver_data direct access of struct device X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7690e63deae3b8d57ef201cae1ff590492cf84e5;p=linux-beck.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/altpciechdma/altpciechdma.c b/drivers/staging/altpciechdma/altpciechdma.c index 5869e1484a95..f5004d3cef63 100644 --- a/drivers/staging/altpciechdma/altpciechdma.c +++ b/drivers/staging/altpciechdma/altpciechdma.c @@ -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 @@ end: 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);