/* @client: the i2c client @dim: either LP3944_DIM0 or LP3944_DIM1 @duty_cycle: percentage of a period during which a led is ON  */
static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim, u8 duty_cycle)
/* @client: the i2c client @dim: either LP3944_DIM0 or LP3944_DIM1 @duty_cycle: percentage of a period during which a led is ON  */
static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim, u8 duty_cycle)
{
	u8 pwm_reg;
	u8 pwm_value;
	int err;
	if (dim == LP3944_DIM0)
		pwm_reg = LP3944_REG_PWM0;
	else if (dim == LP3944_DIM1)
		pwm_reg = LP3944_REG_PWM1;
	else
		return -EINVAL;
	if (duty_cycle > LP3944_DUTY_CYCLE_MAX)
		return -EINVAL;
	pwm_value = (duty_cycle * 255) / LP3944_DUTY_CYCLE_MAX;
	err = lp3944_reg_write(client, pwm_reg, pwm_value);
	return err;
}