diff mbox

[1/3] powertop: Disable pci bus measurement for arm platforms

Message ID 1310711748-23531-2-git-send-email-amit.kachhap@linaro.org
State New
Headers show

Commit Message

Amit Daniel Kachhap July 15, 2011, 6:35 a.m. UTC
This patch disables pci related measurement which is not needed
for ARM platforms and also library libpci is not needed.

Signed-off-by:  Amit Daniel Kachhap <amit.kachhap@linaro.org>
---
 Android.mk             |    7 ++++++-
 devices/runtime_pm.cpp |    3 ++-
 lib.cpp                |    7 ++++---
 main.cpp               |    6 ++++++
 tuning/runtime.cpp     |    2 ++
 5 files changed, 20 insertions(+), 5 deletions(-)

Comments

Kok, Auke-jan H July 15, 2011, 5:26 p.m. UTC | #1
On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap
<amit.kachhap@linaro.org> wrote:
> This patch disables pci related measurement which is not needed
> for ARM platforms and also library libpci is not needed.
>
> Signed-off-by:  Amit Daniel Kachhap <amit.kachhap@linaro.org>
> ---
>  Android.mk             |    7 ++++++-
>  devices/runtime_pm.cpp |    3 ++-
>  lib.cpp                |    7 ++++---
>  main.cpp               |    6 ++++++
>  tuning/runtime.cpp     |    2 ++
>  5 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/Android.mk b/Android.mk
> index 146f57a..6948011 100644
> --- a/Android.mk
> +++ b/Android.mk
> @@ -4,7 +4,6 @@ include $(CLEAR_VARS)
>  LOCAL_MODULE_TAGS := debug
>  LOCAL_SHARED_LIBRARIES := libstlport \
>                          libnl \
> -                         libpci \
>
>  LOCAL_MODULE := powertop
>
> @@ -14,6 +13,12 @@ LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
>
>  LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/  bionic external/libnl/include/
>
> +ifneq ($(TARGET_ARCH),arm)
> +LOCAL_SHARED_LIBRARIES += libpci
> +else #TARGET_ARCH != arm
> +LOCAL_CPPFLAGS += -DDISABLE_PCI
> +endif #TARGET_ARCH == arm

should probably not use #ifdef ARM but something like #ifdef
HAVE_LIBPCI instead.. there will be other architectures that don't
have libpci as well.

>  LOCAL_SRC_FILES += \
>        parameters/parameters.cpp \
>        parameters/persistent.cpp \
> diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp
> index 368d995..5a55426 100644
> --- a/devices/runtime_pm.cpp
> +++ b/devices/runtime_pm.cpp
> @@ -200,7 +200,7 @@ static void do_bus(const char *bus)
>                        continue;
>
>                dev = new class runtime_pmdevice(entry->d_name, filename);
> -
> +#ifndef DISABLE_PCI

I'd prefer a nice HAVE_LIBPCI here instead as well for the rest of these...
Amit Daniel Kachhap July 19, 2011, 6:32 a.m. UTC | #2
On 15 July 2011 22:56, Kok, Auke-jan H <auke-jan.h.kok@intel.com> wrote:
> On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap
> <amit.kachhap@linaro.org> wrote:
>> This patch disables pci related measurement which is not needed
>> for ARM platforms and also library libpci is not needed.
>>
>> Signed-off-by:  Amit Daniel Kachhap <amit.kachhap@linaro.org>
>> ---
>>  Android.mk             |    7 ++++++-
>>  devices/runtime_pm.cpp |    3 ++-
>>  lib.cpp                |    7 ++++---
>>  main.cpp               |    6 ++++++
>>  tuning/runtime.cpp     |    2 ++
>>  5 files changed, 20 insertions(+), 5 deletions(-)
>>
>> diff --git a/Android.mk b/Android.mk
>> index 146f57a..6948011 100644
>> --- a/Android.mk
>> +++ b/Android.mk
>> @@ -4,7 +4,6 @@ include $(CLEAR_VARS)
>>  LOCAL_MODULE_TAGS := debug
>>  LOCAL_SHARED_LIBRARIES := libstlport \
>>                          libnl \
>> -                         libpci \
>>
>>  LOCAL_MODULE := powertop
>>
>> @@ -14,6 +13,12 @@ LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
>>
>>  LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/  bionic external/libnl/include/
>>
>> +ifneq ($(TARGET_ARCH),arm)
>> +LOCAL_SHARED_LIBRARIES += libpci
>> +else #TARGET_ARCH != arm
>> +LOCAL_CPPFLAGS += -DDISABLE_PCI
>> +endif #TARGET_ARCH == arm
>
> should probably not use #ifdef ARM but something like #ifdef
> HAVE_LIBPCI instead.. there will be other architectures that don't
> have libpci as well.
>
Thanks for your comments. i will use this macro in the next patches.

