FROMLIST: pwm: Convert period and duty cycle to u64

Because period and duty cycle are defined as ints with units of
nanoseconds, the maximum time duration that can be set is limited to
~2.147 seconds. Change their definitions to u64 in the structs of the
PWM framework so that higher durations may be set.

Also make the relevant fixes to those drivers that use the period and
duty_cycle struct members in division operations, viz. replacing the
division operations with 64-bit division macros as appropriate.

Bug: 140290586
Link: https://www.spinics.net/lists/linux-pwm/msg11133.html
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Todd Kjos <tkjos@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ife96637115f8f704aef938291eb189cb29378afb
This commit is contained in:
Guru Das Srinagesh
2019-11-26 10:57:36 -08:00
committed by Greg Kroah-Hartman
parent 8885e88692
commit d2ee0ef1e0
15 changed files with 31 additions and 30 deletions

View File

@@ -39,7 +39,7 @@ enum pwm_polarity {
* current PWM hardware state.
*/
struct pwm_args {
unsigned int period;
u64 period;
enum pwm_polarity polarity;
};
@@ -67,8 +67,8 @@ enum pwm_output_type {
* @enabled: PWM enabled status
*/
struct pwm_state {
unsigned int period;
unsigned int duty_cycle;
u64 period;
u64 duty_cycle;
enum pwm_polarity polarity;
enum pwm_output_type output_type;
bool enabled;
@@ -117,13 +117,13 @@ static inline bool pwm_is_enabled(const struct pwm_device *pwm)
return state.enabled;
}
static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period)
static inline void pwm_set_period(struct pwm_device *pwm, u64 period)
{
if (pwm)
pwm->state.period = period;
}
static inline unsigned int pwm_get_period(const struct pwm_device *pwm)
static inline u64 pwm_get_period(const struct pwm_device *pwm)
{
struct pwm_state state;
@@ -138,7 +138,7 @@ static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty)
pwm->state.duty_cycle = duty;
}
static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm)
static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm)
{
struct pwm_state state;
@@ -330,8 +330,8 @@ struct pwm_chip {
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
*/
struct pwm_capture {
unsigned int period;
unsigned int duty_cycle;
u64 period;
u64 duty_cycle;
};
#if IS_ENABLED(CONFIG_PWM)