Beispiel #1
0
static ssize_t set_in0_max(struct device *dev, struct device_attribute
                           *devattr, const char *buf, size_t count)
{
    struct f71805f_data *data = dev_get_drvdata(dev);
    long val = simple_strtol(buf, NULL, 10);

    down(&data->update_lock);
    data->in_high[0] = in0_to_reg(val);
    f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]);
    up(&data->update_lock);

    return count;
}
Beispiel #2
0
static ssize_t set_in_max(struct device *dev, struct device_attribute
                          *devattr, const char *buf, size_t count)
{
    struct f71805f_data *data = dev_get_drvdata(dev);
    struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
    int nr = attr->index;
    long val = simple_strtol(buf, NULL, 10);

    down(&data->update_lock);
    data->in_high[nr] = in_to_reg(val);
    f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
    up(&data->update_lock);

    return count;
}
Beispiel #3
0
static ssize_t set_in_max(struct device *dev, struct device_attribute
			  *devattr, const char *buf, size_t count)
{
	struct f71805f_data *data = dev_get_drvdata(dev);
	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
	int nr = attr->index;
	long val;
	int err;

	err = kstrtol(buf, 10, &val);
	if (err)
		return err;

	mutex_lock(&data->update_lock);
	data->in_high[nr] = in_to_reg(val);
	f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
	mutex_unlock(&data->update_lock);

	return count;
}
Beispiel #4
0
static struct f71805f_data *f71805f_update_device(struct device *dev)
{
    struct f71805f_data *data = dev_get_drvdata(dev);
    int nr;

    down(&data->update_lock);

    /* Limit registers cache is refreshed after 60 seconds */
    if (time_after(jiffies, data->last_updated + 60 * HZ)
            || !data->valid) {
        for (nr = 0; nr < 9; nr++) {
            data->in_high[nr] = f71805f_read8(data,
                                              F71805F_REG_IN_HIGH(nr));
            data->in_low[nr] = f71805f_read8(data,
                                             F71805F_REG_IN_LOW(nr));
        }
        for (nr = 0; nr < 3; nr++) {
            if (data->fan_enabled & (1 << nr))
                data->fan_low[nr] = f71805f_read16(data,
                                                   F71805F_REG_FAN_LOW(nr));
        }
        for (nr = 0; nr < 3; nr++) {
            data->temp_high[nr] = f71805f_read8(data,
                                                F71805F_REG_TEMP_HIGH(nr));
            data->temp_hyst[nr] = f71805f_read8(data,
                                                F71805F_REG_TEMP_HYST(nr));
        }
        data->temp_mode = f71805f_read8(data, F71805F_REG_TEMP_MODE);

        data->last_limits = jiffies;
    }

    /* Measurement registers cache is refreshed after 1 second */
    if (time_after(jiffies, data->last_updated + HZ)
            || !data->valid) {
        for (nr = 0; nr < 9; nr++) {
            data->in[nr] = f71805f_read8(data,
                                         F71805F_REG_IN(nr));
        }
        for (nr = 0; nr < 3; nr++) {
            if (data->fan_enabled & (1 << nr))
                data->fan[nr] = f71805f_read16(data,
                                               F71805F_REG_FAN(nr));
        }
        for (nr = 0; nr < 3; nr++) {
            data->temp[nr] = f71805f_read8(data,
                                           F71805F_REG_TEMP(nr));
        }
        for (nr = 0; nr < 3; nr++) {
            data->alarms[nr] = f71805f_read8(data,
                                             F71805F_REG_STATUS(nr));
        }

        data->last_updated = jiffies;
        data->valid = 1;
    }

    up(&data->update_lock);

    return data;
}
Beispiel #5
0
static struct f71805f_data *f71805f_update_device(struct device *dev)
{
	struct f71805f_data *data = dev_get_drvdata(dev);
	int nr, apnr;

	mutex_lock(&data->update_lock);

	/* Limit registers cache is refreshed after 60 seconds */
	if (time_after(jiffies, data->last_updated + 60 * HZ)
	 || !data->valid) {
		for (nr = 0; nr < 11; nr++) {
			if (!(data->has_in & (1 << nr)))
				continue;
			data->in_high[nr] = f71805f_read8(data,
					    F71805F_REG_IN_HIGH(nr));
			data->in_low[nr] = f71805f_read8(data,
					   F71805F_REG_IN_LOW(nr));
		}
		for (nr = 0; nr < 3; nr++) {
			data->fan_low[nr] = f71805f_read16(data,
					    F71805F_REG_FAN_LOW(nr));
			data->fan_target[nr] = f71805f_read16(data,
					       F71805F_REG_FAN_TARGET(nr));
			data->pwm_freq[nr] = f71805f_read8(data,
					     F71805F_REG_PWM_FREQ(nr));
		}
		for (nr = 0; nr < 3; nr++) {
			data->temp_high[nr] = f71805f_read8(data,
					      F71805F_REG_TEMP_HIGH(nr));
			data->temp_hyst[nr] = f71805f_read8(data,
					      F71805F_REG_TEMP_HYST(nr));
		}
		data->temp_mode = f71805f_read8(data, F71805F_REG_TEMP_MODE);
		for (nr = 0; nr < 3; nr++) {
			for (apnr = 0; apnr < 3; apnr++) {
				data->auto_points[nr].temp[apnr] =
					f71805f_read8(data,
					F71805F_REG_PWM_AUTO_POINT_TEMP(nr,
									apnr));
				data->auto_points[nr].fan[apnr] =
					f71805f_read16(data,
					F71805F_REG_PWM_AUTO_POINT_FAN(nr,
								       apnr));
			}
		}

		data->last_limits = jiffies;
	}

	/* Measurement registers cache is refreshed after 1 second */
	if (time_after(jiffies, data->last_updated + HZ)
	 || !data->valid) {
		for (nr = 0; nr < 11; nr++) {
			if (!(data->has_in & (1 << nr)))
				continue;
			data->in[nr] = f71805f_read8(data,
				       F71805F_REG_IN(nr));
		}
		for (nr = 0; nr < 3; nr++) {
			data->fan[nr] = f71805f_read16(data,
					F71805F_REG_FAN(nr));
			data->fan_ctrl[nr] = f71805f_read8(data,
					     F71805F_REG_FAN_CTRL(nr));
			data->pwm[nr] = f71805f_read8(data,
					F71805F_REG_PWM_DUTY(nr));
		}
		for (nr = 0; nr < 3; nr++) {
			data->temp[nr] = f71805f_read8(data,
					 F71805F_REG_TEMP(nr));
		}
		data->alarms = f71805f_read8(data, F71805F_REG_STATUS(0))
			+ (f71805f_read8(data, F71805F_REG_STATUS(1)) << 8)
			+ (f71805f_read8(data, F71805F_REG_STATUS(2)) << 16);

		data->last_updated = jiffies;
		data->valid = 1;
	}

	mutex_unlock(&data->update_lock);

	return data;
}