Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp633033iob; Wed, 4 May 2022 05:00:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUI7OEUbK1JWUDxK66MC9CWDHa2b3/+bvAESzHC9D5mPjmV4Mr+BwSw8qKqn0280uzOW5y X-Received: by 2002:a17:907:7f12:b0:6f4:57e7:b20a with SMTP id qf18-20020a1709077f1200b006f457e7b20amr12042924ejc.538.1651665629051; Wed, 04 May 2022 05:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651665629; cv=none; d=google.com; s=arc-20160816; b=Z9m5SXDnR/VPBHM80fi8MF49VcB/JPnzpPku3mHYGUeLmpifoaGk8E3z2ZRGgdFuRK 8/yx/lmUbFOeuIjPDuNjokiXWYd+9ZEIy4VHW/tFKPZdMqGP0sarngarxLE7vjYUssOf 6FIj2En3VF4zM/EFOzhvhCDaPlT39Py1ExOxZ4G8lxj8wC4DJsknwXVklqVclrR+ab8b 7tzhORDQ0/pxoJXGC0t3n3InnlPT5SvmUDRHdBLhSFjSx29zyWVU4atih6RiradNnpQF 55NfI/xOoqIsIslG57dMWURI+xuGNC4Hh+odeKUG1r2RkggzC16mN+ea5Qo2VeeMPOJP Ldow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=6HMO+sQEG0eDggOCw6HtXOnAgHhA4OiT4KgL3s0gPcs=; b=WN00B0+i6txENiKH19orFqIAVh0oGvwHyQp0vPOt9LCP44bUDTJ3yhzA2Ur9msCuDb dkmOWMdReulgxEiOJI/LaWV681Qe0ogG2c5XZkzd8I3KSMnVANdlb+VB7xLKQVwy4xcR gd9h4kiymrMpzt8WWKJnatCs8pjS9AwvVvax9e2FG12u1R/H7MlOCYGbL64WjfipuXZ7 iNnblb5XKy6tntuaQmhbc7fUdWAYjLmaQYwazLfH9+9Sc+/d5GJ3QznU540rVs/e0quN 1TiPmhH7VdDuAGgtnm3boPbTPSwd2uIAKIVHdcxaCVxd0NhhRkrBIuiYm5Z+frD9I5im sYGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=kQYuIWdE; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ks13-20020a170906f84d00b006e8a7c59771si15820061ejb.237.2022.05.04.05.00.03; Wed, 04 May 2022 05:00:29 -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=@baikalelectronics.ru header.s=mail header.b=kQYuIWdE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242273AbiECUOZ (ORCPT + 99 others); Tue, 3 May 2022 16:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237775AbiECUNn (ORCPT ); Tue, 3 May 2022 16:13:43 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7585E3FBE9; Tue, 3 May 2022 13:10:08 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id D759E16DE; Tue, 3 May 2022 23:10:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru D759E16DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651608640; bh=6HMO+sQEG0eDggOCw6HtXOnAgHhA4OiT4KgL3s0gPcs=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=kQYuIWdEZhdQzY0Q7MIEq0udyTHAxSDmDL5hKSD55Zbst4pfmdEt1NVgoSodBDCIh rcjVd3V0RmC6RjgIP4M2RQBWXe5zLORMxpL8e0N5MNaEZb43e0VeD5cKIKQfw2xNC6 E68zGMYsRKqkn0LXeWt1SlLMzgVJcwY+sJuDPprM= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 3 May 2022 23:10:06 +0300 From: Serge Semin To: Damien Le Moal , Hans de Goede , Jens Axboe CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Rob Herring , , , Subject: [PATCH v2 08/23] ata: libahci_platform: Add function returning a clock-handle by id Date: Tue, 3 May 2022 23:09:23 +0300 Message-ID: <20220503200938.18027-9-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220503200938.18027-1-Sergey.Semin@baikalelectronics.ru> References: <20220503200938.18027-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Since all the clocks are retrieved by the method ahci_platform_get_resources() there is no need for the LLD (glue) drivers to be looking for some particular of them in the kernel clocks table again. Instead we suggest to add a simple method returning a device-specific clock with passed connection ID if it is managed to be found. Otherwise the function will return NULL. Thus the glue-drivers won't need to either manually touching the hpriv->clks array or calling clk_get()-friends. The AHCI platform drivers will be able to use the new function right after the ahci_platform_get_resources() method invocation and up to the device removal. Signed-off-by: Serge Semin --- Changelog v2: - Fix some grammar mistakes in the method description. --- drivers/ata/libahci_platform.c | 27 +++++++++++++++++++++++++++ include/linux/ahci_platform.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 3cff86c225fd..7ff6626fd569 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -94,6 +94,33 @@ void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) } EXPORT_SYMBOL_GPL(ahci_platform_disable_phys); +/** + * ahci_platform_find_clk - Find platform clock + * @hpriv: host private area to store config values + * @con_id: clock connection ID + * + * This function returns a pointer to the clock descriptor of the clock with + * the passed ID. + * + * RETURNS: + * Pointer to the clock descriptor on success otherwise NULL + */ +struct clk *ahci_platform_find_clk(struct ahci_host_priv *hpriv, const char *con_id) +{ + struct clk *clk = NULL; + int i; + + for (i = 0; i < hpriv->n_clks; i++) { + if (!strcmp(hpriv->clks[i].id, con_id)) { + clk = hpriv->clks[i].clk; + break; + } + } + + return clk; +} +EXPORT_SYMBOL_GPL(ahci_platform_find_clk); + /** * ahci_platform_enable_clks - Enable platform clocks * @hpriv: host private area to store config values diff --git a/include/linux/ahci_platform.h b/include/linux/ahci_platform.h index 49e5383d4222..fd964e6a68d6 100644 --- a/include/linux/ahci_platform.h +++ b/include/linux/ahci_platform.h @@ -13,6 +13,7 @@ #include +struct clk; struct device; struct ata_port_info; struct ahci_host_priv; @@ -21,6 +22,8 @@ struct scsi_host_template; int ahci_platform_enable_phys(struct ahci_host_priv *hpriv); void ahci_platform_disable_phys(struct ahci_host_priv *hpriv); +struct clk * +ahci_platform_find_clk(struct ahci_host_priv *hpriv, const char *con_id); int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv); -- 2.35.1