Back to index

lshw  02.16
Defines | Functions File Reference
#include "version.h"
#include "hw.h"
#include "osutils.h"
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>

Go to the source code of this file.


#define DEVICESCPUFREQ   "/sys/devices/system/cpu/cpu%d/cpufreq/"


 __ID ("@(#) $Id: 2433 2012-01-10 22:01:30Z lyonel $")
static long get_long (const string &path)
static string cpubusinfo (int cpu)
bool scan_cpufreq (hwNode &node)

Define Documentation

#define DEVICESCPUFREQ   "/sys/devices/system/cpu/cpu%d/cpufreq/"

Definition at line 23 of file

Function Documentation

__ID ( "@(#) $Id: 2433 2012-01-10 22:01:30Z lyonel $"  )
static string cpubusinfo ( int  cpu) [static]

Definition at line 41 of file

  char buffer[10];

  snprintf(buffer, sizeof(buffer), "cpu@%d", cpu);

  return string(buffer);

Here is the caller graph for this function:

static long get_long ( const string &  path) [static]

Definition at line 25 of file

  long result = 0;
  FILE * in = fopen(path.c_str(), "r");

  if (in)
    if(fscanf(in, "%ld", &result) != 1)
      result = 0;

  return result;

Here is the caller graph for this function:

bool scan_cpufreq ( hwNode node)

Definition at line 51 of file

  char buffer[PATH_MAX];
  unsigned i =0;

  while(hwNode * cpu = node.findChildByBusInfo(cpubusinfo(i)))
    snprintf(buffer, sizeof(buffer), DEVICESCPUFREQ, i);
      unsigned long long max, min, cur;

                                                  // in Hz
      min = 1000*(unsigned long long)get_long("cpuinfo_min_freq");
                                                  // in Hz
      max = 1000*(unsigned long long)get_long("cpuinfo_max_freq");
                                                  // in Hz
      cur = 1000*(unsigned long long)get_long("scaling_cur_freq");
      cpu->addCapability("cpufreq", "CPU Frequency scaling");
      if(cur) cpu->setSize(cur);
      if(max>cpu->getCapacity()) cpu->setCapacity(cur);

  return true;

Here is the call graph for this function:

Here is the caller graph for this function: