Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+5 -13
+5 -13
drivers/staging/altpciechdma/altpciechdma.c
··· 783 783 goto err_ape; 784 784 } 785 785 ape->pci_dev = dev; 786 - dev->dev.driver_data = (void *)ape; 786 + dev_set_drvdata(&dev->dev, ape); 787 787 printk(KERN_DEBUG "probe() ape = 0x%p\n", ape); 788 788 789 789 printk(KERN_DEBUG "sizeof(struct ape_chdma_table) = %d.\n", ··· 946 946 947 947 static void __devexit remove(struct pci_dev *dev) 948 948 { 949 - struct ape_dev *ape; 949 + struct ape_dev *ape = dev_get_drvdata(&dev->dev); 950 + 950 951 printk(KERN_DEBUG "remove(0x%p)\n", dev); 951 - if ((dev == 0) || (dev->dev.driver_data == 0)) { 952 - printk(KERN_DEBUG "remove(dev = 0x%p) dev->dev.driver_data = 0x%p\n", 953 - dev, (dev? dev->dev.driver_data: NULL)); 954 - return; 955 - } 956 - ape = (struct ape_dev *)dev->dev.driver_data; 957 - printk(KERN_DEBUG "remove(dev = 0x%p) where dev->dev.driver_data = 0x%p\n", dev, ape); 958 - if (ape->pci_dev != dev) { 959 - printk(KERN_DEBUG "dev->dev.driver_data->pci_dev (0x%08lx) != dev (0x%08lx)\n", 960 - (unsigned long)ape->pci_dev, (unsigned long)dev); 961 - } 952 + printk(KERN_DEBUG "remove(dev = 0x%p) where ape = 0x%p\n", dev, ape); 953 + 962 954 /* remove character device */ 963 955 #if ALTPCIECHDMA_CDEV 964 956 sg_exit(ape);