Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36196187rwd; Mon, 10 Jul 2023 20:01:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEjm8oV05sp9WnudzXWhpRw9xAMsvZ3Vrg+46o3w3+x5H+0a78l44NsVF7h6WhWsyLTx0ha X-Received: by 2002:aa7:cd01:0:b0:51d:af77:d201 with SMTP id b1-20020aa7cd01000000b0051daf77d201mr15225431edw.18.1689044474835; Mon, 10 Jul 2023 20:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689044474; cv=none; d=google.com; s=arc-20160816; b=FK0/ww2XZ/yiqAX2OpyvlRi1mcekvaDPdwm5fx80BLxKk7909dq+5GvcDTf9vrnOW0 tA+EstY1tYBMvH8eupK2sEe29tczbdqAFATXm3KjC1jbWGqBAQIgMxXAr8TsrUXzGVtm 58FMUodMR2tSOJlpSueCtTzIOxXUmbpiebttjG2+lCXAKZnCHcYAwsnRd/oR0CLRIFNF Mqm0rfWcAB1wuGUT2dKUuoTIhEetjHNE4tkkj4LF7bBLiQF6cB9gxocxe5zaY6/ANwil Z84dWo0FE0Wxea62Fcld7IutNNJyqHwWJ3Tc0diT7acefKOxgf26TkrKrgmzsBgxCpZl PeNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=2vKCsfZmQ4pdPeNTJyUuoml7xtipyGpfEqf7kDYskjU=; fh=in8FZZO6l5qL+y/jP2IMHM7J5Unbybzi/3ZcGWG6Mw4=; b=vLakbq9cIFv54A5oaAwDYqDHvpQCprr9qJjVa252CgiOw8iKf+cPt5Maqr8Uh6XpiM Ro40j5Ra6lzyzzghSOkR51rgRE9X+ZBbpSvDZgCpSnKQ75X5z/KBSQi8ZmXw2tLhXkEl OvYQ77Lwm+hpuMYDfA32IVWA2IVBARGqUJbYJg8T8m4brtMk38VnX6weSP5oCKIG/IsD x90uz8+9IQ704pHRE4RgfUi87Gqm+osGzUUaIl35CL6O2V6ff1NOFuNmqJQfAmZx0BUr WZru/DXTYRtxWcO7eDyWGgDjnqI5zKWCyzJ4zimw9q8Mb51ZVx75P8SAxut40DHyXFhZ Fo7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oDCAc5Lx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020aa7c982000000b0051a1d9c1974si997907edt.107.2023.07.10.20.00.50; Mon, 10 Jul 2023 20:01:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oDCAc5Lx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbjGKCbW (ORCPT + 99 others); Mon, 10 Jul 2023 22:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbjGKCbV (ORCPT ); Mon, 10 Jul 2023 22:31:21 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3D06197; Mon, 10 Jul 2023 19:31:20 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3a3790a0a48so4006150b6e.1; Mon, 10 Jul 2023 19:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689042680; x=1691634680; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2vKCsfZmQ4pdPeNTJyUuoml7xtipyGpfEqf7kDYskjU=; b=oDCAc5LxzzKVXMV7c8RHtevUUAMyTt+Yf1wboAuOvQW8XhL3bRnujfvSw1c2F/p0R1 O0ZYblp0elMGQfwD6fXQVdw00hLKtgVa7hgB2FWY0SUWOvkrIMVgALU3JFSDX5BzqRao 59RRLGxSst9SHUWndmvIW+3KKaeekl67sTd18v5PsN+y74acg9lPJpSQA7xHLyBF1pVW 5fVvmO6hXwy8sfn9ASrj0dVbXcqYUwmWoYvATCaAr6WHQUaw/JEiXdFGjXBIDObq3te2 ah7IvR5ndVx70dXrPyLYUKB2TDx/7ig1JtNwX3bCB/j0XsX/VNnIVNCJHW9qNCBzgFjX xPTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689042680; x=1691634680; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2vKCsfZmQ4pdPeNTJyUuoml7xtipyGpfEqf7kDYskjU=; b=ORwrr+7SvkPmF5xp/Hx4bUSPraRlxezCYuYzSVZYu9OWjtS0CUoxprD/aNixt3m+kE u8I1X6ah5rqBWshbMmMAuaMFG6yQJY3D50EZhk2RyjSZosGjg2CeKOLDA2lNQf8/s2Bs Yvi50Fa213eDHchL/sMaJ+oLhHOaijlTf7X5mdzLmc/DeDuJkJL/pSOZCzI21a81XVF7 n7T1C9Q5a28Qk6VIrJDsyvVHtJ5DH6/wxcc2rwQqpZ2Hf+/zW241GmGCN3+Uikd78UUt yQHVQEXljxMzRCQ70lPboeo31rlAaROlienUgg1WW/XxSb+rsJSUQn/AcI5MEnnbbUpW 6FRg== X-Gm-Message-State: ABy/qLYrz3oa3xfn+qKS1tqDDHAVbgfVyJdzUOumESiZWfb9IMcO7rXX YmII9zXOS8+WM4yBLTInvjE= X-Received: by 2002:a05:6358:3386:b0:135:515c:38ee with SMTP id i6-20020a056358338600b00135515c38eemr7122186rwd.25.1689042679717; Mon, 10 Jul 2023 19:31:19 -0700 (PDT) Received: from [192.168.220.128] ([183.63.252.58]) by smtp.gmail.com with ESMTPSA id a28-20020a63705c000000b00528513c6bbcsm384979pgn.28.2023.07.10.19.31.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jul 2023 19:31:19 -0700 (PDT) Message-ID: Date: Tue, 11 Jul 2023 10:30:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.10.0 Subject: Re: [PATCH] pwm: atmel: enable clk when pwm already enabled in bootloader Content-Language: en-US To: Thierry Reding Cc: claudiu.beznea@microchip.com, u.kleine-koenig@pengutronix.de, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230710144214.63343-1-aarongt.shen@gmail.com> From: Guiting Shen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 10, 2023 at 23:00:45PM GMT+8, Thierry Reding wrote: > On Mon, Jul 10, 2023 at 10:42:14PM +0800, Guiting Shen wrote: >> The driver would never call clk_eanble() if the pwm channel already >> enable in bootloader which lead to dump the warning message of "the pwm >> clk already disabled" when poweroff the pwm channel. >> >> Add atmel_pwm_enanle_clk_if_on() in probe function to enable clk if the >> pwm channel already enabled in bootloader. > > You've got multiple spelling errors in the commit message. Also, PWM is > an abbreviation and so should be all uppercase (except for the subject > prefix). I also prefer spelling out terms like "clock" in the commit > message. This is text that is supposed to be readable. It's not code. Got it, Thank you. How about this commit message: The driver would never call clk_enable() if the PWM channel was already enabled in bootloader which lead to dump the warning message "the pwm clock already disabled" when turn off the PWM channel. Add atmel_pwm_enable_clk_if_on() in probe function to enable clk if the PWM channel was already enabled in bootloader. >> >> Signed-off-by: Guiting Shen >> --- >> drivers/pwm/pwm-atmel.c | 27 +++++++++++++++++++++++++++ >> 1 file changed, 27 insertions(+) >> >> diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c >> index cdbc23649032..385f12eb604c 100644 >> --- a/drivers/pwm/pwm-atmel.c >> +++ b/drivers/pwm/pwm-atmel.c >> @@ -464,6 +464,29 @@ static const struct of_device_id atmel_pwm_dt_ids[] = { >> }; >> MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); >> >> +static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm) >> +{ >> + u32 sr, i; > > Maybe make i an unsigned int since you use it to iterate over npwm, > which is unsigned int as well. Ok, I will correct it in v2 patch. >> + int err; >> + >> + sr = atmel_pwm_readl(atmel_pwm, PWM_SR); >> + if (!sr) >> + return 0; >> + >> + for (i = 0; i < atmel_pwm->chip.npwm; i++) { >> + if (!(sr & (1 << i))) > > We would usually write this as BIT(i), but I see that the rest of the > driver uses this notation, so it's fine to keep this as-is. > >> + continue; >> + >> + err = clk_enable(atmel_pwm->clk); >> + if (err) { >> + dev_err(atmel_pwm->chip.dev, "enable clock error\n"); > > Might be worth to include the error code in the error message to make it > easier to diagnose where the issue is. Something like: > > dev_err(atmel_pwm->chip.dev, "failed to enable clock: %d\n", err); > >> + return err; >> + } >> + } >> + >> + return 0; >> +} >> + >> static int atmel_pwm_probe(struct platform_device *pdev) >> { >> struct atmel_pwm_chip *atmel_pwm; >> @@ -504,6 +527,10 @@ static int atmel_pwm_probe(struct platform_device *pdev) >> >> platform_set_drvdata(pdev, atmel_pwm); >> >> + ret = atmel_pwm_enable_clk_if_on(atmel_pwm); >> + if (ret < 0) >> + goto unprepare_clk; > > This is not correct. You call this after pwmchip_add(), so you need to > make sure to also remove the PWM chip on error. Preferably, though, you > should call this before adding the PWM chip in the first place. Sorry, I will call this before adding the PWM chip in v2 patch. >> + >> return ret; >> >> unprepare_clk: >> -- >> 2.25.1 >> -- Regards, Guiting Shen