All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 08/11] dm: pci: Add an inline API to test if a device is on a PCI bus
Date: Thu,  3 Sep 2015 04:43:44 -0700	[thread overview]
Message-ID: <1441280627-29714-9-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1441280627-29714-1-git-send-email-bmeng.cn@gmail.com>

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 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(-)

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 */
-- 
1.8.2.1

  parent reply	other threads:[~2015-09-03 11:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 11:43 [U-Boot] [PATCH v3 00/11] x86: quark: Convert to driver model Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 01/11] x86: quark: Optimize MRC execution time Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 02/11] x86: quark: Avoid chicken and egg problem Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 03/11] x86: Enable PCIe controller on quark/galileo Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 04/11] x86: Convert to use driver model pci " Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 05/11] x86: quark: Add USB PHY initialization support Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 06/11] x86: galileo: Convert to use CONFIG_DM_USB Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 07/11] net: designware: Fix build warnings Bin Meng
2015-09-03 11:43 ` Bin Meng [this message]
2015-09-03 11:43 ` [U-Boot] [PATCH v3 09/11] net: designware: Add support to PCI designware devices Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 10/11] x86: Convert to use driver model eth on quark/galileo Bin Meng
2015-09-03 11:43 ` [U-Boot] [PATCH v3 11/11] x86: quark: Add PCIe/USB static register programming after memory init Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441280627-29714-9-git-send-email-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.