static int __init cs6436_56p_fan_init(void)
{
    int ret;

    cig_cpld_write_register(0x40, duty_cycle_to_reg_val(50));

    ret = platform_driver_register(&cs6436_56p_fan_driver);
    if (ret < 0) {
        goto exit;
    }

    fan_data = kzalloc(sizeof(struct cs6436_56p_fan_data), GFP_KERNEL);
    if (!fan_data) {
        ret = -ENOMEM;
        platform_driver_unregister(&cs6436_56p_fan_driver);
        goto exit;
    }

	mutex_init(&fan_data->update_lock);
    fan_data->valid = 0;
	
    fan_data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
    if (IS_ERR(fan_data->pdev)) {
        ret = PTR_ERR(fan_data->pdev);
        platform_driver_unregister(&cs6436_56p_fan_driver);
        kfree(fan_data);
        goto exit;
    }

exit:
    return ret;
}
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
			const char *buf, size_t count)
{
	int error, value;
	struct i2c_client *client = to_i2c_client(dev);
	struct as7512_32x_fan_data *data = i2c_get_clientdata(client);

	error = kstrtoint(buf, 10, &value);
	if (error) {
		return error;
	}

	if (value < 0 || value > FAN_MAX_DUTY_CYCLE) {
		return -EINVAL;
	}
	
	/* Disable the watchdog timer
	 */
	error = as7512_32x_fan_write_value(client, 0x33, 0);
	
	if (error != 0) {
		dev_dbg(&client->dev, "Unable to disable the watchdog timer\n");
		return error;
	}	

	as7512_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
	data->valid = 0;

	return count;
}
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
                              const char *buf, size_t count)
{
    int error, value;

    error = kstrtoint(buf, 10, &value);
    if (error)
        return error;

    if (value <= 0 || value > FAN_MAX_DUTY_CYCLE)
        return -EINVAL;

    cig_cpld_write_register(fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
    
    return count;
}
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
            const char *buf, size_t count) 
{
    int error, value;
    struct i2c_client *client = to_i2c_client(dev);
    
    error = kstrtoint(buf, 10, &value);
    if (error)
        return error;
        
    if (value < 0 || value > FAN_MAX_DUTY_CYCLE)
        return -EINVAL;

    as7712_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */
    as7712_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
    return count;
}
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
            const char *buf, size_t count) 
{
    int error, value;
    struct i2c_client *client = to_i2c_client(dev);
    
    error = kstrtoint(buf, 10, &value);
    if (error)
        return error;

    if (value < FAN_MIN_DUTY_CYCLE) {
		value = FAN_MIN_DUTY_CYCLE;
    }

	if (value > FAN_MAX_DUTY_CYCLE) {
		value = FAN_MAX_DUTY_CYCLE;
	}

    as7116_54x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
    return count;
}