From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32BF4C04FDF for ; Tue, 11 Jul 2023 02:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A1d0B3v6TLgEAj4By1x5f6SWTZzKBOSrFEln/blp9dk=; b=XXgZ9LGIOO4wF3 tLZy5Duws9sKKrGqkQBmUlzSdtW3DvLo8/hEprNqqbQxFiB3HWUApCcBXzq+0DYBtneiT/9zJNX8D vbXzZXhofbFF32+Iga/pLbviyJORPDNQ9shN5ahxl3WeGc+MANEb8wDsJZUAT15gsaq3YP0HIrAQg NwD+LbnWL1A+sbz9SYAkVaO6OiT1omHfzvzD2zs9JNXCBUhDAZLapLOoJn0vs1UnWpwlUIP/OSypB NgUubvVpzXbDkibzTD6ux7Q/jsBePXB112AN0L4R4XRVzX3UVy/MXculfSi0cENURON3JC3j1Rv+x g6Hr4z73zsGSC4WxLMTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJ39w-00DKFm-30; Tue, 11 Jul 2023 02:31:24 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJ39t-00DKF8-2d for linux-arm-kernel@lists.infradead.org; Tue, 11 Jul 2023 02:31:23 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3a3c78ede4bso4000873b6e.2 for ; 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=TcwIWB9OJB3yyQpDsJuucOhQGvkBykvHD+Hfoi16yMqfqk/L7HZy4zzZRs1c3kJKao DYr1ygogO2zOXkhgoBK332Um0rqImBEyxp2C5l3ITE+gbsIn4elKvEVVg+mGp/ui8hjG xtch+mDixWyqpo0Wlh94AkNE2IbqqKm5Ep8nbOVFUt5lZon1zvki2QCenY8IezzhzZzV Iuvjs3Kzy67BjI+l3kIjv7KlUObHBTdCnzoPvxAB29Z9qpsUulLQqRqc/rm5BobHKSEp Y40TwO9TV1lMY7vmkME37jpXJYPRlFFtaxOw19hFvixy9BiTd+rA9PA3rq5h67N9yWcl /W6w== X-Gm-Message-State: ABy/qLbPIn0LedzY1yhPKjPaJZhe4HcB+Vc6mKjvMbbWh5q9kBKAaICL AWXdvhu9zk5R4zhOAt9wN6M= X-Google-Smtp-Source: APBJJlF69HmcE9pA9bI0uyTf9CZoeAAH0AkorKJeTM4T0kEzUpLX5q1z7+3fh4uJqexowXW1QwAixA== 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 References: <20230710144214.63343-1-aarongt.shen@gmail.com> From: Guiting Shen In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230710_193121_861108_285DBDF0 X-CRM114-Status: GOOD ( 31.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, u.kleine-koenig@pengutronix.de, claudiu.beznea@microchip.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel