diff mbox

[U-Boot,v4,08/11] dm: pci: Add an inline API to test if a device is on a PCI bus

Message ID 1441283853-30868-9-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Bin Meng Sept. 3, 2015, 12:37 p.m. UTC
Introduce device_is_on_pci_bus() which can be utilized by driver
to test if a device is on a PCI bus.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- New patch to add an inline API to test if a device is on a PCI bus

 drivers/pci/pci-uclass.c |  4 ++--
 include/pci.h            | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

Comments

Simon Glass Sept. 10, 2015, 3:58 a.m. UTC | #1
On 3 September 2015 at 06:37, Bin Meng <bmeng.cn@gmail.com> wrote:
> Introduce device_is_on_pci_bus() which can be utilized by driver
> to test if a device is on a PCI bus.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - New patch to add an inline API to test if a device is on a PCI bus
>
>  drivers/pci/pci-uclass.c |  4 ++--
>  include/pci.h            | 15 +++++++++++++++
>  2 files changed, 17 insertions(+), 2 deletions(-)

Applied to u-boot-x86, thanks!
Simon Glass Sept. 10, 2015, 8:41 p.m. UTC | #2
Hi Bin,

On 9 September 2015 at 21:58, Simon Glass <sjg@chromium.org> wrote:
> On 3 September 2015 at 06:37, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Introduce device_is_on_pci_bus() which can be utilized by driver
>> to test if a device is on a PCI bus.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>> Acked-by: Simon Glass <sjg@chromium.org>
>>
>> ---
>>
>> Changes in v4: None
>> Changes in v3: None
>> Changes in v2:
>> - New patch to add an inline API to test if a device is on a PCI bus
>>
>>  drivers/pci/pci-uclass.c |  4 ++--
>>  include/pci.h            | 15 +++++++++++++++
>>  2 files changed, 17 insertions(+), 2 deletions(-)
>
> Applied to u-boot-x86, thanks!

Sorry, I did not end up bringing this in from testing.

This causes build errors on quite a few boards - can you please take a look:

w+../include/pci.h: In function 'device_is_on_pci_bus':
w+../include/pci.h:1287:2: warning: implicit declaration of function
'device_get_uclass_id' [-Wimplicit-function-declaration]

boards:

alt,sniper,omap3_zoom1,p2571,omap3_beagle,mx6sxsabresd_spl,mx6ul_14x14_evk,devkit3250,apalis_t30,pcm051_rev3,pcm051_rev1,gose,venice2,ls2085ardb,mx6dlsabreauto,cm_t43,whistler,igep0030_nand,silk,am335x_boneblack,cairo,wandboard,birdland_bav335a,birdland_bav335b,mx6slevk_spl,am335x_evm_usbspl,igep0032,igep0030,devkit8000,chromebook_jerry,mx6qsabrelite,s5p_goni,snapper9g20,mx6sxsabresd,mx6dlsabresd,rpi_2,am335x_evm_nor,pengwyn,work_92105,tec-ng,trimslice,rpi,colibri_t30,igep0020,mx6cuboxi,cm_t335,ls2085aqds,beaver,am335x_baltos,mx6slevk_spinor,snapper9260,firefly-rk3288,jetson-tk1,mx6qsabresd,udoo,mx6sabresd_spl,igep0020_nand,am335x_evm_norboot,plutux,dalmore,marsboard,cgtqmx6qeval,am335x_evm_spiboot,lager,am335x_evm,cm_fx6,riotboard,omap3_logic,porter,pepper,omap3_overo,mx6slevk,am335x_boneblack_vboot,mx6qsabreauto,mx6qpsabreauto,am335x_gp_evm,p2371-0000,koelsch,am335x_igep0033,cardhu,e2220-1170

Regards,
Simon
Bin Meng Sept. 11, 2015, 10:24 a.m. UTC | #3
Hi Simon,

