staging: comedi: comedidev.h: introduce comedi_to_pci_dev() helper
PATCH 1/90 staging: comedi: comedidev.h: introduce comedi_to_pci_dev() helper
Introduce a wrapper for to_pci_dev() to allow the comedi pci drivers to store the pci_dev pointer in the comedi_device hw_dev variable and retrieve it easily.
--- drivers/staging/comedi/comedidev.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/staging/comedi/comedidev.h +5 -0
@@ -446,6 +446,11 @@ static inline void comedi_set_hw_dev(struct comedi_device *dev, } } +static inline struct pci_dev *comedi_to_pci_dev (struct comedi_device *dev) +{ +return to_pci_dev (dev->hw_dev); +} +int comedi_buf_put (struct comedi_async *async,short x);int comedi_buf_get (struct comedi_async *async,short *x);
Signature · 1 line
1.7.11
Quoted 16 lines · H Hartley Sweeten
Introduce a wrapper for
to_pci_dev()to allow the comedi pci drivers to store thepci_devpointer in thecomedi_devicehw_devvariable and retrieve it easily.Signed-off-by H Hartley Sweeten <[email protected]>Cc Ian Abbott <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/staging/comedi/comedidev.h | 5 +++++ 1 file changed, 5 insertions(+)drivers/staging/comedi/comedidev.h +0
-0
drivers/staging/comedi/comedidev.h static inline void comedi_set_hw_dev(struct comedi_device *dev, · line 453
Quoted 8 lines
drivers/staging/comedi/comedidev.h +5
-0@@ -446,6 +446,11 @@ static inline void comedi_set_hw_dev(struct comedi_device *dev, } } +static inline struct pci_dev *comedi_to_pci_dev (struct comedi_device *dev) +{ +return to_pci_dev (dev->hw_dev); +} +
That needs to be something like:
return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 28 lines · Ian Abbott
Quoted 16 lines · H Hartley Sweeten
Introduce a wrapper for
to_pci_dev()to allow the comedi pci drivers to store thepci_devpointer in thecomedi_devicehw_devvariable and retrieve it easily.Signed-off-by H Hartley Sweeten <[email protected]>Cc Ian Abbott <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/staging/comedi/comedidev.h | 5 +++++ 1 file changed, 5 insertions(+)drivers/staging/comedi/comedidev.h +0
-0drivers/staging/comedi/comedidev.h static inline void comedi_set_hw_dev(struct comedi_device *dev, · line 453
Quoted 8 lines
drivers/staging/comedi/comedidev.h +5
-0@@ -446,6 +446,11 @@ static inline void comedi_set_hw_dev(struct comedi_device *dev, } } +static inline struct pci_dev *comedi_to_pci_dev (struct comedi_device *dev) +{ +return to_pci_dev (dev->hw_dev); +} +That needs to be something like:
Quoted 1 line
return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;
Hmm.. I'm not really sure.
I assumed that the container_of() macro would return NULL if the ptr passed to it was NULL. But, I'm not sure how this actually unwinds for that case.
Greg, do you know if the NULL check is needed? It's is possible that the dev->hw_dev pointer could be NULL.
Thanks,
Hartley
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 31 lines · H Hartley Sweeten
Quoted 28 lines · Ian Abbott
Quoted 16 lines · H Hartley Sweeten
Introduce a wrapper for
to_pci_dev()to allow the comedi pci drivers to store thepci_devpointer in thecomedi_devicehw_devvariable and retrieve it easily.Signed-off-by H Hartley Sweeten <[email protected]>Cc Ian Abbott <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/staging/comedi/comedidev.h | 5 +++++ 1 file changed, 5 insertions(+)drivers/staging/comedi/comedidev.h +0
-0drivers/staging/comedi/comedidev.h static inline void comedi_set_hw_dev(struct comedi_device *dev, · line 453
Quoted 8 lines
drivers/staging/comedi/comedidev.h +5
-0@@ -446,6 +446,11 @@ static inline void comedi_set_hw_dev(struct comedi_device *dev, } } +static inline struct pci_dev *comedi_to_pci_dev (struct comedi_device *dev) +{ +return to_pci_dev (dev->hw_dev); +} +That needs to be something like:
Quoted 1 line
return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;
Quoted 8 lines
Hmm.. I'm not really sure.
I assumed that the
container_of()macro would return NULL if the ptr passed to it was NULL. But, I'm not sure how this actually unwinds for that case.Greg, do you know if the NULL check is needed? It's is possible that the
dev->hw_devpointer could be NULL.
container_of() just does pointer math with the offset. Since ->hw_dev is not the first member of the pci_dev struct then to_pci_dev() never returns NULL. If you give it a NULL pointer it returns a bogus pointer back.
regards,
dan carpenter
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · H Hartley Sweeten
Quoted 3 lines · Ian Abbott
That needs to be something like:
return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;Hmm.. I'm not really sure.
I assumed that the
container_of()macro would return NULL if the ptr passed to it was NULL. But, I'm not sure how this actually unwinds for that case.
Quoted 8 lines
Quoted 3 lines
Greg, do you know if the NULL check is needed? It's is possible that the
dev->hw_devpointer could be NULL.
container_of()just does pointer math with the offset. Since ->hw_dev is not the first member of thepci_devstruct thento_pci_dev()never returns NULL. If you give it a NULL pointer it returns a bogus pointer back.
Thanks for the information.
I'll update PATCH 01/90 and repost it as v2.
Thanks,
Hartley