diff options
author | njl <njl@FreeBSD.org> | 2005-02-18 00:23:36 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2005-02-18 00:23:36 +0000 |
commit | 18a69f46e3ac23cb04aa2d1abf75f3aebf0c4e9a (patch) | |
tree | f4abd78e49b192efb6c1137801aa4a380e6e4218 /sys/dev/acpica | |
parent | c54115d548403a18776fc113c093f02b9b1b7cd6 (diff) | |
download | FreeBSD-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/acpica')
-rw-r--r-- | sys/dev/acpica/acpi_perf.c | 24 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_throttle.c | 18 |
2 files changed, 34 insertions, 8 deletions
diff --git a/sys/dev/acpica/acpi_perf.c b/sys/dev/acpica/acpi_perf.c index 1956d7b..539a06a 100644 --- a/sys/dev/acpica/acpi_perf.c +++ b/sys/dev/acpica/acpi_perf.c @@ -101,9 +101,10 @@ static void acpi_px_available(struct acpi_perf_softc *sc); static void acpi_px_startup(void *arg); static void acpi_px_notify(ACPI_HANDLE h, UINT32 notify, void *context); static int acpi_px_settings(device_t dev, struct cf_setting *sets, - int *count, int *type); + int *count); static int acpi_px_set(device_t dev, const struct cf_setting *set); static int acpi_px_get(device_t dev, struct cf_setting *set); +static int acpi_px_type(device_t dev, int *type); static device_method_t acpi_perf_methods[] = { /* Device interface */ @@ -115,6 +116,7 @@ static device_method_t acpi_perf_methods[] = { /* cpufreq interface */ DEVMETHOD(cpufreq_drv_set, acpi_px_set), DEVMETHOD(cpufreq_drv_get, acpi_px_get), + DEVMETHOD(cpufreq_drv_type, acpi_px_type), DEVMETHOD(cpufreq_drv_settings, acpi_px_settings), {0, 0} }; @@ -392,7 +394,7 @@ acpi_px_to_set(device_t dev, struct acpi_px *px, struct cf_setting *set) } static int -acpi_px_settings(device_t dev, struct cf_setting *sets, int *count, int *type) +acpi_px_settings(device_t dev, struct cf_setting *sets, int *count) { struct acpi_perf_softc *sc; int x, y; @@ -408,9 +410,6 @@ acpi_px_settings(device_t dev, struct cf_setting *sets, int *count, int *type) for (x = sc->px_max_avail; x < sc->px_count; x++, y++) acpi_px_to_set(dev, &sc->px_states[x], &sets[y]); *count = sc->px_count - sc->px_max_avail; - *type = CPUFREQ_TYPE_ABSOLUTE; - if (sc->info_only) - *type |= CPUFREQ_FLAG_INFO_ONLY; return (0); } @@ -502,3 +501,18 @@ acpi_px_get(device_t dev, struct cf_setting *set) return (0); } + +static int +acpi_px_type(device_t dev, int *type) +{ + struct acpi_perf_softc *sc; + + if (type == NULL) + return (EINVAL); + sc = device_get_softc(dev); + + *type = CPUFREQ_TYPE_ABSOLUTE; + if (sc->info_only) + *type |= CPUFREQ_FLAG_INFO_ONLY; + return (0); +} diff --git a/sys/dev/acpica/acpi_throttle.c b/sys/dev/acpica/acpi_throttle.c index 51894c2..6261eba 100644 --- a/sys/dev/acpica/acpi_throttle.c +++ b/sys/dev/acpica/acpi_throttle.c @@ -97,9 +97,10 @@ static int acpi_throttle_attach(device_t dev); static int acpi_throttle_evaluate(struct acpi_throttle_softc *sc); static int acpi_throttle_quirks(struct acpi_throttle_softc *sc); static int acpi_thr_settings(device_t dev, struct cf_setting *sets, - int *count, int *type); + int *count); static int acpi_thr_set(device_t dev, const struct cf_setting *set); static int acpi_thr_get(device_t dev, struct cf_setting *set); +static int acpi_thr_type(device_t dev, int *type); static device_method_t acpi_throttle_methods[] = { /* Device interface */ @@ -110,6 +111,7 @@ static device_method_t acpi_throttle_methods[] = { /* cpufreq interface */ DEVMETHOD(cpufreq_drv_set, acpi_thr_set), DEVMETHOD(cpufreq_drv_get, acpi_thr_get), + DEVMETHOD(cpufreq_drv_type, acpi_thr_type), DEVMETHOD(cpufreq_drv_settings, acpi_thr_settings), {0, 0} }; @@ -320,7 +322,7 @@ acpi_throttle_quirks(struct acpi_throttle_softc *sc) } static int -acpi_thr_settings(device_t dev, struct cf_setting *sets, int *count, int *type) +acpi_thr_settings(device_t dev, struct cf_setting *sets, int *count) { struct acpi_throttle_softc *sc; int i, speed; @@ -338,7 +340,6 @@ acpi_thr_settings(device_t dev, struct cf_setting *sets, int *count, int *type) sets[i].dev = dev; } *count = CPU_MAX_SPEED; - *type = CPUFREQ_TYPE_RELATIVE; return (0); } @@ -409,3 +410,14 @@ acpi_thr_get(device_t dev, struct cf_setting *set) return (0); } + +static int +acpi_thr_type(device_t dev, int *type) +{ + + if (type == NULL) + return (EINVAL); + + *type = CPUFREQ_TYPE_RELATIVE; + return (0); +} |