ssize_t fan_show_default()

in platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c [198:303]


ssize_t fan_show_default(struct device *dev, struct device_attribute *da, char *buf)
{
    struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
    struct i2c_client *client = to_i2c_client(dev);
    struct fan_data *data = i2c_get_clientdata(client);
    FAN_PDATA *pdata = (FAN_PDATA *)(client->dev.platform_data);
    FAN_DATA_ATTR *usr_data = NULL;
    struct fan_attr_info *attr_info = NULL;
    int i, status=0;
	char new_str[ATTR_NAME_LEN] = "";
	FAN_SYSFS_ATTR_DATA *ptr = NULL;

    for (i=0;i<data->num_attr;i++)
    {
		ptr = (FAN_SYSFS_ATTR_DATA *)pdata->fan_attrs[i].access_data;
		get_fan_duplicate_sysfs(ptr->index , new_str);
        if (strcmp(attr->dev_attr.attr.name, pdata->fan_attrs[i].aname) == 0 || strcmp(attr->dev_attr.attr.name, new_str) == 0)
        {
			attr_info = &data->attr_info[i];
            usr_data = &pdata->fan_attrs[i];
			strcpy(new_str, "");
        }
    }

    if (attr_info==NULL || usr_data==NULL)
    {
        printk(KERN_ERR "%s is not supported attribute for this client\n", usr_data->aname);
		goto exit;
	}

    fan_update_attr(dev, attr_info, usr_data);

	/*Decide the o/p based on attribute type */
	switch(attr->index)
	{
		case FAN1_PRESENT:
		case FAN2_PRESENT:
		case FAN3_PRESENT:
		case FAN4_PRESENT:
		case FAN5_PRESENT:
		case FAN6_PRESENT:
		case FAN7_PRESENT:
		case FAN8_PRESENT:
		case FAN9_PRESENT:
		case FAN10_PRESENT:
		case FAN11_PRESENT:
		case FAN12_PRESENT:
		case FAN1_DIRECTION:
		case FAN2_DIRECTION:
		case FAN3_DIRECTION:
		case FAN4_DIRECTION:
		case FAN5_DIRECTION:
		case FAN6_DIRECTION:
		case FAN7_DIRECTION:
		case FAN8_DIRECTION:
		case FAN9_DIRECTION:
		case FAN10_DIRECTION:
		case FAN11_DIRECTION:
		case FAN12_DIRECTION:
		case FAN1_INPUT:
		case FAN2_INPUT:
		case FAN3_INPUT:
		case FAN4_INPUT:
		case FAN5_INPUT:
		case FAN6_INPUT:
		case FAN7_INPUT:
		case FAN8_INPUT:
		case FAN9_INPUT:
		case FAN10_INPUT:
		case FAN11_INPUT:
		case FAN12_INPUT:
		case FAN1_PWM:
		case FAN2_PWM:
		case FAN3_PWM:
		case FAN4_PWM:
		case FAN5_PWM:
		case FAN6_PWM:
		case FAN7_PWM:
		case FAN8_PWM:
		case FAN9_PWM:
		case FAN10_PWM:
		case FAN11_PWM:
		case FAN12_PWM:
		case FAN1_FAULT:
		case FAN2_FAULT:
		case FAN3_FAULT:
		case FAN4_FAULT:
		case FAN5_FAULT:
		case FAN6_FAULT:
		case FAN7_FAULT:
		case FAN8_FAULT:
		case FAN9_FAULT:
		case FAN10_FAULT:
		case FAN11_FAULT:
		case FAN12_FAULT:
		case FAN_DUTY_CYCLE:
            status = attr_info->val.intval;
			break;
		default:
			fan_dbg(KERN_ERR "%s: Unable to find the attribute index for %s\n", __FUNCTION__, usr_data->aname);
			status = 0;
	}

exit:
    return sprintf(buf, "%d\n", status);
}