Hi all,
I have got a question.
I was going through pci_Driver.c. Then i found
drv = to_pci_driver(dev->driver);
and
drv is of type struct pci_driver*
#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver)
#define container_of(ptr, type, member)
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
Then i substituted for all parameters and got this
drv = ({
const struct device_driver *__mptr = (dev->driver);
(struct pci_driver*)( (char *)__mptr - offsetof(struct pci_driver,driver) );
});
1)What value will be stored in drv? Is there any rule to find this, ( Like last statement ----- My Guess )
2)We are declaring const struct device_driver pointer and substracting the offset value (struct device_driver * is a member of struct pci_driver )and getting the address of struct pci_driver which may contain some data that is irrelevent to struct pci_driver. If this is the return value whether this will cause problems? How this is dealt in the code.
Thanks in advance
Rajesh