Hi,
> > 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.
>
>Look at the definition of struct pci_driver. It contains a struct
>device_driver. When passed a pointer to a struct device_driver, the
>code "knows" that it is safe to treat it as a part of the struct
>pci_driver. So it moves backwards in memory to get the real pointer to
>the struct pci_driver and everyone is happy.
>
>This convention is used a _lot_ in the driver model code in the kernel
>to allow for "inheritance" in C.
Thanks Greg,
But i am worried about the values that will be there in the pci_driver struct before member struct device_driver. If they are used , I think it will cause troubles. Am i right? If so how it is handled?
Regards
Rajesh