forked from luck/tmp_suning_uos_patched
mfd: lm3533: Expand control-bank accessors
Expand the control-bank accessors that were implemented using macros. This allows the definitions of these exported functions to be found more easily and specifically avoids a W=1 compiler warning due to the redundant brightness sanity check: drivers/mfd/lm3533-ctrlbank.c: In function 'lm3533_ctrlbank_set_brightness': drivers/mfd/lm3533-ctrlbank.c:98:10: warning: comparison is always false due to limited range of data type [-Wtype-limits] 98 | if (val > LM3533_##_NAME##_MAX) \ | ^ drivers/mfd/lm3533-ctrlbank.c:125:1: note: in expansion of macro 'lm3533_ctrlbank_set' 125 | lm3533_ctrlbank_set(brightness, BRIGHTNESS); | ^~~~~~~~~~~~~~~~~~~ Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
f1d8fe2e98
commit
4d3ec936f8
|
@ -17,7 +17,6 @@
|
|||
#define LM3533_MAX_CURRENT_MAX 29800
|
||||
#define LM3533_MAX_CURRENT_STEP 800
|
||||
|
||||
#define LM3533_BRIGHTNESS_MAX 255
|
||||
#define LM3533_PWM_MAX 0x3f
|
||||
|
||||
#define LM3533_REG_PWM_BASE 0x14
|
||||
|
@ -89,41 +88,33 @@ int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u16 imax)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_set_max_current);
|
||||
|
||||
#define lm3533_ctrlbank_set(_name, _NAME) \
|
||||
int lm3533_ctrlbank_set_##_name(struct lm3533_ctrlbank *cb, u8 val) \
|
||||
{ \
|
||||
u8 reg; \
|
||||
int ret; \
|
||||
\
|
||||
if (val > LM3533_##_NAME##_MAX) \
|
||||
return -EINVAL; \
|
||||
\
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_##_NAME##_BASE); \
|
||||
ret = lm3533_write(cb->lm3533, reg, val); \
|
||||
if (ret) \
|
||||
dev_err(cb->dev, "failed to set " #_name "\n"); \
|
||||
\
|
||||
return ret; \
|
||||
} \
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_set_##_name);
|
||||
int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val)
|
||||
{
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
#define lm3533_ctrlbank_get(_name, _NAME) \
|
||||
int lm3533_ctrlbank_get_##_name(struct lm3533_ctrlbank *cb, u8 *val) \
|
||||
{ \
|
||||
u8 reg; \
|
||||
int ret; \
|
||||
\
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_##_NAME##_BASE); \
|
||||
ret = lm3533_read(cb->lm3533, reg, val); \
|
||||
if (ret) \
|
||||
dev_err(cb->dev, "failed to get " #_name "\n"); \
|
||||
\
|
||||
return ret; \
|
||||
} \
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_get_##_name);
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_BRIGHTNESS_BASE);
|
||||
ret = lm3533_write(cb->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(cb->dev, "failed to set brightness\n");
|
||||
|
||||
lm3533_ctrlbank_set(brightness, BRIGHTNESS);
|
||||
lm3533_ctrlbank_get(brightness, BRIGHTNESS);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_set_brightness);
|
||||
|
||||
int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val)
|
||||
{
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_BRIGHTNESS_BASE);
|
||||
ret = lm3533_read(cb->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(cb->dev, "failed to get brightness\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_get_brightness);
|
||||
|
||||
/*
|
||||
* PWM-input control mask:
|
||||
|
@ -135,9 +126,36 @@ lm3533_ctrlbank_get(brightness, BRIGHTNESS);
|
|||
* bit 1 - PWM-input enabled in Zone 0
|
||||
* bit 0 - PWM-input enabled
|
||||
*/
|
||||
lm3533_ctrlbank_set(pwm, PWM);
|
||||
lm3533_ctrlbank_get(pwm, PWM);
|
||||
int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val)
|
||||
{
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
if (val > LM3533_PWM_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_PWM_BASE);
|
||||
ret = lm3533_write(cb->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(cb->dev, "failed to set PWM mask\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_set_pwm);
|
||||
|
||||
int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val)
|
||||
{
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_PWM_BASE);
|
||||
ret = lm3533_read(cb->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(cb->dev, "failed to get PWM mask\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lm3533_ctrlbank_get_pwm);
|
||||
|
||||
MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>");
|
||||
MODULE_DESCRIPTION("LM3533 Control Bank interface");
|
||||
|
|
Loading…
Reference in New Issue
Block a user