Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5660812pxb; Mon, 28 Mar 2022 15:39:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgU8Bjb4D5YD2xjX+B/dxj178xzygBvQ1StyXgSfhx6hkcFXL/SDvoNfubqH7RF+AYJ+ga X-Received: by 2002:a17:90a:f2cd:b0:1c6:5a37:69ab with SMTP id gt13-20020a17090af2cd00b001c65a3769abmr1359837pjb.224.1648507155623; Mon, 28 Mar 2022 15:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648507155; cv=none; d=google.com; s=arc-20160816; b=KkLIY24TMe+TArhYlDXpEYOfrxFkcpukH2i0ZcClVU0eL54p0Ns04tQv9u5I9uSS1s SU+Q72+UqE2DT7LvsuR1R0i2pFyzS1iSmlA6F8gWE97/XeGylPsO8SAlB3ztC6pg0mZI P/enjr/HfaarQVGz6J/7gxrMGJvQcr3iAXCX6yRxWRc9Q78mtLTuECIE6lUeEkUndmRe qAvrPbI482x10vvghSq/updU7KRo7taU0Daqgjw40vWlK8hu+3SkpyctUaFmC2yjnDuv ciQ1uSbBVc7HuJavV1WhsM7ebM98rFmzETKPoSFgiX3sHJKhWRslP/BA9PkJBRFzvEcL oDmw== 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=RP5344hK4MoreMUhlLHhHnmvxDb96UG9Vm23YY7ClMI=; b=HF9vwv1wq11VgwJuD9j9oiVETfV3dplQm+kU4YVXCj3o0yEGBCMYqwDhrAg7ancZNX y0369Xn8a/Qp0MD8RfOk9XMW6ORhauXb5wUJdmbabHDCP6ZvAegNsiQpR9lzuHelUkXa crzR38lQYISor5dM19Sii/HUfDlTcBLXbvK9c7EdmWof2TN0CeXeA4dU9bPPdqG4L1QM nDkpkMGbHbrot0ke/MEHZ0c9BNqiN9mSBKMRTyI7fqFFS0ddG0lj30Sayn8G7/arXVz5 BxD6Ghx3zAg0ga9HTbU1e6ebjGftEDc5DcfXRWH5ZsNK2qV48krJogNfNd1O7JqV/ErW CNeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=QLs4Es4z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k65-20020a633d44000000b003982828d932si11635439pga.628.2022.03.28.15.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:39:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=QLs4Es4z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B0101FCD3A; Mon, 28 Mar 2022 14:47:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239592AbiC1Pqb (ORCPT + 99 others); Mon, 28 Mar 2022 11:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239117AbiC1PqK (ORCPT ); Mon, 28 Mar 2022 11:46:10 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 643AE4B1D9; Mon, 28 Mar 2022 08:44:19 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 581FF1E28D1; Thu, 24 Mar 2022 03:16:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 581FF1E28D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1648080995; bh=RP5344hK4MoreMUhlLHhHnmvxDb96UG9Vm23YY7ClMI=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=QLs4Es4z+zUl7MX4nf4fgSEiUM1tgPOmNZ+9WTmUPEDkOR3bAQslDo8S0E8CIbMzp vadx3mG38NwXQhQAeB+YlU2VTI5snpetSLMMf0UGG/sU3iWedM2IeDODyppk2Hb1Qp BUFFZP4HXIitjtTLzuoNkgGNkxTri0UkyiEAqrLA= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 24 Mar 2022 03:16:35 +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 06/21] ata: libahci_platform: Add function returning a clock-handle by id Date: Thu, 24 Mar 2022 03:16:13 +0300 Message-ID: <20220324001628.13028-7-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220324001628.13028-1-Sergey.Semin@baikalelectronics.ru> References: <20220324001628.13028-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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 --- 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 d805ddc3a024..4fb9629c03ab 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 point to the clock descriptor of the clock with + * 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