From patchwork Mon Feb 14 14:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12745652 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 17BE7C433EF for ; Mon, 14 Feb 2022 14:05:23 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=e1DXMtLLuYxWL5rUpqWeBOO/13aosmK6kn2xwAvNsbM=; b=FWoFOSD0Hqh2s7 HgzJ6lE801tMZlylwU4UpxMrr5buCkBR8xjvj5ejVHSZdydh+BMWPOcJIjy9jm+D76eUD0Tc2DA5w z/ZfxV5r4ldsplnWH3kBc9fBAmDPZE2rXyfbxz7S92Wchpa5rbUkF4Ca78/j1HkAJeP6NLtbkLKqP 9L3C0yiSF1ZAJdplLXRmxeaHdrj0tHTr4GvbSa7yT5Gsw/fvgUruFKg5plnldkmYofPvodUrEmBBI kH8bIaMxppr23ZMtQd/seLIAjZZO7djEKw8rLYjtwe0ZGkhIoHW1bAGZVpvQ1KtGodPljLx4SvELm mzNK/L/y2SDcq1LcVqGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxX-00FYu3-6z; Mon, 14 Feb 2022 14:04:07 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxD-00FYmr-Tl; Mon, 14 Feb 2022 14:03:49 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id E600A1F417FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644847425; bh=QaLaTj9ziNtqxf12oz66KYW1D7p03OX8Bk66flIHsxs=; h=From:To:Cc:Subject:Date:From; b=IiLx73dq4wyKSkdrAxRCsYed1Zpv5mkzLr5ixnDofJ6LIi5Gp/scc2V/6seFoGTbD 0JeOtZrdJQnmrVFPgJaEcbng/zlJ3X5WkP4zV+bWCJX8DjiRAwkSuquklkDtMCTIXT YiBAgFXOzEJ9nW7jRJF0GW28e4FnFDZLrvwYIBiXXp1C6Syw44mn7xtIi9ncE+jAyU q2tpv2InOkV3ykX4R398AWYmVyCUmlULeD2I5nqjKcbD1KFnHO6nUAgFXmq5c8/Lp8 gIyZxUdgDX+LUqn5cYos3bA0FnuNIFMRNfVpILa+Q4dR7r/RvAV5F6MXGF3mu3oMPb eRrgGYgpyqz+A== From: AngeloGioacchino Del Regno To: thierry.reding@gmail.com Cc: u.kleine-koenig@pengutronix.de, lee.jones@linaro.org, matthias.bgg@gmail.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 1/3] pwm: pwm-mediatek: Simplify error handling with dev_err_probe() Date: Mon, 14 Feb 2022 15:03:37 +0100 Message-Id: <20220214140339.112500-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220214_060348_108943_F6023E51 X-CRM114-Status: GOOD ( 10.64 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use dev_err_probe() to simplify handling errors in pwm_mediatek_probe(). Signed-off-by: AngeloGioacchino Del Regno --- drivers/pwm/pwm-mediatek.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 0d4dd80e9f07..c7d5ca09a684 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -227,18 +227,14 @@ static int pwm_mediatek_probe(struct platform_device *pdev) return -ENOMEM; pc->clk_top = devm_clk_get(&pdev->dev, "top"); - if (IS_ERR(pc->clk_top)) { - dev_err(&pdev->dev, "clock: top fail: %ld\n", - PTR_ERR(pc->clk_top)); - return PTR_ERR(pc->clk_top); - } + if (IS_ERR(pc->clk_top)) + return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_top), + "clock: top failed\n"); pc->clk_main = devm_clk_get(&pdev->dev, "main"); - if (IS_ERR(pc->clk_main)) { - dev_err(&pdev->dev, "clock: main fail: %ld\n", - PTR_ERR(pc->clk_main)); - return PTR_ERR(pc->clk_main); - } + if (IS_ERR(pc->clk_main)) + return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_main), + "clock: main failed\n"); for (i = 0; i < pc->soc->num_pwms; i++) { char name[8]; @@ -246,11 +242,9 @@ static int pwm_mediatek_probe(struct platform_device *pdev) snprintf(name, sizeof(name), "pwm%d", i + 1); pc->clk_pwms[i] = devm_clk_get(&pdev->dev, name); - if (IS_ERR(pc->clk_pwms[i])) { - dev_err(&pdev->dev, "clock: %s fail: %ld\n", - name, PTR_ERR(pc->clk_pwms[i])); - return PTR_ERR(pc->clk_pwms[i]); - } + if (IS_ERR(pc->clk_pwms[i])) + return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_pwms[i]), + "clock: %s failed\n", name); } pc->chip.dev = &pdev->dev; @@ -258,10 +252,8 @@ static int pwm_mediatek_probe(struct platform_device *pdev) pc->chip.npwm = pc->soc->num_pwms; ret = devm_pwmchip_add(&pdev->dev, &pc->chip); - if (ret < 0) { - dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, "pwmchip_add() failed\n"); return 0; } From patchwork Mon Feb 14 14:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12745651 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 A4BEDC433F5 for ; Mon, 14 Feb 2022 14:05:11 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VqK+9n2ZpeBbQqj7lqt4O4BkapssGdLfPpeutCypiyI=; b=sqW10k/eakAefe KY9St2Rc/3xUpV1zkFDDTREu252oHeKDUMXTtfqHt7gzyLUxei2BgL8WdNlkpuvU8aFTIUpJhDCGY oQge9ebJ/V7zqOHTSy6Yc2p/NEKaSNvZG1ve9orGz/NpeDlkKgzBmMCrufUlgBm/l7n0vzXm3i8MP WtzJaDj3M+KnHpfDyLFfi0hd5/gxY5kXgqxPaO4x6bw+ah+z6VSKcXo6mo/dfcbgXkqLZHz+pxx8E PJIU6S3Nqi2EWyceEzqL2Vh59Qe3qraxgN5A6iE9nV7+D6Sa8yAW+uELzoftczs8ngO/j9T7rCWI0 531pW9gpBJCrf6d6Un4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxH-00FYoL-OH; Mon, 14 Feb 2022 14:03:51 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxD-00FYmy-Gv; Mon, 14 Feb 2022 14:03:49 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id AABB41F437CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644847426; bh=+h64QsZ/rfjOYapg2dVyfjUfA0g+jFxUuPrgfX0vMwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kz+56Zkseu07eayLKtzfXRGwHhVVEPtMd7EfOzaTCgNvS/tlR0YB5ZLzumqNbL72C KpK2z0JdkUaHFbs6Y6k4Rj8oHK1SEcrYanrMYLzmXWq71AYXHvcVrKtdCGFAksQ2Gg GcROODf6knMnMYyFdKtY9b56jbg2tpjb/VRiFAJKH66skWbfiIQcE4IY/IIooDVPTU gtr9A3VpWetF7MHF7wXfwmT9DEuG3cO0QcqkRFSRl9nCobdmBKCjIeLgDj+e+CFJ8O V4SUKYSbubs7FVq4PigtyYUnIvTw0CWmSsGBZi3M0KAb59PcpXRWqShWGoYyirgoBS rfNDOnI0eh9tg== From: AngeloGioacchino Del Regno To: thierry.reding@gmail.com Cc: u.kleine-koenig@pengutronix.de, lee.jones@linaro.org, matthias.bgg@gmail.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 2/3] pwm: pwm-mediatek: Allocate clk_pwms with devm_kmalloc_array Date: Mon, 14 Feb 2022 15:03:38 +0100 Message-Id: <20220214140339.112500-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220214140339.112500-1-angelogioacchino.delregno@collabora.com> References: <20220214140339.112500-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220214_060348_102495_9A69ABD0 X-CRM114-Status: GOOD ( 10.03 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch from devm_kcalloc to devm_kmalloc_array when allocating clk_pwms, as this structure is being filled right after allocating it, hence there is no need to zero it out beforehand. Signed-off-by: AngeloGioacchino Del Regno --- drivers/pwm/pwm-mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index c7d5ca09a684..6b39f3d69e41 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -221,7 +221,7 @@ static int pwm_mediatek_probe(struct platform_device *pdev) if (IS_ERR(pc->regs)) return PTR_ERR(pc->regs); - pc->clk_pwms = devm_kcalloc(&pdev->dev, pc->soc->num_pwms, + pc->clk_pwms = devm_kmalloc_array(&pdev->dev, pc->soc->num_pwms, sizeof(*pc->clk_pwms), GFP_KERNEL); if (!pc->clk_pwms) return -ENOMEM; From patchwork Mon Feb 14 14:03:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12745653 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 62CBBC433F5 for ; Mon, 14 Feb 2022 14:05:48 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iROHOupLwOAzYxkZEqDs04XOzMOsH5tCwnX6gIzTeAE=; b=EzYpd1b77Mp3GK 3cmTH0jh4pTQDvbTJE12TEBg8ngd/xMsXRbCsSnPJJ+Fsjj1m70qogr72a+YppofkbTKSioSilv90 npK+GV0EcpCa588DDXwfjZ0jsXuRh4WtwB0bGV6jzbX2PlvEVd2q8Xf57T2O20e3za8p2dq7bIzB4 0wU0oJlPm7JKiCpV+YvRQj13msB0PkM/6+DWqrKb1tGmKsuN0Cvvixtkyr6kUb12BHLPjbX297D0p soaYlRr5PJJ3tnb2+hRB9vS8tzo3jFsuON2xsZFuFq1mZ2HWqVKxbvYqeZTaOVY5QLPig8eEU4w1J f/jFd3KXHuPfl+j3DisA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxn-00FZ2c-It; Mon, 14 Feb 2022 14:04:23 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJbxE-00FYn1-70; Mon, 14 Feb 2022 14:03:50 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 6C8D31F437D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644847427; bh=wFNgkqGiONoneW7J7GAtmcWU3v7pj9r5c0V0Os6wFU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OUG+pRD5LFzg0JNUMPwO8D3H1M9GSWqUTPtDByjaPj95ISZWa4Pvs4Fd0wkQWzBcF dgJ9fdDzLdJWCXfJpfvfH2uipWAipJtTSKdsA1t6BXNN57RCoE1+ixwBUXhBtR89Bx d6hz0MguCsVR07zG1aERD8kW7FKTrABhs41a7UPhKe+3IdEkWw74KtSXTsuK3Dqsfr HLz0KaN1BN25jpW0Wz2QihHbm2uHudnjZ45SCZX7g3TzIcsGBI+M93VuT7/Q+HMv70 YV2qBURT/u4kLKpL9GGXBcF5PW6mL1hGoRoxkh3OItUGA2hF9Kzvwz2L+ENRnV/dKo i2hKFQGJ7l7Jg== From: AngeloGioacchino Del Regno To: thierry.reding@gmail.com Cc: u.kleine-koenig@pengutronix.de, lee.jones@linaro.org, matthias.bgg@gmail.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v2 3/3] pwm: pwm-mediatek: Beautify error messages text Date: Mon, 14 Feb 2022 15:03:39 +0100 Message-Id: <20220214140339.112500-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220214140339.112500-1-angelogioacchino.delregno@collabora.com> References: <20220214140339.112500-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220214_060348_412622_10669927 X-CRM114-Status: GOOD ( 11.28 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As a cherry-on-top cleanup, make error messages clearer to read by changing instances of "clock: XXXX failed" to a more readable "Failed to get XXXX clock". Also add "of" to unsupported period error. This is purely a cosmetic change; no "real" functional changes. Signed-off-by: AngeloGioacchino Del Regno --- drivers/pwm/pwm-mediatek.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 6b39f3d69e41..568b13a48717 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -146,7 +146,7 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, if (clkdiv > PWM_CLK_DIV_MAX) { pwm_mediatek_clk_disable(chip, pwm); - dev_err(chip->dev, "period %d not supported\n", period_ns); + dev_err(chip->dev, "period of %d ns not supported\n", period_ns); return -EINVAL; } @@ -229,12 +229,12 @@ static int pwm_mediatek_probe(struct platform_device *pdev) pc->clk_top = devm_clk_get(&pdev->dev, "top"); if (IS_ERR(pc->clk_top)) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_top), - "clock: top failed\n"); + "Failed to get top clock\n"); pc->clk_main = devm_clk_get(&pdev->dev, "main"); if (IS_ERR(pc->clk_main)) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_main), - "clock: main failed\n"); + "Failed to get main clock\n"); for (i = 0; i < pc->soc->num_pwms; i++) { char name[8]; @@ -244,7 +244,7 @@ static int pwm_mediatek_probe(struct platform_device *pdev) pc->clk_pwms[i] = devm_clk_get(&pdev->dev, name); if (IS_ERR(pc->clk_pwms[i])) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk_pwms[i]), - "clock: %s failed\n", name); + "Failed to get %s clock\n", name); } pc->chip.dev = &pdev->dev;