On Thu, Dec 04, 2014 at 08:20:57PM +0300, Alexey Kodanev wrote:
> Signed-off-by: Alexey Kodanev <[email protected]>
> ---
> .../kernel/device-drivers/cpufreq/cpufreq_boost.c | 67
> +++++++++++---------
> 1 files changed, 37 insertions(+), 30 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> index 423188e..941e4db 100644
> --- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> +++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
> + * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
This should rather be "Copyright (c) 2013-2014 ..."
> * This program is free software; you can redistribute it and/or
> * modify it under the terms of the GNU General Public License as
> @@ -37,22 +37,33 @@
> #include "safe_macros.h"
> #include "safe_stdio.h"
>
> -char *TCID = "ltp_acpi_cpufreq";
> +char *TCID = "cpufreq_boost";
>
> #define SYSFS_CPU_DIR "/sys/devices/system/cpu/"
>
> -const char boost[] = SYSFS_CPU_DIR "cpufreq/boost";
> +struct cpufreq_driver_info {
> + char *name;
> + int off;
> + char *on_str;
> + char *off_str;
> + char *file;
> +};
> +static const struct cpufreq_driver_info cdrv[] = {
> + { "acpi_cpufreq", 0, "1", "0", SYSFS_CPU_DIR "cpufreq/boost" },
> + { "intel_pstate", 1, "0", "1", SYSFS_CPU_DIR "intel_pstate/no_turbo" },
> +};
> +static int id = -1;
> +
> static int boost_value;
>
> const char governor[] = SYSFS_CPU_DIR "cpu0/cpufreq/scaling_governor";
> static char governor_name[16];
>
> -const char setspeed[] = SYSFS_CPU_DIR "cpu0/cpufreq/scaling_setspeed";
> const char maxspeed[] = SYSFS_CPU_DIR "cpu0/cpufreq/scaling_max_freq";
>
> static void cleanup(void)
> {
> - SAFE_FILE_PRINTF(NULL, boost, "%d", boost_value);
> + SAFE_FILE_PRINTF(NULL, cdrv[id].file, "%d", boost_value);
>
> if (governor[0] != '\0')
> SAFE_FILE_PRINTF(NULL, governor, "%s", governor_name);
> @@ -63,22 +74,32 @@ static void cleanup(void)
> static void setup(void)
> {
> int fd;
> + unsigned int i;
> tst_require_root(NULL);
>
> - fd = open(boost, O_RDWR);
> - if (fd == -1) {
> - tst_brkm(TCONF, NULL,
> - "acpi-cpufreq not loaded or overclock not supported");
> + for (i = 0; i < ARRAY_SIZE(cdrv); ++i) {
> + fd = open(cdrv[i].file, O_RDWR);
> + if (fd == -1)
> + continue;
> +
> + id = i;
> + close(fd);
Will simple access() suffice here or do we have to actually open the
file?
Otherwise it looks Ok.
--
Cyril Hrubis
[email protected]
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list