From patchwork Tue Mar 16 20:38:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 402044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA2E7C433DB for ; Tue, 16 Mar 2021 20:39:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A8D664F7B for ; Tue, 16 Mar 2021 20:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231465AbhCPUiz (ORCPT ); Tue, 16 Mar 2021 16:38:55 -0400 Received: from antares.kleine-koenig.org ([94.130.110.236]:53548 "EHLO antares.kleine-koenig.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231397AbhCPUiZ (ORCPT ); Tue, 16 Mar 2021 16:38:25 -0400 Received: by antares.kleine-koenig.org (Postfix, from userid 1000) id 2B2A7B3384C; Tue, 16 Mar 2021 21:38:19 +0100 (CET) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Dmitry Torokhov Cc: Thierry Reding , Lee Jones , linux-input@vger.kernel.org, linux-pwm@vger.kernel.org Subject: [PATCH] input: misc: max8997: Switch to pwm_apply() Date: Tue, 16 Mar 2021 21:38:13 +0100 Message-Id: <20210316203813.48999-1-uwe@kleine-koenig.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org max8997_haptic_enable() is the only caller of max8997_haptic_set_duty_cycle(). For the non-external case the PWM is already enabled in max8997_haptic_set_duty_cycle(), so this can be done for the external case, too, and so the pwm_enable() call can be folded into max8997_haptic_set_duty_cycle()'s call to pwm_apply_state(). With max8997_haptic_set_duty_cycle() now using pwm_init_state() the call to pwm_apply_args() can be dropped. Signed-off-by: Uwe Kleine-König --- drivers/input/misc/max8997_haptic.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c index 20ff087b8a44..c86966ea0f16 100644 --- a/drivers/input/misc/max8997_haptic.c +++ b/drivers/input/misc/max8997_haptic.c @@ -58,8 +58,12 @@ static int max8997_haptic_set_duty_cycle(struct max8997_haptic *chip) int ret = 0; if (chip->mode == MAX8997_EXTERNAL_MODE) { - unsigned int duty = chip->pwm_period * chip->level / 100; - ret = pwm_config(chip->pwm, duty, chip->pwm_period); + struct pwm_state state; + pwm_init_state(chip->pwm, &state); + state.enabled = true; + state.period = chip->pwm_period; + pwm_set_relative_duty_cycle(&state, chip->level, 100); + ret = pwm_apply_state(chip->pwm, &state); } else { int i; u8 duty_index = 0; @@ -173,14 +177,6 @@ static void max8997_haptic_enable(struct max8997_haptic *chip) goto out; } max8997_haptic_configure(chip); - if (chip->mode == MAX8997_EXTERNAL_MODE) { - error = pwm_enable(chip->pwm); - if (error) { - dev_err(chip->dev, "Failed to enable PWM\n"); - regulator_disable(chip->regulator); - goto out; - } - } chip->enabled = true; } @@ -293,11 +289,6 @@ static int max8997_haptic_probe(struct platform_device *pdev) goto err_free_mem; } - /* - * FIXME: pwm_apply_args() should be removed when switching to - * the atomic PWM API. - */ - pwm_apply_args(chip->pwm); break; default: