parisc: don't touch driver core internals
Subsystems (2)
PATCH 1/1 parisc: don't touch driver core internals
From: Greg Kroah-Hartman <[email protected]>
It isn't wise to use the struct device klists on their own, as their implementation has a tendancy to change at times. Instead, use the functions created for iterating over lists of devices, as it handles all of the dirty klist work for you automatically.
This is needed as the driver core is changing how klists are stored in struct device in the near future.
---
I can keep this in my driver-core tree, where is it required in order for parisc to build properly. Or you all can take this now, in your tree, whatever is easier for you.
drivers/char/agp/parisc-agp.c | 24 ++++++--------- drivers/parisc/gsc.c | 40 +++++++++++++++----------- drivers/parisc/sba_iommu.c | 64 ++++++++++++++++++++++++------------------ 3 files changed, 71 insertions(+), 57 deletions(-)
drivers/char/agp/parisc-agp.c +10 -14
@@ -16,7 +16,6 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> -#include <linux/klist.h> #include <linux/agp_backend.h> #include <linux/log2.h>
@@ -359,9 +358,12 @@ fail:return error; } -static struct device *next_device (struct klist_iter *i) { -struct klist_node * n =klist_next (i); - return n ? container_of(n, struct device, knode_parent) : NULL; +static int match_quicksilver (struct device *dev,void *data) +{ +struct parisc_device *padev =to_parisc_device (dev); + +if (IS_QUICKSILVER (padev)) +return 1 ; } static int
@@ -372,8 +374,7 @@ parisc_agp_init(void)int err =-1 ;struct parisc_device *sba =NULL , *lba =NULL ;struct lba_device *lbadev =NULL ; -struct device *dev =NULL ; -struct klist_iter i; +struct device *dev;if (!sba_list) goto out;
@@ -386,14 +387,9 @@ parisc_agp_init(void) }/* Now search our Pluto for our precious AGP device... */ -klist_iter_init (&sba->dev.klist_children, &i); -while ((dev =next_device (&i))) { -struct parisc_device *padev =to_parisc_device (dev); -if (IS_QUICKSILVER (padev)) - lba = padev; - } -klist_iter_exit (&i); - + dev =device_find_child (&sba->dev,NULL , match_quicksilver); +if (dev) + lba =to_parisc_device (dev);if (!lba) { printk(KERN_INFO DRVPFX "No AGP devices found.\n"); goto out;
drivers/parisc/gsc.c +24 -16
@@ -186,29 +186,37 @@ void gsc_asic_assign_irq(struct gsc_asic *irqp = irq; } -static struct device *next_device (struct klist_iter *i) +struct fixup_irq_struct { +void *ctrl; +void (*choose_irq)(struct parisc_device *,void *); +} + +static int fixup_irq(struct device *dev, void *data) { -struct klist_node * n =klist_next (i); - return n ? container_of(n, struct device, knode_parent) : NULL; +struct fixup_irq_struct *fixup = data; +void (*choose_irq)(struct parisc_device *,void *) = fixup->choose_irq; +void *ctrl = fixup->ctrl; +struct parisc_device *padev =to_parisc_device (dev); + +/* work-around for 715/64 and others which have parent +at path [5] and children at path [5/0/x] */ +if (padev->id.hw_type ==HPHW_FAULTY ) { +gsc_fixup_irqs (padev, ctrl, choose_irq); +return -1 ; + } +choose_irq (padev, ctrl); +return 0 ; }void gsc_fixup_irqs (struct parisc_device *parent,void *ctrl,void (*choose_irq)(struct parisc_device *,void *)) { -struct device *dev; -struct klist_iter i; +struct fixup_irq_struct fixup; -klist_iter_init (&parent->dev.klist_children, &i); -while ((dev =next_device (&i))) { -struct parisc_device *padev =to_parisc_device (dev); - -/* work-around for 715/64 and others which have parent -at path [5] and children at path [5/0/x] */ -if (padev->id.hw_type ==HPHW_FAULTY ) -return gsc_fixup_irqs (padev, ctrl, choose_irq); -choose_irq (padev, ctrl); - } -klist_iter_exit (&i); + fixup.ctrl = ctrl; + fixup.choose_irq = choose_irq; + +device_for_each_child (&parent->dev, &fixup, fixup_irq); }int gsc_common_setup (struct parisc_device *parent,struct gsc_asic *gsc_asic)
drivers/parisc/sba_iommu.c +37 -27
97 lines not on this page · raw message
James Bottomley
maintainerQuoted 18 lines · Greg KH
From: Greg Kroah-Hartman <[email protected]>
It isn't wise to use the struct device klists on their own, as their implementation has a tendancy to change at times. Instead, use the functions created for iterating over lists of devices, as it handles all of the dirty klist work for you automatically.
This is needed as the driver core is changing how klists are stored in struct device in the near future.
Cc Kyle McMartin <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Grant Grundler <[email protected]>Cc Kay Sievers <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Quoted 8 lines
I can keep this in my driver-core tree, where is it required in order for parisc to build properly. Or you all can take this now, in your tree, whatever is easier for you.
drivers/char/agp/parisc-agp.c | 24 ++++++--------- drivers/parisc/gsc.c | 40 +++++++++++++++----------- drivers/parisc/sba_iommu.c | 64 ++++++++++++++++++++++++------------------ 3 files changed, 71 insertions(+), 57 deletions(-)
Actually, we already have such a patch here:
http://marc.info/?l=linux-parisc&m=123154903507114
The approaches look identical.
James
Quoted 28 lines · James Bottomley
Quoted 18 lines · Greg KH
From: Greg Kroah-Hartman <[email protected]>
It isn't wise to use the struct device klists on their own, as their implementation has a tendancy to change at times. Instead, use the functions created for iterating over lists of devices, as it handles all of the dirty klist work for you automatically.
This is needed as the driver core is changing how klists are stored in struct device in the near future.
Cc Kyle McMartin <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Grant Grundler <[email protected]>Cc Kay Sievers <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Quoted 8 lines
I can keep this in my driver-core tree, where is it required in order for parisc to build properly. Or you all can take this now, in your tree, whatever is easier for you.
drivers/char/agp/parisc-agp.c | 24 ++++++--------- drivers/parisc/gsc.c | 40 +++++++++++++++----------- drivers/parisc/sba_iommu.c | 64 ++++++++++++++++++++++++------------------ 3 files changed, 71 insertions(+), 57 deletions(-)
Quoted 5 lines
Actually, we already have such a patch here:
http://marc.info/?l=linux-parisc&m=123154903507114
The approaches look identical.
Author: Greg Kroah-Hartman <[email protected]> ???
I wrote that? heh, I forgot all about that...
Yeah, that looks fine to me.
thanks,
greg k-h
Quoted 4 lines · Greg KH
I wrote that? heh, I forgot all about that...
Yeah, that looks fine to me.
If you and Pat hadn't converted struct device to use klists we wouldn't be in this mess... ;-)
Ack... My tree or yours, greg? I've already got James' patch I believe.
cheers, Kyle
Quoted 8 lines · Kyle McMartin
Quoted 4 lines · Greg KH
I wrote that? heh, I forgot all about that...
Yeah, that looks fine to me.
If you and Pat hadn't converted struct device to use klists we wouldn't be in this mess... ;-)
Well, you could have used the helper functions then...
Quoted 1 line
Ack... My tree or yours, greg? I've already got James' patch I believe.
If you want to take it, I have no objection. Let me know which is easier for you.
thanks,
greg k-h
Quoted 10 lines · Greg KH
Quoted 8 lines · Kyle McMartin
Quoted 4 lines · Greg KH
I wrote that? heh, I forgot all about that...
Yeah, that looks fine to me.
If you and Pat hadn't converted struct device to use klists we wouldn't be in this mess... ;-)
Quoted 7 lines
Well, you could have used the helper functions then...
Quoted 1 line
Ack... My tree or yours, greg? I've already got James' patch I believe.
If you want to take it, I have no objection. Let me know which is easier for you.
Ok, I've already got James' patch in my tree, I'll push it all along tonight.
cheers, Kyle