From patchwork Thu Sep 3 12:37:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 514040 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DD1721401CD for ; Thu, 3 Sep 2015 22:36:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=cm+8m+o8; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7BD794B7F5; Thu, 3 Sep 2015 14:36:10 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 67lZUvy9nZ53; Thu, 3 Sep 2015 14:36:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F1DD4B800; Thu, 3 Sep 2015 14:35:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 495324B7D6 for ; Thu, 3 Sep 2015 14:35:29 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tl0KJGo9Y4C1 for ; Thu, 3 Sep 2015 14:35:29 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by theia.denx.de (Postfix) with ESMTPS id 11D2A4B77D for ; Thu, 3 Sep 2015 14:35:19 +0200 (CEST) Received: by pacex6 with SMTP id ex6so40958413pac.0 for ; Thu, 03 Sep 2015 05:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=nlgNMV+3+pVr7Ovk2G5RMWwld2efIMaPGpA9qroeAww=; b=cm+8m+o8aXb3OwuC/Hq5Ao7+DYrC/AAyU2jyOLQWsgbg6YmwgV23rSAZGyEUAWWo3z MGj5pxdd3GlYLykE9+N/1HcyaBFAQyICwSK0VEm91Y0PGHaKhYSO1LLFGfkxGOTKxUwP iZBd3RK/0I5sMf+CHLZeusxxli8R2FfOQ5PlkG/BKKE8bREh10zqR2GGqpRq6xbS07oI 77DcbNmO8447nnDCO9ek5pL0sq5JbcpMrNmYj3vgarocGdQ2K98cubakv32zrwruZYrm NTpS0ep8WmJfuu7ooZYGQhHUMF2TFdeloFWBJ3cqi0Bd/4dkrSQ9wrHZbJ+vLFjZvCrw 6YHA== X-Received: by 10.66.173.72 with SMTP id bi8mr4723533pac.27.1441283718646; Thu, 03 Sep 2015 05:35:18 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id ev2sm25165500pbb.37.2015.09.03.05.35.18 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Sep 2015 05:35:18 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Thu, 3 Sep 2015 05:37:30 -0700 Message-Id: <1441283853-30868-9-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1441283853-30868-1-git-send-email-bmeng.cn@gmail.com> References: <1441283853-30868-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v4 08/11] dm: pci: Add an inline API to test if a device is on a PCI bus X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Acked-by: Simon Glass --- 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(-) 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 + +/** + * 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 */