Re: [RESEND PATCH V13 3/3] Input: new da7280 haptic driver
From: Uwe Kleine-König <hidden>
Date: 2020-06-24 13:37:43
Also in:
linux-pwm, lkml
On Wed, Jun 24, 2020 at 12:04:24PM +0000, Roy Im wrote:
Hello Uwe, On Tue, June 23, 2020 11:41 PM, Uwe Kleine-König wrote:quoted
Hello, On Mon, Jun 15, 2020 at 08:40:23PM +0900, Roy Im wrote:quoted
Adds support for the Dialog DA7280 LRA/ERM Haptic Driver with multiple mode and integrated waveform memory and wideband support. It communicates via an I2C bus to the device. Signed-off-by: Roy Im <redacted>Just some picky comments below.quoted
+ error = pwm_apply_state(haptics->pwm_dev, &state); + if (error) + dev_err(haptics->dev, + "failed to apply pwm state: %pE\n", + ERR_PTR(error));You can save some horizontal space here by dropping the \n after the first comma. (There are a few more occurences.)Ok, is this what you want? error = pwm_apply_state(haptics->pwm_dev, &state); if (error) dev_err(haptics->dev, "failed to apply pwm state: %pE\n", ERR_PTR(error));
Yes, that's what I meant.
quoted
quoted
+ return error; +} +[...] + + /* Sync up PWM state and ensure it is off. */ + pwm_init_state(haptics->pwm_dev, &state); + state.enabled = false; + error = pwm_apply_state(haptics->pwm_dev, &state); + if (error) { + dev_err(dev, + "failed to apply initial PWM state: %pE\n", + ERR_PTR(error)); + return error; + } + + /* Check PWM Period, it must be in 10k ~ 250kHz */The unit of a PWM period is in (nano)seconds, to it cannot be in the range [10kHz, 250kHz]. (Is this too picky?)No, it isn't. The 'Period' should be changed to 'frequency', I will fix this as below. /* Check PWM frequency, valid range: 10k ~ 250kHz */
Much better.
quoted
quoted
+ period2freq = 1000000 / state.period; + if (period2freq < DA7280_MIN_PWM_FREQ_KHZ || + period2freq > DA7280_MAX_PWM_FREQ_KHZ) { + dev_err(dev, "Not supported PWM frequency(%d)\n", + period2freq);Doesn't the compiler warn here about period2freq being unsigned and %d being for signed int values? For my (non-native) English ear s/Not supported/Unsupported/ sounds better. Also my eyes would be pleases by a space before the opening brace.I didn't see any warning message, but I will change/improve them to proper one and the log as below. period2freq = 1000000 / state.period; if (period2freq < DA7280_MIN_PWM_FREQ_KHZ || period2freq > DA7280_MAX_PWM_FREQ_KHZ) { dev_err(dev, "Unsupported PWM frequency (%u)\n", period2freq); return -EINVAL; } If you look ok, let me update this so.
looks fine.
Note that you don't need the division if you check for:
if (state.period > 100000 || state.period < 4000) {
...
(maybe the compiler is already clever enough to get rid of the division
for you, but then the check is:
if (state.period > 100000 || state.period < 3985) {
because of rounding errors.)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ | Attachments
- signature.asc [application/pgp-signature] 488 bytes