linux/drivers/powercap/powercap_sys.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Power capping class
 * Copyright (c) 2013, Intel Corporation.
 */

#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kstrtox.h>
#include <linux/slab.h>
#include <linux/powercap.h>

#define to_powercap_zone(n)
#define to_powercap_control_type(n)

/* Power zone show function */
#define define_power_zone_show(_attr)

/* The only meaningful input is 0 (reset), others are silently ignored */
#define define_power_zone_store(_attr)

/* Power zone constraint show function */
#define define_power_zone_constraint_show(_attr)

/* Power zone constraint store function */
#define define_power_zone_constraint_store(_attr)

/* Power zone information callbacks */
define_power_zone_show(power_uw);
define_power_zone_show(max_power_range_uw);
define_power_zone_show(energy_uj);
define_power_zone_store(energy_uj);
define_power_zone_show(max_energy_range_uj);

/* Power zone attributes */
static DEVICE_ATTR_RO(max_power_range_uw);
static DEVICE_ATTR_RO(power_uw);
static DEVICE_ATTR_RO(max_energy_range_uj);
static DEVICE_ATTR_RW(energy_uj);

/* Power zone constraint attributes callbacks */
define_power_zone_constraint_show(power_limit_uw);
define_power_zone_constraint_store(power_limit_uw);
define_power_zone_constraint_show(time_window_us);
define_power_zone_constraint_store(time_window_us);
define_power_zone_constraint_show(max_power_uw);
define_power_zone_constraint_show(min_power_uw);
define_power_zone_constraint_show(max_time_window_us);
define_power_zone_constraint_show(min_time_window_us);

/* For one time seeding of constraint device attributes */
struct powercap_constraint_attr {};

static struct powercap_constraint_attr
				constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];

/* A list of powercap control_types */
static LIST_HEAD(powercap_cntrl_list);
/* Mutex to protect list of powercap control_types */
static DEFINE_MUTEX(powercap_cntrl_list_lock);

#define POWERCAP_CONSTRAINT_NAME_LEN
static ssize_t show_constraint_name(struct device *dev,
				struct device_attribute *dev_attr,
				char *buf)
{}

static int create_constraint_attribute(int id, const char *name,
				int mode,
				struct device_attribute *dev_attr,
				ssize_t (*show)(struct device *,
					struct device_attribute *, char *),
				ssize_t (*store)(struct device *,
					struct device_attribute *,
				const char *, size_t)
				)
{}

static void free_constraint_attributes(void)
{}

static int seed_constraint_attributes(void)
{}

static int create_constraints(struct powercap_zone *power_zone,
			int nr_constraints,
			const struct powercap_zone_constraint_ops *const_ops)
{}

static bool control_type_valid(void *control_type)
{}

static ssize_t name_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

static DEVICE_ATTR_RO(name);

/* Create zone and attributes in sysfs */
static void create_power_zone_common_attributes(
					struct powercap_zone *power_zone)
{}

static void powercap_release(struct device *dev)
{}

static ssize_t enabled_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

static ssize_t enabled_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf,  size_t len)
{}

static DEVICE_ATTR_RW(enabled);

static struct attribute *powercap_attrs[] =;
ATTRIBUTE_GROUPS();

static struct class powercap_class =;

struct powercap_zone *powercap_register_zone(
			struct powercap_zone *power_zone,
			struct powercap_control_type *control_type,
			const char *name,
			struct powercap_zone *parent,
			const struct powercap_zone_ops *ops,
			int nr_constraints,
			const struct powercap_zone_constraint_ops *const_ops)
{}
EXPORT_SYMBOL_GPL();

int powercap_unregister_zone(struct powercap_control_type *control_type,
				struct powercap_zone *power_zone)
{}
EXPORT_SYMBOL_GPL();

struct powercap_control_type *powercap_register_control_type(
				struct powercap_control_type *control_type,
				const char *name,
				const struct powercap_control_type_ops *ops)
{}
EXPORT_SYMBOL_GPL();

int powercap_unregister_control_type(struct powercap_control_type *control_type)
{}
EXPORT_SYMBOL_GPL();

static int __init powercap_init(void)
{}

fs_initcall(powercap_init);

MODULE_DESCRIPTION();
MODULE_AUTHOR();