From patchwork Mon Jun 25 17:14:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 9609 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4F60F23EE9 for ; Mon, 25 Jun 2012 17:14:43 +0000 (UTC) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by fiordland.canonical.com (Postfix) with ESMTP id EB91FA18245 for ; Mon, 25 Jun 2012 17:14:42 +0000 (UTC) Received: by yhjj63 with SMTP id j63so3607997yhj.37 for ; Mon, 25 Jun 2012 10:14:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=yO59Awyv9/4CFwgUEMHeRmVW4DlfQOYZAhPcUoSk/h4=; b=fsxGy/QFEIfmDrJD9gnPY9Tk3zJjroaXnXsIG8Z92F189netKAgzLsk/jLgQC4GEkc baNVm6LU/19qQzP3wx5ap6j6MdTZpYGG6Erve7IQhMvj1noa9JonIOUv+09OwR/P8NRI LBJcMBKwz9PfxWBp1xRw1zHaiUh7F0PYWGZHECpeR90sZVxP1mSv3gE5BqjtOeGjr2mm gp/uN+VA2LL5zO26WPIogHctXDZ3w6j4XyfBEbSoELVns6R/2JjunX3lgtpcO59ovPVX jqeUWm216MnC9+QXE2b1msDlLOr34iWz379ObOOs3hajzo+NS6lXkaKfjf3N5OxVvXPM vUKQ== Received: by 10.50.193.196 with SMTP id hq4mr8774466igc.57.1340644482134; Mon, 25 Jun 2012 10:14:42 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp54669ibb; Mon, 25 Jun 2012 10:14:41 -0700 (PDT) Received: by 10.68.225.9 with SMTP id rg9mr41987515pbc.137.1340644481068; Mon, 25 Jun 2012 10:14:41 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id rt10si3748893pbc.261.2012.06.25.10.14.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jun 2012 10:14:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by danh15 with SMTP id h15so6735189dan.37 for ; Mon, 25 Jun 2012 10:14:40 -0700 (PDT) Received: by 10.68.204.129 with SMTP id ky1mr43779476pbc.32.1340644480662; Mon, 25 Jun 2012 10:14:40 -0700 (PDT) Received: from localhost.localdomain ([115.242.218.11]) by mx.google.com with ESMTPS id pq5sm9056951pbb.30.2012.06.25.10.14.35 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jun 2012 10:14:39 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, Rajagopal Venkat Subject: [Powertop][PATCH v3] conditionally disable pci if not supported Date: Mon, 25 Jun 2012 22:44:13 +0530 Message-Id: <1340644453-9135-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmCk+M7Y3DNMkQW1mp2Dal+xYYZ89RcA8BHfOGWqiMajjIcrCfPGen/bBF7pYyHvoAux3Ks disable pci if not supported by host platform. When libpci is not found, define a macro which will be used for conditional compilation. Signed-off-by: Rajagopal Venkat --- configure.ac | 5 +++-- src/lib.cpp | 20 ++++++++++++++++++-- src/lib.h | 5 +++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 4da4eea..3cbc7b0 100644 --- a/configure.ac +++ b/configure.ac @@ -48,8 +48,9 @@ AC_CHECK_FUNCS([fdatasync getpagesize gettimeofday memmove memset mkdir munmap p AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [], AC_MSG_ERROR([ncurses is required but was not found]), []) PKG_CHECK_MODULES([PCIUTILS], [libpci],[],[ - AC_SEARCH_LIBS([pci_get_dev], [pci], [], AC_MSG_ERROR([libpci is required but was not found]), []) -]) + AC_SEARCH_LIBS([pci_get_dev], [pci], [], AC_DEFINE([HAVE_NO_PCI],[1],[Define if pci is not supported]), []) +]) + PKG_CHECK_MODULES([LIBZ], [zlib],[],[ AC_SEARCH_LIBS([deflate], [z], [], AC_MSG_ERROR([zlib is required but was not found]), []) ]) diff --git a/src/lib.cpp b/src/lib.cpp index 0f87e48..77e49a2 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -35,11 +35,13 @@ #include #include +#include "lib.h" + +#ifndef HAVE_NO_PCI extern "C" { #include } - -#include "lib.h" +#endif #include #include @@ -266,6 +268,7 @@ void format_watts(double W, char *buffer, unsigned int len) } +#ifndef HAVE_NO_PCI static struct pci_access *pci_access; char *pci_id_to_name(uint16_t vendor, uint16_t device, char *buffer, int len) @@ -290,6 +293,19 @@ void end_pci_access(void) pci_free_name_list(pci_access); } +#else + +char *pci_id_to_name(uint16_t vendor, uint16_t device, char *buffer, int len) +{ + return NULL; +} + +void end_pci_access(void) +{ +} + +#endif /* HAVE_NO_PCI */ + int utf_ok = -1; diff --git a/src/lib.h b/src/lib.h index 588c023..7093b7f 100644 --- a/src/lib.h +++ b/src/lib.h @@ -30,6 +30,11 @@ #endif #include +/* Include only for Automake builds */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifndef DISABLE_I18N #define _(STRING) gettext(STRING) #else