Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2415979rwn; Fri, 9 Sep 2022 13:25:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6t1H11XdC3eBrzL5r47OCQxQxT6ozBFJMitSHcGSDjbAMIWQ1ObDp+df/hoQcHso23R2Dg X-Received: by 2002:a17:907:868b:b0:741:8f6b:187c with SMTP id qa11-20020a170907868b00b007418f6b187cmr11329548ejc.188.1662755143162; Fri, 09 Sep 2022 13:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662755143; cv=none; d=google.com; s=arc-20160816; b=mqhnS3KQvwWlMEssktigxge0xbIyhIcNqSwl0MByu49JZBeIicXkxUApOAksA7q5Sw K2+HwBK0VLJJo1fik+obID1/BqPEF8pVYj+F0drHzEpJBWXsWWLZRMIgaE4RhY37TDmx 7DukpZL4hcZuRUuTD7giANWCj9WMFLfUtQBpsseIcpyPZbOcSXCLi/iuPv7mYkLj1MJ/ r+0wQmGHCcMnSGpCUrUu1t0SjNXMRL734jsjd++y+BzuNNFwchuxcFMZsS5G8f2rldxt bJo6Tl5B431n7cfrXdNtnyubrChfJw4oRqtNAmGV4A9PbyiqoMIJlKGKnWqZbJxMp3SZ CiTA== 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=tSsMfF1s5Ux6xk0N3ZRzC7OTKA8znIR4lsF8Oe1CY5A=; b=MNX4TbxbrQZYzIKly8Tgj3qGzsuvVc3OaNXz3BwYtxDtGibg3fsSl5FuHLeWX8PzNE xRV6oBje+8hU6V+Cpp7N97Eds1yX/POmv/6eLqM/FWX+9IFSYB3dJ+Hs2fmZMffGx7TB I0lrUnuin6Clh6bA97YFyqK+IajDTM5lCup1BYQOc5vzSg2BsjUn50ASxodqrrI7g93m ScPcBIiYCZTNw79uMo8J0P5MxeyMPMPRu7NGhljljmdB6Mdwsyu4TuMiS+Y/Bx0TpfkL XivCG0ZfITa3pPEWiT07Ddk5Wv27Lv5tVLcYJBKXwqDZwn9M/n2Jj1v7G0yzyBGVk1M7 ImbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=Ov8Kkd5C; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a170906470600b0077584ae7a40si1179912ejq.627.2022.09.09.13.25.18; Fri, 09 Sep 2022 13:25:43 -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=Ov8Kkd5C; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232078AbiIITim (ORCPT + 99 others); Fri, 9 Sep 2022 15:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbiIIThx (ORCPT ); Fri, 9 Sep 2022 15:37:53 -0400 Received: from mail.baikalelectronics.com (mail.baikalelectronics.com [87.245.175.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B56EA131EE4; Fri, 9 Sep 2022 12:36:53 -0700 (PDT) Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id F2856DC5; Fri, 9 Sep 2022 22:40:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com F2856DC5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1662752432; bh=tSsMfF1s5Ux6xk0N3ZRzC7OTKA8znIR4lsF8Oe1CY5A=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Ov8Kkd5Cjpw5NKlAx+XL4mx/jUkM8JMigsPJOyvLm3T4sw57hLag3CgCWRqLFqbGQ x+WuTPVjHcsgR3XU9AEk1FFho2m9Jx5UEMwQuPbOpPc1PoCxbZTfma4OvsvhQKa0Ej FoIxGm71HPLWc0xzynH8VKDMtTsJ9I9yD+7L3tks= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Sep 2022 22:36:44 +0300 From: Serge Semin To: Damien Le Moal , Hans de Goede , Jens Axboe , Hannes Reinecke CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Rob Herring , Krzysztof Kozlowski , , , Subject: [PATCH v8 18/23] ata: libahci_platform: Add function returning a clock-handle by id Date: Fri, 9 Sep 2022 22:36:16 +0300 Message-ID: <20220909193621.17380-19-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220909193621.17380-1-Sergey.Semin@baikalelectronics.ru> References: <20220909193621.17380-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_PASS,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. Note the method is left unused here, but will be utilized in the framework of the DWC AHCI SATA driver being added in the next commit. Signed-off-by: Serge Semin --- Changelog v2: - Fix some grammar mistakes in the method description. Changelog v4: - Add a note regarding the new method usage. Changelog v5: - Fix the ahci_platform_find_clk() declaration identations. (@Damien) - Simplify the ahci_platform_find_clk() method body by dropping the local poiter to clk structure. (@Damien) --- drivers/ata/libahci_platform.c | 24 ++++++++++++++++++++++++ include/linux/ahci_platform.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 86d156075336..ddf17e2d266c 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -93,6 +93,30 @@ 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) +{ + int i; + + for (i = 0; i < hpriv->n_clks; i++) { + if (!strcmp(hpriv->clks[i].id, con_id)) + return hpriv->clks[i].clk; + } + + return NULL; +} +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 6d7dd472d370..17fa26215292 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_deassert_rsts(struct ahci_host_priv *hpriv); -- 2.37.2