Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1103480pxu; Wed, 6 Jan 2021 12:20:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwul9dy+suI7/ZlAQFTe1BTq77vXxyqua/iYfscno5Igf9ero0131IRC7yqSh+5E4XFJKaa X-Received: by 2002:a05:6402:3c3:: with SMTP id t3mr5231238edw.86.1609964456792; Wed, 06 Jan 2021 12:20:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964456; cv=none; d=google.com; s=arc-20160816; b=mzcyXApjJc6FETVWx12beveP5Mzboo8GMpokyj4nvFePmdCRegQJvrjlzXvg7lR+3M 6cLrP4bZVK/KvlshEGGRnn9CYx2HsV8gP5IeBjPRVKiHgxRj+wGkm1LV2DkEJkvojRWy IZU9hho36TDcURKFbFFQOZVXPPbUpOzeLuvtl6gTXAnAh6I/7qU/NQF21eSilHYdoz6n VfdJARvt/eN2eTnguCZchMA83gw1uTg5mbMobuGHsG1gyPX4ArZw41eV96k89y0CrScK du1YAasvC7rQTWKha4pQPQvN+lUG+kqO3HCkUWBGBHeP2mOtg9+lkEO4ZBkowceghVAO BwFw== 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=tOGCItcwQaD0J3iCdRnVccLfoNDhk4h2ofBhQQhyX3M=; b=irdYvvjKqxjbqKgrvignyLOmBF+6AJ6TKOaxIqXc2aoZtk2z4HOdSqVvCjR0mjNV8i VGjP7onTCjvuOKgW/NtMc0vRrWNMkbxS+c+ekgxk+3qvAxogrkaS0CjmfhTzc/xXjfQu YgaJgU5xUmiKOjuZ0JS+q0rgGqfUMxQxw27G6HEoYK86KRPXM2urb7UCjbmaI5JGN7w9 Yfs45lpmLaGr3zhc/D0Ku6wY8SgPEW1J55cxsYUui4C9fLjOIBOWJmDO9pu/oYYgPfXR IwR/avFTYYn2/SMEED+zZE/w6guD2s01PRLN9k87VyPBRz0sZh+hXgZn6Khk1N6HmMty Geqg== 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 hh2si1340252ejb.627.2021.01.06.12.20.33; Wed, 06 Jan 2021 12:20:56 -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 S1727721AbhAFUSv (ORCPT + 99 others); Wed, 6 Jan 2021 15:18:51 -0500 Received: from foss.arm.com ([217.140.110.172]:46968 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbhAFUSs (ORCPT ); Wed, 6 Jan 2021 15:18:48 -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 53B631529; Wed, 6 Jan 2021 12:17:57 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2DF913F719; Wed, 6 Jan 2021 12:17:53 -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 25/37] hwmon: (scmi) port driver to the new scmi_sensor_proto_ops interface Date: Wed, 6 Jan 2021 20:15:58 +0000 Message-Id: <20210106201610.26538-26-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 Sensor interface based on protocol handles and common devm_get_ops(). Signed-off-by: Cristian Marussi --- drivers/hwmon/scmi-hwmon.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 17d064e58938..399011740b00 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -2,7 +2,7 @@ /* * System Control and Management Interface(SCMI) based hwmon sensor driver * - * Copyright (C) 2018 ARM Ltd. + * Copyright (C) 2018-2020 ARM Ltd. * Sudeep Holla */ @@ -13,8 +13,10 @@ #include #include +static const struct scmi_sensor_proto_ops *sensor_ops; + struct scmi_sensors { - const struct scmi_handle *handle; + const struct scmi_protocol_handle *ph; const struct scmi_sensor_info **info[hwmon_max]; }; @@ -69,10 +71,9 @@ static int scmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u64 value; const struct scmi_sensor_info *sensor; struct scmi_sensors *scmi_sensors = dev_get_drvdata(dev); - const struct scmi_handle *h = scmi_sensors->handle; sensor = *(scmi_sensors->info[type] + channel); - ret = h->sensor_ops->reading_get(h, sensor->id, &value); + ret = sensor_ops->reading_get(scmi_sensors->ph, sensor->id, &value); if (ret) return ret; @@ -169,11 +170,16 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) struct hwmon_channel_info *scmi_hwmon_chan; const struct hwmon_channel_info **ptr_scmi_ci; const struct scmi_handle *handle = sdev->handle; + struct scmi_protocol_handle *ph; - if (!handle || !handle->sensor_ops) + if (!handle) return -ENODEV; - nr_sensors = handle->sensor_ops->count_get(handle); + sensor_ops = handle->devm_get_ops(sdev, SCMI_PROTOCOL_SENSOR, &ph); + if (IS_ERR(sensor_ops)) + return PTR_ERR(sensor_ops); + + nr_sensors = sensor_ops->count_get(ph); if (!nr_sensors) return -EIO; @@ -181,10 +187,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) if (!scmi_sensors) return -ENOMEM; - scmi_sensors->handle = handle; + scmi_sensors->ph = ph; for (i = 0; i < nr_sensors; i++) { - sensor = handle->sensor_ops->info_get(handle, i); + sensor = sensor_ops->info_get(ph, i); if (!sensor) return -EINVAL; @@ -236,7 +242,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) } for (i = nr_sensors - 1; i >= 0 ; i--) { - sensor = handle->sensor_ops->info_get(handle, i); + sensor = sensor_ops->info_get(ph, i); if (!sensor) continue; -- 2.17.1