Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1105175pxu; Wed, 6 Jan 2021 12:23:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJy79DWrQXAGYewYUjQyhkONbe5QZz9pfZ1drUBeuTWTo9pQQV7ehgx++KbsvtV+JPPpswmy X-Received: by 2002:a17:906:a011:: with SMTP id p17mr3977978ejy.30.1609964619806; Wed, 06 Jan 2021 12:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964619; cv=none; d=google.com; s=arc-20160816; b=NqXR6Bg/TTbGSW++Nee/9BAmj0A5CdkDyWqNs5OTv5oMOwcwCFJteYZem3Z8U12+I/ so3Qx1Xv8ucxxPqJKbWn9dAu97Ls3QQFNCfTdQrqOBidun/uEjKmj58H0pwVkPhlJOXN 31+ywderqpaFRJzOUAJwuTu3CU3pRfPh85UrB1bsdHn7WgQhLJXam9ef1dzkLRvhMz/d EiCK5EnTbJtT9DWxlrTsihtSwjuoyC9YSegSsy4RIjVeI9pM9r7fsD9O60r5qrsL9LuQ JOpS/gWvGuOitIwu3GPtk2fPiDJkmzBZMAFUqEUalcHICgHZrLYJFD2Q6zCDm/mnHbRM s1xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=VJjWAUKmrzik59RShhOkoRJpaaStDjE9Ivpl3oRn+m8=; b=qEgRNJ1TRIMaAFOnpouG7CAE4Qn6CtxqRMPw/JcqXU8OFw3dkbshKzskxEOdF0y1FS h4UJpj5zMMypAm4NSf8Y+mcUKcL53aUT0IY/OxZiTA1BxKeY60xy8KicyGdocKnEP4N8 zL4C/L9OEJ4ieFFZ0+TPnKEsbI4nqyVXT+NBLf3eXsekAzIPdLW8Z/ziPRmaIbKNmmXd 2coo1Qgh1Q4bq1dycSP5EC1Z9LskM0Dh7U4T8WqEwlTsq4QiK1noT3MxFiriGx1+ZART 6I2hVKAARg+ttUE3SMauBBsNt49VyOvVmNFiqtOAPqpLWJDwIlDdpXa7a8Tl9AJrdl6o TqsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qo17si1293625ejb.296.2021.01.06.12.23.16; Wed, 06 Jan 2021 12:23:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbhAFUSn (ORCPT + 99 others); Wed, 6 Jan 2021 15:18:43 -0500 Received: from foss.arm.com ([217.140.110.172]:46940 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727477AbhAFUSn (ORCPT ); Wed, 6 Jan 2021 15:18:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 73478D6E; Wed, 6 Jan 2021 12:17:39 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F3983F85F; Wed, 6 Jan 2021 12:17:36 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, lukasz.luba@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, thara.gopinath@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, cristian.marussi@arm.com Subject: [PATCH v4 19/37] clk: scmi: port driver to the new scmi_clk_proto_ops interface Date: Wed, 6 Jan 2021 20:15:52 +0000 Message-Id: <20210106201610.26538-20-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210106201610.26538-1-cristian.marussi@arm.com> References: <20210106201610.26538-1-cristian.marussi@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Port driver to the new SCMI Clock interface based on protocol handles and common devm_get_ops(). Signed-off-by: Cristian Marussi --- drivers/clk/clk-scmi.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index c754dfbb73fd..9d5e1262673b 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -2,7 +2,7 @@ /* * System Control and Power Interface (SCMI) Protocol based clock driver * - * Copyright (C) 2018 ARM Ltd. + * Copyright (C) 2018-2020 ARM Ltd. */ #include @@ -13,11 +13,13 @@ #include #include +static const struct scmi_clk_proto_ops *clk_ops; + struct scmi_clk { u32 id; struct clk_hw hw; const struct scmi_clock_info *info; - const struct scmi_handle *handle; + const struct scmi_protocol_handle *ph; }; #define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw) @@ -29,7 +31,7 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw, u64 rate; struct scmi_clk *clk = to_scmi_clk(hw); - ret = clk->handle->clk_ops->rate_get(clk->handle, clk->id, &rate); + ret = clk_ops->rate_get(clk->ph, clk->id, &rate); if (ret) return 0; return rate; @@ -69,21 +71,21 @@ static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate, { struct scmi_clk *clk = to_scmi_clk(hw); - return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate); + return clk_ops->rate_set(clk->ph, clk->id, rate); } static int scmi_clk_enable(struct clk_hw *hw) { struct scmi_clk *clk = to_scmi_clk(hw); - return clk->handle->clk_ops->enable(clk->handle, clk->id); + return clk_ops->enable(clk->ph, clk->id); } static void scmi_clk_disable(struct clk_hw *hw) { struct scmi_clk *clk = to_scmi_clk(hw); - clk->handle->clk_ops->disable(clk->handle, clk->id); + clk_ops->disable(clk->ph, clk->id); } static const struct clk_ops scmi_clk_ops = { @@ -142,11 +144,16 @@ static int scmi_clocks_probe(struct scmi_device *sdev) struct device *dev = &sdev->dev; struct device_node *np = dev->of_node; const struct scmi_handle *handle = sdev->handle; + struct scmi_protocol_handle *ph; - if (!handle || !handle->clk_ops) + if (!handle) return -ENODEV; - count = handle->clk_ops->count_get(handle); + clk_ops = handle->devm_get_ops(sdev, SCMI_PROTOCOL_CLOCK, &ph); + if (IS_ERR(clk_ops)) + return PTR_ERR(clk_ops); + + count = clk_ops->count_get(ph); if (count < 0) { dev_err(dev, "%pOFn: invalid clock output count\n", np); return -EINVAL; @@ -167,14 +174,14 @@ static int scmi_clocks_probe(struct scmi_device *sdev) if (!sclk) return -ENOMEM; - sclk->info = handle->clk_ops->info_get(handle, idx); + sclk->info = clk_ops->info_get(ph, idx); if (!sclk->info) { dev_dbg(dev, "invalid clock info for idx %d\n", idx); continue; } sclk->id = idx; - sclk->handle = handle; + sclk->ph = ph; err = scmi_clk_ops_init(dev, sclk); if (err) { -- 2.17.1