From 745a5e9960d791148d7da7a824edd6137422b48f Mon Sep 17 00:00:00 2001 From: Jaehyoung Choi Date: Thu, 23 Nov 2017 19:06:23 +0900 Subject: [PATCH] [COMMON] pwm: pwm-samsung: Fix Prevent defect CID[202165], CID[202131], CID[202076] Fix Invalid Assignment issue Change-Id: I73e984c0eff678740ecb41601d493aef26c33b0e Signed-off-by: Jaehyoung Choi --- drivers/pwm/pwm-samsung.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 05cf1910496a..8038e8d8ea26 100755 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -52,11 +52,12 @@ * In addition, the location of autoreload bit for channel 4 (TCON channel 5) * in its set of bits is 2 as opposed to 3 for other channels. */ -#define TCON_START(chan) BIT(4 * (chan) + 0) -#define TCON_MANUALUPDATE(chan) BIT(4 * (chan) + 1) -#define TCON_INVERT(chan) BIT(4 * (chan) + 2) -#define _TCON_AUTORELOAD(chan) BIT(4 * (chan) + 3) -#define _TCON_AUTORELOAD4(chan) BIT(4 * (chan) + 2) +#define PWM_BIT(nr) (1U << (nr)) +#define TCON_START(chan) PWM_BIT(4 * (chan) + 0) +#define TCON_MANUALUPDATE(chan) PWM_BIT(4 * (chan) + 1) +#define TCON_INVERT(chan) PWM_BIT(4 * (chan) + 2) +#define _TCON_AUTORELOAD(chan) PWM_BIT(4 * (chan) + 3) +#define _TCON_AUTORELOAD4(chan) PWM_BIT(4 * (chan) + 2) #define TCON_AUTORELOAD(chan) \ ((chan < 5) ? _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan)) @@ -426,7 +427,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, unsigned long tin_rate; u32 period; - period = NSEC_PER_SEC / period_ns; + period = (unsigned int)(NSEC_PER_SEC / period_ns); dev_dbg(our_chip->chip.dev, "duty_ns=%d, period_ns=%d (%u)\n", duty_ns, period_ns, period); @@ -436,7 +437,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, if(!tin_rate) return -EINVAL; - tin_ns = NSEC_PER_SEC / tin_rate; + tin_ns = (unsigned int)(NSEC_PER_SEC / tin_rate); } /* Note that counters count down. */ -- 2.20.1