Format fan code

This commit is contained in:
Jeremy Soller 2018-01-02 10:50:12 -07:00
parent bc4ffb1c4d
commit 8dd2515b44
1 changed files with 12 additions and 33 deletions

45
fan.c
View File

@ -29,8 +29,7 @@ struct s76_hwmon {
static struct s76_hwmon *s76_hwmon = NULL; static struct s76_hwmon *s76_hwmon = NULL;
static int static int
s76_read_fan(int idx) s76_read_fan(int idx) {
{
u8 value; u8 value;
int raw_rpm; int raw_rpm;
ec_read(0xd0 + 0x2 * idx, &value); ec_read(0xd0 + 0x2 * idx, &value);
@ -43,72 +42,54 @@ s76_read_fan(int idx)
} }
static ssize_t static ssize_t
s76_hwmon_show_name(struct device *dev, struct device_attribute *attr, s76_hwmon_show_name(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, S76_DRIVER_NAME "\n"); return sprintf(buf, S76_DRIVER_NAME "\n");
} }
static ssize_t static ssize_t
s76_hwmon_show_fan1_input(struct device *dev, struct device_attribute *attr, s76_hwmon_show_fan1_input(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "%i\n", s76_read_fan(0)); return sprintf(buf, "%i\n", s76_read_fan(0));
} }
static ssize_t static ssize_t
s76_hwmon_show_fan1_label(struct device *dev, struct device_attribute *attr, s76_hwmon_show_fan1_label(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "CPU fan\n"); return sprintf(buf, "CPU fan\n");
} }
#ifdef EXPERIMENTAL #ifdef EXPERIMENTAL
static ssize_t static ssize_t
s76_hwmon_show_fan2_input(struct device *dev, struct device_attribute *attr, s76_hwmon_show_fan2_input(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "%i\n", s76_read_fan(1)); return sprintf(buf, "%i\n", s76_read_fan(1));
} }
static ssize_t static ssize_t
s76_hwmon_show_fan2_label(struct device *dev, struct device_attribute *attr, s76_hwmon_show_fan2_label(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "GPU fan\n"); return sprintf(buf, "GPU fan\n");
} }
#endif #endif
static ssize_t static ssize_t
s76_hwmon_show_temp1_input(struct device *dev, struct device_attribute *attr, s76_hwmon_show_temp1_input(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
u8 value; u8 value;
ec_read(0x07, &value); ec_read(0x07, &value);
return sprintf(buf, "%i\n", value * 1000); return sprintf(buf, "%i\n", value * 1000);
} }
static ssize_t static ssize_t
s76_hwmon_show_temp1_label(struct device *dev, struct device_attribute *attr, s76_hwmon_show_temp1_label(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "CPU temperature\n"); return sprintf(buf, "CPU temperature\n");
} }
#ifdef EXPERIMENTAL #ifdef EXPERIMENTAL
static ssize_t static ssize_t
s76_hwmon_show_temp2_input(struct device *dev, struct device_attribute *attr, s76_hwmon_show_temp2_input(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
u8 value; u8 value;
ec_read(0xcd, &value); ec_read(0xcd, &value);
return sprintf(buf, "%i\n", value * 1000); return sprintf(buf, "%i\n", value * 1000);
} }
static ssize_t static ssize_t
s76_hwmon_show_temp2_label(struct device *dev, struct device_attribute *attr, s76_hwmon_show_temp2_label(struct device *dev, struct device_attribute *attr, char *buf) {
char *buf)
{
return sprintf(buf, "GPU temperature\n"); return sprintf(buf, "GPU temperature\n");
} }
#endif #endif
@ -149,8 +130,7 @@ static const struct attribute_group hwmon_default_attrgroup = {
}; };
static int static int
s76_hwmon_init(struct device *dev) s76_hwmon_init(struct device *dev) {
{
int ret; int ret;
s76_hwmon = kzalloc(sizeof(*s76_hwmon), GFP_KERNEL); s76_hwmon = kzalloc(sizeof(*s76_hwmon), GFP_KERNEL);
@ -170,8 +150,7 @@ s76_hwmon_init(struct device *dev)
} }
static int static int
s76_hwmon_fini(struct device *dev) s76_hwmon_fini(struct device *dev) {
{
if (!s76_hwmon || !s76_hwmon->dev) if (!s76_hwmon || !s76_hwmon->dev)
return 0; return 0;
sysfs_remove_group(&s76_hwmon->dev->kobj, &hwmon_default_attrgroup); sysfs_remove_group(&s76_hwmon->dev->kobj, &hwmon_default_attrgroup);