static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); cs6436_56p_fan_update_device(dev); struct cs6436_56p_fan_data *data = fan_data; ssize_t ret = 0; if (data->valid) { switch (attr->index) { case FAN1_STATE: case FAN2_STATE: case FAN3_STATE: case FAN4_STATE: case FAN5_STATE: //printk("FAN_STATE_REG: 0x%x\n", data->reg_val[FAN_STATE_REG]); //printk("index: %d\n", attr->index); ret = sprintf(buf, "%d\n", reg_val_to_is_state(data->reg_val[FAN_STATE_REG], attr->index - FAN1_STATE)); break; case FAN_DUTY_CYCLE_PERCENTAGE: { u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); ret = sprintf(buf, "%u\n", duty_cycle); break; } case FAN1_FRONT_SPEED_RPM: case FAN2_FRONT_SPEED_RPM: case FAN3_FRONT_SPEED_RPM: case FAN4_FRONT_SPEED_RPM: case FAN5_FRONT_SPEED_RPM: case FAN1_REAR_SPEED_RPM: case FAN2_REAR_SPEED_RPM: case FAN3_REAR_SPEED_RPM: case FAN4_REAR_SPEED_RPM: case FAN5_REAR_SPEED_RPM: // printk("FAN_seed_REG: 0x%x\n", data->reg_val[attr->index]); // printk("index: %d\n", attr->index); ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); break; case FAN1_FAULT: case FAN2_FAULT: case FAN3_FAULT: case FAN4_FAULT: case FAN5_FAULT: ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); break; default: break; } } return ret; }
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct as7716_24xc_fan_data *data = as7716_24xc_fan_update_device(dev); ssize_t ret = 0; if (data->valid) { switch (attr->index) { case FAN_DUTY_CYCLE_PERCENTAGE: { u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); ret = sprintf(buf, "%u\n", duty_cycle); break; } case FAN1_FRONT_SPEED_RPM: case FAN2_FRONT_SPEED_RPM: case FAN3_FRONT_SPEED_RPM: case FAN4_FRONT_SPEED_RPM: case FAN1_REAR_SPEED_RPM: case FAN2_REAR_SPEED_RPM: case FAN3_REAR_SPEED_RPM: case FAN4_REAR_SPEED_RPM: { u32 rpm = reg_val_to_speed_rpm(data->reg_val[attr->index]); ret = sprintf(buf, "%u\n", rpm); break; } case FAN1_PRESENT: case FAN2_PRESENT: case FAN3_PRESENT: case FAN4_PRESENT: ret = sprintf(buf, "%d\n", reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], attr->index - FAN1_PRESENT)); break; case FAN1_FAULT: case FAN2_FAULT: case FAN3_FAULT: case FAN4_FAULT: ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); break; case FAN1_DIRECTION: case FAN2_DIRECTION: case FAN3_DIRECTION: case FAN4_DIRECTION: ret = sprintf(buf, "%d\n", reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], attr->index - FAN1_DIRECTION)); break; default: break; } } return ret; }