summaryrefslogtreecommitdiffstats
path: root/sys/dev/cpufreq
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2005-02-18 00:23:36 +0000
committernjl <njl@FreeBSD.org>2005-02-18 00:23:36 +0000
commit18a69f46e3ac23cb04aa2d1abf75f3aebf0c4e9a (patch)
treef4abd78e49b192efb6c1137801aa4a380e6e4218 /sys/dev/cpufreq
parentc54115d548403a18776fc113c093f02b9b1b7cd6 (diff)
downloadFreeBSD-src-18a69f46e3ac23cb04aa2d1abf75f3aebf0c4e9a.zip
FreeBSD-src-18a69f46e3ac23cb04aa2d1abf75f3aebf0c4e9a.tar.gz
Introduce a new method, cpufreq_drv_type(), that returns the type of the
driver. This used to be handled by cpufreq_drv_settings() but it's useful to get the type/flags separately from getting the settings. (For example, you don't have to pass an array of cf_setting just to find the driver type.) Use this new method in our in-tree drivers to detect reliably if acpi_perf is present and owns the hardware. This simplifies logic in drivers as well as fixing a bug introduced in my last commit where too many drivers attached.
Diffstat (limited to 'sys/dev/cpufreq')
-rw-r--r--sys/dev/cpufreq/ichss.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/sys/dev/cpufreq/ichss.c b/sys/dev/cpufreq/ichss.c
index 9f19cd4..d04c650 100644
--- a/sys/dev/cpufreq/ichss.c
+++ b/sys/dev/cpufreq/ichss.c
@@ -97,9 +97,10 @@ static int ichss_probe(device_t dev);
static int ichss_attach(device_t dev);
static int ichss_detach(device_t dev);
static int ichss_settings(device_t dev, struct cf_setting *sets,
- int *count, int *type);
+ int *count);
static int ichss_set(device_t dev, const struct cf_setting *set);
static int ichss_get(device_t dev, struct cf_setting *set);
+static int ichss_type(device_t dev, int *type);
static device_method_t ichss_methods[] = {
/* Device interface */
@@ -110,6 +111,7 @@ static device_method_t ichss_methods[] = {
/* cpufreq interface */
DEVMETHOD(cpufreq_drv_set, ichss_set),
DEVMETHOD(cpufreq_drv_get, ichss_get),
+ DEVMETHOD(cpufreq_drv_type, ichss_type),
DEVMETHOD(cpufreq_drv_settings, ichss_settings),
{0, 0}
};
@@ -209,9 +211,8 @@ ichss_pci_probe(device_t dev)
static int
ichss_probe(device_t dev)
{
- struct cf_setting set;
device_t perf_dev;
- int count, type;
+ int error, type;
/*
* If the ACPI perf driver has attached and is not just offering
@@ -219,10 +220,8 @@ ichss_probe(device_t dev)
*/
perf_dev = device_find_child(device_get_parent(dev), "acpi_perf", -1);
if (perf_dev && device_is_attached(perf_dev)) {
- type = 0;
- count = 1;
- CPUFREQ_DRV_SETTINGS(perf_dev, &set, &count, &type);
- if ((type & CPUFREQ_FLAG_INFO_ONLY) == 0)
+ error = CPUFREQ_DRV_TYPE(perf_dev, &type);
+ if (error == 0 && (type & CPUFREQ_FLAG_INFO_ONLY) == 0)
return (ENXIO);
}
@@ -275,7 +274,7 @@ ichss_detach(device_t dev)
}
static int
-ichss_settings(device_t dev, struct cf_setting *sets, int *count, int *type)
+ichss_settings(device_t dev, struct cf_setting *sets, int *count)
{
struct ichss_softc *sc;
struct cf_setting set;
@@ -304,7 +303,6 @@ ichss_settings(device_t dev, struct cf_setting *sets, int *count, int *type)
bcopy(sc->sets, sets, sizeof(sc->sets));
*count = 2;
- *type = CPUFREQ_TYPE_ABSOLUTE;
return (0);
}
@@ -382,3 +380,14 @@ ichss_get(device_t dev, struct cf_setting *set)
return (0);
}
+
+static int
+ichss_type(device_t dev, int *type)
+{
+
+ if (type == NULL)
+ return (EINVAL);
+
+ *type = CPUFREQ_TYPE_ABSOLUTE;
+ return (0);
+}
OpenPOWER on IntegriCloud