cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

governor_powersave.c (1316B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 *  linux/drivers/devfreq/governor_powersave.c
      4 *
      5 *  Copyright (C) 2011 Samsung Electronics
      6 *	MyungJoo Ham <myungjoo.ham@samsung.com>
      7 */
      8
      9#include <linux/devfreq.h>
     10#include <linux/module.h>
     11#include "governor.h"
     12
     13static int devfreq_powersave_func(struct devfreq *df,
     14				  unsigned long *freq)
     15{
     16	/*
     17	 * target callback should be able to get ceiling value as
     18	 * said in devfreq.h
     19	 */
     20	*freq = DEVFREQ_MIN_FREQ;
     21	return 0;
     22}
     23
     24static int devfreq_powersave_handler(struct devfreq *devfreq,
     25				unsigned int event, void *data)
     26{
     27	int ret = 0;
     28
     29	if (event == DEVFREQ_GOV_START) {
     30		mutex_lock(&devfreq->lock);
     31		ret = update_devfreq(devfreq);
     32		mutex_unlock(&devfreq->lock);
     33	}
     34
     35	return ret;
     36}
     37
     38static struct devfreq_governor devfreq_powersave = {
     39	.name = DEVFREQ_GOV_POWERSAVE,
     40	.get_target_freq = devfreq_powersave_func,
     41	.event_handler = devfreq_powersave_handler,
     42};
     43
     44static int __init devfreq_powersave_init(void)
     45{
     46	return devfreq_add_governor(&devfreq_powersave);
     47}
     48subsys_initcall(devfreq_powersave_init);
     49
     50static void __exit devfreq_powersave_exit(void)
     51{
     52	int ret;
     53
     54	ret = devfreq_remove_governor(&devfreq_powersave);
     55	if (ret)
     56		pr_err("%s: failed remove governor %d\n", __func__, ret);
     57
     58	return;
     59}
     60module_exit(devfreq_powersave_exit);
     61MODULE_LICENSE("GPL");