On Fri, Sep 11, 2015 at 4:41 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 9 September 2015 at 21:58, Simon Glass <sjg@chromium.org> wrote:
>> On 3 September 2015 at 06:37, Bin Meng <bmeng.cn@gmail.com> wrote:
>>> Introduce device_is_on_pci_bus() which can be utilized by driver
>>> to test if a device is on a PCI bus.
>>>
>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>>
>>> ---
>>>
>>> Changes in v4: None
>>> Changes in v3: None
>>> Changes in v2:
>>> - New patch to add an inline API to test if a device is on a PCI bus
>>>
>>>  drivers/pci/pci-uclass.c |  4 ++--
>>>  include/pci.h            | 15 +++++++++++++++
>>>  2 files changed, 17 insertions(+), 2 deletions(-)
>>
>> Applied to u-boot-x86, thanks!
>
> Sorry, I did not end up bringing this in from testing.
>
> This causes build errors on quite a few boards - can you please take a look:
>
> w+../include/pci.h: In function 'device_is_on_pci_bus':
> w+../include/pci.h:1287:2: warning: implicit declaration of function
> 'device_get_uclass_id' [-Wimplicit-function-declaration]
>
> boards:
>
> alt,sniper,omap3_zoom1,p2571,omap3_beagle,mx6sxsabresd_spl,mx6ul_14x14_evk,devkit3250,apalis_t30,pcm051_rev3,pcm051_rev1,gose,venice2,ls2085ardb,mx6dlsabreauto,cm_t43,whistler,igep0030_nand,silk,am335x_boneblack,cairo,wandboard,birdland_bav335a,birdland_bav335b,mx6slevk_spl,am335x_evm_usbspl,igep0032,igep0030,devkit8000,chromebook_jerry,mx6qsabrelite,s5p_goni,snapper9g20,mx6sxsabresd,mx6dlsabresd,rpi_2,am335x_evm_nor,pengwyn,work_92105,tec-ng,trimslice,rpi,colibri_t30,igep0020,mx6cuboxi,cm_t335,ls2085aqds,beaver,am335x_baltos,mx6slevk_spinor,snapper9260,firefly-rk3288,jetson-tk1,mx6qsabresd,udoo,mx6sabresd_spl,igep0020_nand,am335x_evm_norboot,plutux,dalmore,marsboard,cgtqmx6qeval,am335x_evm_spiboot,lager,am335x_evm,cm_fx6,riotboard,omap3_logic,porter,pepper,omap3_overo,mx6slevk,am335x_boneblack_vboot,mx6qsabreauto,mx6qpsabreauto,am335x_gp_evm,p2371-0000,koelsch,am335x_igep0033,cardhu,e2220-1170
>

Sorry, please check the v5 series @ http://patchwork.ozlabs.org/patch/516672/

Regards,
Bin
diff mbox

Patch

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index ea70853..0756bbe 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -238,7 +238,7 @@  int dm_pci_write_config(struct udevice *dev, int offset, unsigned long value,
 {
 	struct udevice *bus;
 
-	for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
+	for (bus = dev; device_is_on_pci_bus(bus);)
 		bus = bus->parent;
 	return pci_bus_write_config(bus, pci_get_bdf(dev), offset, value, size);
 }
@@ -303,7 +303,7 @@  int dm_pci_read_config(struct udevice *dev, int offset, unsigned long *valuep,
 {
 	struct udevice *bus;
 
-	for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
+	for (bus = dev; device_is_on_pci_bus(bus);)
 		bus = bus->parent;
 	return pci_bus_read_config(bus, pci_get_bdf(dev), offset, valuep,
 				   size);
diff --git a/include/pci.h b/include/pci.h
index e24c970..293a021 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -1273,5 +1273,20 @@  struct pci_driver_entry {
 		.match = __match, \
 		}
 
+#ifdef CONFIG_DM
+#include <dm.h>
+
+/**
+ * device_is_on_pci_bus - Test if a device is on a PCI bus
+ *
+ * @dev:	device to test
+ * @return:	true if it is on a PCI bus, false otherwise
+ */
+static inline bool device_is_on_pci_bus(struct udevice *dev)
+{
+	return device_get_uclass_id(dev->parent) == UCLASS_PCI;
+}
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* _PCI_H */