>>  LOCAL_SRC_FILES += \
>>        parameters/parameters.cpp \
>>        parameters/persistent.cpp \
>> diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp
>> index 368d995..5a55426 100644
>> --- a/devices/runtime_pm.cpp
>> +++ b/devices/runtime_pm.cpp
>> @@ -200,7 +200,7 @@ static void do_bus(const char *bus)
>>                        continue;
>>
>>                dev = new class runtime_pmdevice(entry->d_name, filename);
>> -
>> +#ifndef DISABLE_PCI
>
> I'd prefer a nice HAVE_LIBPCI here instead as well for the rest of these...
>
diff mbox

Patch

diff --git a/Android.mk b/Android.mk
index 146f57a..6948011 100644
--- a/Android.mk
+++ b/Android.mk
@@ -4,7 +4,6 @@  include $(CLEAR_VARS)
 LOCAL_MODULE_TAGS := debug
 LOCAL_SHARED_LIBRARIES := libstlport \
 			  libnl \
-			  libpci \
 
 LOCAL_MODULE := powertop
 
@@ -14,6 +13,12 @@  LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH
 
 LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/  bionic external/libnl/include/
 
+ifneq ($(TARGET_ARCH),arm)
+LOCAL_SHARED_LIBRARIES += libpci
+else #TARGET_ARCH != arm
+LOCAL_CPPFLAGS += -DDISABLE_PCI
+endif #TARGET_ARCH == arm
+
 LOCAL_SRC_FILES += \
 	parameters/parameters.cpp \
 	parameters/persistent.cpp \
diff --git a/devices/runtime_pm.cpp b/devices/runtime_pm.cpp
index 368d995..5a55426 100644
--- a/devices/runtime_pm.cpp
+++ b/devices/runtime_pm.cpp
@@ -200,7 +200,7 @@  static void do_bus(const char *bus)
 			continue;
 
 		dev = new class runtime_pmdevice(entry->d_name, filename);
-
+#ifndef DISABLE_PCI
 		if (strcmp(bus, "pci") == 0) {
 			uint16_t vendor = 0, device = 0;
 
@@ -226,6 +226,7 @@  static void do_bus(const char *bus)
 				dev->set_human_name(devname);
 			}
 		}
+#endif//DISABLE_PCI
 		all_devices.push_back(dev);
 	}
 	closedir(dir);
diff --git a/lib.cpp b/lib.cpp
index e6684b0..d058e4f 100644
--- a/lib.cpp
+++ b/lib.cpp
@@ -35,10 +35,11 @@ 
 #include <stdbool.h>
 #include <math.h>
 #include <stdlib.h>
-
+#ifndef DISABLE_PCI
 extern "C" {
 #include <pci/pci.h>
 }
+#endif
 
 #include "lib.h"
 
@@ -243,7 +244,7 @@  void format_watts(double W, char *buffer, unsigned int len)
 #endif	
 }
 
-
+#ifndef DISABLE_PCI
 static struct pci_access *pci_access;
 
 char *pci_id_to_name(uint16_t vendor, uint16_t device, char *buffer, int len)
@@ -267,7 +268,7 @@  void end_pci_access(void)
 	if (pci_access)
 		pci_free_name_list(pci_access);
 }
-
+#endif //DISABLE_PCI
 int utf_ok = -1;
 
 
diff --git a/main.cpp b/main.cpp
index 4241d44..3ee0a7e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -261,7 +261,9 @@  void html_report(int time, bool file)
 	learn_parameters(50, 0);
 	save_all_results("saved_results.powertop");
 	save_parameters("saved_parameters.powertop");
+#ifndef DISABLE_PCI
 	end_pci_access();
+#endif
 	exit(0);
 }
 
@@ -370,7 +372,9 @@  int main(int argc, char **argv)
 	if (debug_learning) {
 	        learn_parameters(1000, 1);
 		dump_parameter_bundle();
+#ifndef DISABLE_PCI
 		end_pci_access();
+#endif
 		exit(0);
 	}
 
@@ -404,7 +408,9 @@  int main(int argc, char **argv)
 	save_parameters("saved_parameters.powertop");
 	learn_parameters(500, 0);
 	save_parameters("saved_parameters.powertop");
+#ifndef DISABLE_PCI
 	end_pci_access();
+#endif
 	reset_display();
 
 	return 0;
diff --git a/tuning/runtime.cpp b/tuning/runtime.cpp
index 03cfa0b..a543b41 100644
--- a/tuning/runtime.cpp
+++ b/tuning/runtime.cpp
@@ -48,6 +48,7 @@  runtime_tunable::runtime_tunable(const char *path, const char *bus, const char *
 	if (!device_has_runtime_pm(path))
 		sprintf(desc, _("%s device %s has no runtime power management"), bus, dev);
 
+#ifndef DISABLE_PCI
 	if (strcmp(bus, "pci") == 0) {
 		char filename[4096];
 		uint16_t vendor = 0, device = 0;
@@ -77,6 +78,7 @@  runtime_tunable::runtime_tunable(const char *path, const char *bus, const char *
 
 		
 	}
+#endif//DISABLE_PCI
 }
 
 int runtime_tunable::good_bad(void)