From patchwork Sun May 28 19:58:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 686697 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB6C0C77B7C for ; Sun, 28 May 2023 19:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjE1T7B (ORCPT ); Sun, 28 May 2023 15:59:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjE1T7A (ORCPT ); Sun, 28 May 2023 15:59:00 -0400 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECF3A8 for ; Sun, 28 May 2023 12:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=+U75rpsQFDKe3AcAiSHeh2dlGhYJu9s1AK3whXkYPC8=; b=KGqT86654KJjNxKis/rbyMq5yj v0m99Sn9z5C7BM7fBN+Na2TUg6SsaAdy9Jm3nJ5JidHi2xNnv+n7j4GAY4tnccH+djx/lc07+tzp7 gcPtgJwlhCFrsGrqB5iNnVAuY/GWjIVhmcBaP+fuy2NP0bZbtw65imenhuYbxFlc9OKrb8ImrlIWi bajtIb4AHKuiVxSnymtejGWSHN2INfmFnlnhunR9ov6onuqmsvxvMkWiv46TGUHlc+haoaX4m+X69 n6e9RytNpffySY/Z5Uls1IJ3ey7LD8e5aPpOykZfiZpTiBrEVHF+xubch574GWXpWIbefZRWDwLHi IxDJX6Mg==; Received: from sslproxy04.your-server.de ([78.46.152.42]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q3MXY-0005NO-2F; Sun, 28 May 2023 21:58:55 +0200 Received: from [136.25.87.181] (helo=lars-desktop.lan) by sslproxy04.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3MXX-000DRD-9L; Sun, 28 May 2023 21:58:55 +0200 From: Lars-Peter Clausen To: Mark Brown Cc: Kunihiko Hayashi , linux-spi@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Date: Sun, 28 May 2023 12:58:28 -0700 Message-Id: <20230528195830.164669-1-lars@metafoo.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26921/Sun May 28 09:22:09 2023) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Replace the combination of devm_clk_get_enable() plus clk_prepare_enable() with devm_clk_get_enabled(). Slightly reduces the amount of boilerplate code. Signed-off-by: Lars-Peter Clausen --- drivers/spi/spi-sn-f-ospi.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c index a2bd9dcde075..39c4df54cdb8 100644 --- a/drivers/spi/spi-sn-f-ospi.c +++ b/drivers/spi/spi-sn-f-ospi.c @@ -634,18 +634,12 @@ static int f_ospi_probe(struct platform_device *pdev) goto err_put_ctlr; } - ospi->clk = devm_clk_get(dev, NULL); + ospi->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(ospi->clk)) { ret = PTR_ERR(ospi->clk); goto err_put_ctlr; } - ret = clk_prepare_enable(ospi->clk); - if (ret) { - dev_err(dev, "Failed to enable the clock\n"); - goto err_disable_clk; - } - mutex_init(&ospi->mlock); ret = f_ospi_init(ospi); @@ -661,9 +655,6 @@ static int f_ospi_probe(struct platform_device *pdev) err_destroy_mutex: mutex_destroy(&ospi->mlock); -err_disable_clk: - clk_disable_unprepare(ospi->clk); - err_put_ctlr: spi_controller_put(ctlr); @@ -674,8 +665,6 @@ static void f_ospi_remove(struct platform_device *pdev) { struct f_ospi *ospi = platform_get_drvdata(pdev); - clk_disable_unprepare(ospi->clk); - mutex_destroy(&ospi->mlock); } From patchwork Sun May 28 19:58:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 686830 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62A4C77B7E for ; Sun, 28 May 2023 19:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231416AbjE1T7C (ORCPT ); Sun, 28 May 2023 15:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjE1T7B (ORCPT ); Sun, 28 May 2023 15:59:01 -0400 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F5C3AC for ; Sun, 28 May 2023 12:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=NWmRmxfw/wubpKhJ52zXFZDg20szMw4ma7f74ukQbq8=; b=iAPKrjM+NqmdtYPrSkdD3PSp8D 7mJzGyXnvwG09TBEYU/+bAI+b5W0HVu0a264ilF7IIJZQizsmJ705glLLg+o7mg6MPeoEGMHqQrbD eXgqtqiwPGA0iMTagIBlsqK/2xhQZb3Zr7836i0wFrZocNh7SRJlztGBIYkZEWTC7qH3PA/8zEkE2 NwLwsGpuWCyAdzqBW2jPF66JZE40lVQVG/1QqD84kyPfssFd87+4xVT9egZBat4FkI/4MBBnjUQT4 oOgWHEI+YcZldkEchW/EtNpo6y3fGlDN44RospGlEAKXomd/Ih9DgmTk3113Ri1YYdEjd9lWRQnjn ClCMGVFw==; Received: from sslproxy04.your-server.de ([78.46.152.42]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q3MXb-0005Nn-97; Sun, 28 May 2023 21:58:58 +0200 Received: from [136.25.87.181] (helo=lars-desktop.lan) by sslproxy04.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3MXa-000DRD-GO; Sun, 28 May 2023 21:58:58 +0200 From: Lars-Peter Clausen To: Mark Brown Cc: Kunihiko Hayashi , linux-spi@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it Date: Sun, 28 May 2023 12:58:29 -0700 Message-Id: <20230528195830.164669-2-lars@metafoo.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230528195830.164669-1-lars@metafoo.de> References: <20230528195830.164669-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26921/Sun May 28 09:22:09 2023) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Use `min_t` instead of `min` with casting the individual arguments. Signed-off-by: Lars-Peter Clausen --- drivers/spi/spi-sn-f-ospi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c index 39c4df54cdb8..691b6092fb3f 100644 --- a/drivers/spi/spi-sn-f-ospi.c +++ b/drivers/spi/spi-sn-f-ospi.c @@ -566,7 +566,7 @@ static bool f_ospi_supports_op(struct spi_mem *mem, static int f_ospi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) { - op->data.nbytes = min((int)op->data.nbytes, (int)(OSPI_DAT_SIZE_MAX)); + op->data.nbytes = min_t(int, op->data.nbytes, OSPI_DAT_SIZE_MAX); return 0; } From patchwork Sun May 28 19:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 686696 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6835C7EE29 for ; Sun, 28 May 2023 19:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231428AbjE1T7D (ORCPT ); Sun, 28 May 2023 15:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjE1T7C (ORCPT ); Sun, 28 May 2023 15:59:02 -0400 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE90AA8 for ; Sun, 28 May 2023 12:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=UXudmQeh7gfIyadWcjx5EnvHJKgAxM35HUX3B2ZYOJo=; b=kp/ow0B9PiadbsdGqCSVgkMD6y j5b/6HtGGoqbLbugxnJXFPwQd3qq3CjXnd+pBPnUR1uQjENH9Huz785s4qPN36+66bemWP7kj1zP+ kwM30WpMRQqN0XFM1yKMen7aAe0Gs1hWrnxUTOTDujqQ2f+ryPoYOQ81MuJ4Qmc7xix6ir+WV+AG8 aIuoxRbpZlj7XLuGIxTDiEOsjPoN2JeL3/DNjoagG9tmrj0x8zWpRqIMMixgfAP1B9osqYzcIJRRx j357YAWqa859pPPmkhuQOemaJa+0g5egtujcS1oPurUt1WC5enBEKGbpvpOscfU6mK3800EkLzLWd 67X0UrKg==; Received: from sslproxy04.your-server.de ([78.46.152.42]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q3MXc-0005O5-HC; Sun, 28 May 2023 21:59:00 +0200 Received: from [136.25.87.181] (helo=lars-desktop.lan) by sslproxy04.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3MXb-000DRD-Nz; Sun, 28 May 2023 21:59:00 +0200 From: Lars-Peter Clausen To: Mark Brown Cc: Kunihiko Hayashi , linux-spi@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const Date: Sun, 28 May 2023 12:58:30 -0700 Message-Id: <20230528195830.164669-3-lars@metafoo.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230528195830.164669-1-lars@metafoo.de> References: <20230528195830.164669-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26921/Sun May 28 09:22:09 2023) Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The `width_available` array is currently placed on the `f_ospi_supports_op_width()` function's stack. But the array is never modified. Make it `static const`. This makes the code slightly smaller and more efficient. Signed-off-by: Lars-Peter Clausen --- drivers/spi/spi-sn-f-ospi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c index 691b6092fb3f..d64d3f75c726 100644 --- a/drivers/spi/spi-sn-f-ospi.c +++ b/drivers/spi/spi-sn-f-ospi.c @@ -526,7 +526,7 @@ static int f_ospi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static bool f_ospi_supports_op_width(struct spi_mem *mem, const struct spi_mem_op *op) { - u8 width_available[] = { 0, 1, 2, 4, 8 }; + static const u8 width_available[] = { 0, 1, 2, 4, 8 }; u8 width_op[] = { op->cmd.buswidth, op->addr.buswidth, op->dummy.buswidth, op->data.buswidth }; bool is_match_found;