Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1103921pxu; Wed, 6 Jan 2021 12:21:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNHopE5sEPpp6ul98eCn1PlU7cGNHOg8tT95KYbQGxw5wjEySRO4yfDsTgg0n6ZyA9m+c1 X-Received: by 2002:a17:906:94ca:: with SMTP id d10mr3857263ejy.62.1609964498353; Wed, 06 Jan 2021 12:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964498; cv=none; d=google.com; s=arc-20160816; b=KK1wNsjmUb3OmKzC30zCw6JYj6tMQ9sYiDda5WvQsPKhUwNLIhdE50oM2ZJVfLi9/w I216CBA9Fk/bGGy5m5xJy548IRhc2DYY1mOkfH/SF8+33NFQMREajN3SGK0zCnoJ/vIj OxyjSNVzvyeHwWEf7ESWXeADb2aBGxl5VoOtpuErqh2S2bjEUCnkb5d0oiNTC9BioYOl yE7lhkhKf+dS6ZzyFAW/Elg5qdlHkjovZLnDqtxPugW+W7xC856MxFefZu8iRr0AdndY j41Ix32GqynsNKA89IsDPztcYg0h7dan3hPrePkY7ni5YIkW+dNwNZcSo3sJumDJ/wTD FpNQ== 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=Cr5lDumL1Qw6AEripWsQ67K5c0Pf9+JbU8NSqzZ+NO8=; b=vKZrJkGl2zc0zNZuejt0Sy7wFs6s2ZeUsnoHFGbZEv6BkU34U2eJZuLr3hUpKcvWPY ldu8PZQNgwZuT/+PIonMgajOKCV0Yy/8doPIc5zoHHpM7hu1CnQJ9HzvybzUMts7vjgF Y3t3zvfkt56E5XpLyObDD7XNcJpezTOE9iOVJWokTe2m3qRVYY5B6wgTPSjvO04Gn7oG Agh47onVy3gtyC90CbQceuu6dwMnhDWBkvdgJx3SAC/gvult1uegonVe2CHk7kba0Dek o/WnGgmmifsb4Pr5SDcx8vMhLSlxV4lAjsW/2/lCx9U3SbeA/VZrvbH6MFGdYLEKJuS7 0ItA== 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 zc2si1219684ejb.427.2021.01.06.12.21.14; Wed, 06 Jan 2021 12:21:38 -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 S1727667AbhAFUSp (ORCPT + 99 others); Wed, 6 Jan 2021 15:18:45 -0500 Received: from foss.arm.com ([217.140.110.172]:46938 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbhAFUSn (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 BA9B014F6; Wed, 6 Jan 2021 12:17:30 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 868CB3F719; Wed, 6 Jan 2021 12:17:28 -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 16/37] firmware: arm_scmi: port GenPD driver to the new scmi_power_proto_ops interface Date: Wed, 6 Jan 2021 20:15:49 +0000 Message-Id: <20210106201610.26538-17-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 Power interface based on protocol handles and common devm_get_ops(). Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/scmi_pm_domain.c | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c index 9e44479f0284..564bb4d56d9a 100644 --- a/drivers/firmware/arm_scmi/scmi_pm_domain.c +++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c @@ -2,7 +2,7 @@ /* * SCMI Generic power domain support. * - * Copyright (C) 2018 ARM Ltd. + * Copyright (C) 2018-2020 ARM Ltd. */ #include @@ -11,9 +11,11 @@ #include #include +static const struct scmi_power_proto_ops *power_ops; + struct scmi_pm_domain { struct generic_pm_domain genpd; - const struct scmi_handle *handle; + const struct scmi_protocol_handle *ph; const char *name; u32 domain; }; @@ -25,16 +27,15 @@ static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on) int ret; u32 state, ret_state; struct scmi_pm_domain *pd = to_scmi_pd(domain); - const struct scmi_power_ops *ops = pd->handle->power_ops; if (power_on) state = SCMI_POWER_STATE_GENERIC_ON; else state = SCMI_POWER_STATE_GENERIC_OFF; - ret = ops->state_set(pd->handle, pd->domain, state); + ret = power_ops->state_set(pd->ph, pd->domain, state); if (!ret) - ret = ops->state_get(pd->handle, pd->domain, &ret_state); + ret = power_ops->state_get(pd->ph, pd->domain, &ret_state); if (!ret && state != ret_state) return -EIO; @@ -60,11 +61,16 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) struct genpd_onecell_data *scmi_pd_data; struct generic_pm_domain **domains; const struct scmi_handle *handle = sdev->handle; + struct scmi_protocol_handle *ph; - if (!handle || !handle->power_ops) + if (!handle) return -ENODEV; - num_domains = handle->power_ops->num_domains_get(handle); + power_ops = handle->devm_get_ops(sdev, SCMI_PROTOCOL_POWER, &ph); + if (IS_ERR(power_ops)) + return PTR_ERR(power_ops); + + num_domains = power_ops->num_domains_get(ph); if (num_domains < 0) { dev_err(dev, "number of domains not found\n"); return num_domains; @@ -85,14 +91,14 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) for (i = 0; i < num_domains; i++, scmi_pd++) { u32 state; - if (handle->power_ops->state_get(handle, i, &state)) { + if (power_ops->state_get(ph, i, &state)) { dev_warn(dev, "failed to get state for domain %d\n", i); continue; } scmi_pd->domain = i; - scmi_pd->handle = handle; - scmi_pd->name = handle->power_ops->name_get(handle, i); + scmi_pd->ph = ph; + scmi_pd->name = power_ops->name_get(ph, i); scmi_pd->genpd.name = scmi_pd->name; scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_on = scmi_pd_power_on; -- 2.17.1