From patchwork Sat Jun 24 16:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13291678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3015FEB64DA for ; Sat, 24 Jun 2023 16:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233000AbjFXQCV (ORCPT ); Sat, 24 Jun 2023 12:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFXQCU (ORCPT ); Sat, 24 Jun 2023 12:02:20 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2060.outbound.protection.outlook.com [40.92.89.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA028E5E; Sat, 24 Jun 2023 09:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WLGnaWe1GNSbYS4Cxow7TzPHXUAeluJqsI+S5Ymdfq/OM0YI5hrpKCcRF0CAgEx/UGsfwLIgCNlczeVAKq4Zs8Jxf/1Gx8+kPJAvpt+Zudv634VrvKzOr4iXRc9mb4KZXNhuMEB9xwS5y4RFCuUwo2wYXIDHWpPCiz8cFAyy7Sy3TFgdtfcD41w0/XYs+R2cp3jBIXYvx7Lc3zQwXNf11Bo2Fmq5TfM4CepXRnUCrz6DXSYifioBYg9Mhytundv1vPD5kkfeKeAVVvzwURqDFtF5/XJ4Z2MGvjQjoJ9GetHAiUvYkOmSRJAQJYeK/4ew6Zlfe7rHzWtK8j126QgTrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AcVVkhcuKjhaiaMiThTgwB4GRp0DfqLQZ+QY5Pwaj4k=; b=Egn2xXOYO/nJank+dqMdsoyq07MCbH8nT3xB4BaoelptpkUJLmV1R0+D6/tvKFREjMXnmgBAKZQ8qbV7DOC/5TmxjrM764dAzKFjSgSVWn+Mi6ADZQurGhJYIvemd++aww75BSU6dsM7K3GkgQ3b8rXdq7tPydpfpaWCEu1sX37S5dKKK/6vHsehp4ooNBVTiyDAD9lnRIIWKz0UBcgJ4fTvVtoqCVUw0s9BiJdKCU/RPAg6BQhss2Q+b5y1H0Px1H1gCUGDfimixfgCCMUr8syO2vtGULDIpXb5+DyNELNH5TjW9h9eIQ06wVPWLfTUgiyQbg4d8UkTrdJnr2uSxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AcVVkhcuKjhaiaMiThTgwB4GRp0DfqLQZ+QY5Pwaj4k=; b=DLMLy5RPYrFvtzl6nnN85qaCyM3w1JKGV74nPEcIMBkXdNK4RRAGN1VHRWZ3v020K+JGiVG3EYwVwv06Bil5lZWkGC89CqFc14RDJGGWB5AUyouH9kX9F0XbZWmJCe2wazfCQf8IXPtTf4R87ejFiuPyfCuT+m9jkmAXIqaWLrFChvLNgxk15igjo2RURZmaCDDdMFVH2WGARYkLcAKsu2AQrIPvUZrIVlQKKsdHQNnGmjVv/0LTdMbzvcHWbNdtF5FmVtPeRUDpq1hdmfnBJam7b7QmJu73YpNJAQhB0D2/+IRbT6PlomPXHe0ShyBZ1w62Yj1WXsKfF3iLtGp94Q== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by AS8PR10MB6102.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:570::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Sat, 24 Jun 2023 16:02:15 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%7]) with mapi id 15.20.6521.024; Sat, 24 Jun 2023 16:02:15 +0000 From: JuenKit_Yip@hotmail.com To: jdelvare@suse.com, linux@roeck-us.net, krzysztof.kozlowki+dt@linaro.org, conor+dt@kernel.org, broonie@kernel.org, vincent@vtremblay.dev, michal.simek@amd.com, geert+renesas@glider.be Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 1/3] hwmon: (sht3x) convert some of sysfs interface to hwmon Date: Sun, 25 Jun 2023 00:01:46 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [wnxwB2Kuz8at2xr8v6YvIdNa3UlXiKJh] X-ClientProxiedBy: TYCPR01CA0136.jpnprd01.prod.outlook.com (2603:1096:400:2b7::6) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230624160148.218786-1-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|AS8PR10MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e393b24-b7fd-45ba-666d-08db74cc60c7 X-MS-Exchange-SLBlob-MailProps: wk1EIbWONa01dq3m3LJx8CKFpQlkHUC+ZI2ds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2h9AwhsOrU+dgxDY50ryVmsV8J+YgH5amevO6b5mCmoK4qWQWLbeOVqopFpIEMsAyBLWKIqx+YdLUOOnOpYslQgV7duU643+4Hlgt9z5Elt3lCN/3Qsx5nEHVWr9Q6IUtYPPgIgYAqgoExnCMPip+FXEN8EbYa7i9g+t0pNhp0hj1AnuKJ/r5AgTO1yBS/6OeW9NGbGiAQcsmnqHrg6bneeoTPEgb/XX/I7kIEKambe0RB65j69kbVKblWs1BQ/2c0ZclMUFEO6+4tAQYxX+6IORRxQ5d26WhtE4uFUZ512orwOW9xXbJW+BsK+9wMN+88cJfRgHR699tP1LB7r8FXWOY74MpdUTkzOJ7Gg+dKRd9fhC/aEX1ns8O6t45SK+JB7CjZoH7MriEE7R9hQVFBILhi/1qCLSAKCuwNo4EtN0OAAdmgEN34oc2pnzhrlFz98H4zEN8GiQqbmYoFtXpYKDfxqq3JbgNdVPDHl1KyE7WYttaLvWPWFYAYTOQr/uIN7CB075sxSmq10pdWvCRoCQqiHGtLux+ueBcOlji4HgvWq4= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 7e393b24-b7fd-45ba-666d-08db74cc60c7 X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2023 16:02:15.5246 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB6102 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: JuenKit Yip update_interval, temperature/humidity max/min and hyst were moved to new hwmon interface, and only heater and repeatability were reserved as non-stardard sysfs interface. Signed-off-by: JuenKit Yip --- drivers/hwmon/sht3x.c | 359 ++++++++++++++++++++++++++++-------------- 1 file changed, 244 insertions(+), 115 deletions(-) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index bf18630619e0..9b2dadd11eeb 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -147,6 +147,19 @@ static const u16 mode_to_update_interval[] = { 100, }; +static const struct hwmon_channel_info * const sht3x_channel_info[] = { + HWMON_CHANNEL_INFO(chip, HWMON_C_UPDATE_INTERVAL), + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MIN | + HWMON_T_MIN_HYST | HWMON_T_MAX | + HWMON_T_MAX_HYST | HWMON_T_ALARM), + HWMON_CHANNEL_INFO(humidity, HWMON_H_INPUT | HWMON_H_MIN | + HWMON_H_MIN_HYST | HWMON_H_MAX | + HWMON_H_MAX_HYST | HWMON_H_ALARM), + NULL, +}; + +static const struct i2c_device_id sht3x_ids[]; + struct sht3x_data { struct i2c_client *client; struct mutex i2c_lock; /* lock for sending i2c commands */ @@ -276,27 +289,24 @@ static struct sht3x_data *sht3x_update_client(struct device *dev) return data; } -/* sysfs attributes */ -static ssize_t temp1_input_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int temp1_input_read(struct device *dev) { struct sht3x_data *data = sht3x_update_client(dev); if (IS_ERR(data)) return PTR_ERR(data); - return sprintf(buf, "%d\n", data->temperature); + return data->temperature; } -static ssize_t humidity1_input_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int humidity1_input_read(struct device *dev) { struct sht3x_data *data = sht3x_update_client(dev); if (IS_ERR(data)) return PTR_ERR(data); - return sprintf(buf, "%u\n", data->humidity); + return data->humidity; } /* @@ -332,33 +342,24 @@ static int limits_update(struct sht3x_data *data) return ret; } -static ssize_t temp1_limit_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static int temp1_limit_read(struct device *dev, int index) { struct sht3x_data *data = dev_get_drvdata(dev); - u8 index = to_sensor_dev_attr(attr)->index; - int temperature_limit = data->temperature_limits[index]; - return sysfs_emit(buf, "%d\n", temperature_limit); + return data->temperature_limits[index]; } -static ssize_t humidity1_limit_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static int humidity1_limit_read(struct device *dev, int index) { struct sht3x_data *data = dev_get_drvdata(dev); - u8 index = to_sensor_dev_attr(attr)->index; - u32 humidity_limit = data->humidity_limits[index]; - return sysfs_emit(buf, "%u\n", humidity_limit); + return data->humidity_limits[index]; } /* - * limit_store must only be called with data_lock held + * limit_write must only be called with data_lock held */ -static size_t limit_store(struct device *dev, - size_t count, +static size_t limit_write(struct device *dev, u8 index, int temperature, u32 humidity) @@ -379,7 +380,7 @@ static size_t limit_store(struct device *dev, * ST = (T + 45) / 175 * 2^16 * SRH = RH / 100 * 2^16 * adapted for fixed point arithmetic and packed the same as - * in limit_show() + * in limit_read() */ raw = ((u32)(temperature + 45000) * 24543) >> (16 + 7); raw |= ((humidity * 42950) >> 16) & 0xfe00; @@ -400,50 +401,43 @@ static size_t limit_store(struct device *dev, data->temperature_limits[index] = temperature; data->humidity_limits[index] = humidity; - return count; + + return 0; } -static ssize_t temp1_limit_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static int temp1_limit_write(struct device *dev, int index, const char *val) { int temperature; int ret; struct sht3x_data *data = dev_get_drvdata(dev); - u8 index = to_sensor_dev_attr(attr)->index; - ret = kstrtoint(buf, 0, &temperature); + ret = kstrtoint(val, 0, &temperature); if (ret) return ret; temperature = clamp_val(temperature, SHT3X_MIN_TEMPERATURE, SHT3X_MAX_TEMPERATURE); mutex_lock(&data->data_lock); - ret = limit_store(dev, count, index, temperature, + ret = limit_write(dev, index, temperature, data->humidity_limits[index]); mutex_unlock(&data->data_lock); return ret; } -static ssize_t humidity1_limit_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static int humidity1_limit_write(struct device *dev, int index, const char *val) { u32 humidity; int ret; struct sht3x_data *data = dev_get_drvdata(dev); - u8 index = to_sensor_dev_attr(attr)->index; - ret = kstrtou32(buf, 0, &humidity); + ret = kstrtou32(val, 0, &humidity); if (ret) return ret; humidity = clamp_val(humidity, SHT3X_MIN_HUMIDITY, SHT3X_MAX_HUMIDITY); mutex_lock(&data->data_lock); - ret = limit_store(dev, count, index, data->temperature_limits[index], + ret = limit_write(dev, index, data->temperature_limits[index], humidity); mutex_unlock(&data->data_lock); @@ -474,7 +468,6 @@ static void sht3x_select_command(struct sht3x_data *data) } static int status_register_read(struct device *dev, - struct device_attribute *attr, char *buffer, int length) { int ret; @@ -487,34 +480,30 @@ static int status_register_read(struct device *dev, return ret; } -static ssize_t temp1_alarm_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static int temp1_alarm_read(struct device *dev) { char buffer[SHT3X_WORD_LEN + SHT3X_CRC8_LEN]; int ret; - ret = status_register_read(dev, attr, buffer, + ret = status_register_read(dev, buffer, SHT3X_WORD_LEN + SHT3X_CRC8_LEN); if (ret) return ret; - return sysfs_emit(buf, "%d\n", !!(buffer[0] & 0x04)); + return !!(buffer[0] & 0x04); } -static ssize_t humidity1_alarm_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static int humidity1_alarm_read(struct device *dev) { char buffer[SHT3X_WORD_LEN + SHT3X_CRC8_LEN]; int ret; - ret = status_register_read(dev, attr, buffer, + ret = status_register_read(dev, buffer, SHT3X_WORD_LEN + SHT3X_CRC8_LEN); if (ret) return ret; - return sysfs_emit(buf, "%d\n", !!(buffer[0] & 0x08)); + return !!(buffer[0] & 0x08); } static ssize_t heater_enable_show(struct device *dev, @@ -524,7 +513,7 @@ static ssize_t heater_enable_show(struct device *dev, char buffer[SHT3X_WORD_LEN + SHT3X_CRC8_LEN]; int ret; - ret = status_register_read(dev, attr, buffer, + ret = status_register_read(dev, buffer, SHT3X_WORD_LEN + SHT3X_CRC8_LEN); if (ret) return ret; @@ -560,20 +549,14 @@ static ssize_t heater_enable_store(struct device *dev, return ret; } -static ssize_t update_interval_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static int update_interval_read(struct device *dev) { struct sht3x_data *data = dev_get_drvdata(dev); - return sysfs_emit(buf, "%u\n", - mode_to_update_interval[data->mode]); + return mode_to_update_interval[data->mode]; } -static ssize_t update_interval_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static int update_interval_write(struct device *dev, const char *val) { u16 update_interval; u8 mode; @@ -582,7 +565,7 @@ static ssize_t update_interval_store(struct device *dev, struct sht3x_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; - ret = kstrtou16(buf, 0, &update_interval); + ret = kstrtou16(val, 0, &update_interval); if (ret) return ret; @@ -592,7 +575,7 @@ static ssize_t update_interval_store(struct device *dev, /* mode did not change */ if (mode == data->mode) { mutex_unlock(&data->data_lock); - return count; + return 0; } mutex_lock(&data->i2c_lock); @@ -634,7 +617,7 @@ static ssize_t update_interval_store(struct device *dev, if (ret != SHT3X_CMD_LENGTH) return ret < 0 ? ret : -EIO; - return count; + return 0; } static ssize_t repeatability_show(struct device *dev, @@ -668,60 +651,211 @@ static ssize_t repeatability_store(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0); -static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0); -static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max); -static SENSOR_DEVICE_ATTR_RW(humidity1_max, humidity1_limit, limit_max); -static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp1_limit, limit_max_hyst); -static SENSOR_DEVICE_ATTR_RW(humidity1_max_hyst, humidity1_limit, - limit_max_hyst); -static SENSOR_DEVICE_ATTR_RW(temp1_min, temp1_limit, limit_min); -static SENSOR_DEVICE_ATTR_RW(humidity1_min, humidity1_limit, limit_min); -static SENSOR_DEVICE_ATTR_RW(temp1_min_hyst, temp1_limit, limit_min_hyst); -static SENSOR_DEVICE_ATTR_RW(humidity1_min_hyst, humidity1_limit, - limit_min_hyst); -static SENSOR_DEVICE_ATTR_RO(temp1_alarm, temp1_alarm, 0); -static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0); static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0); -static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0); static SENSOR_DEVICE_ATTR_RW(repeatability, repeatability, 0); static struct attribute *sht3x_attrs[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_humidity1_input.dev_attr.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, - &sensor_dev_attr_humidity1_max.dev_attr.attr, - &sensor_dev_attr_humidity1_max_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp1_min_hyst.dev_attr.attr, - &sensor_dev_attr_humidity1_min.dev_attr.attr, - &sensor_dev_attr_humidity1_min_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_alarm.dev_attr.attr, - &sensor_dev_attr_humidity1_alarm.dev_attr.attr, &sensor_dev_attr_heater_enable.dev_attr.attr, - &sensor_dev_attr_update_interval.dev_attr.attr, - &sensor_dev_attr_repeatability.dev_attr.attr, - NULL -}; - -static struct attribute *sts3x_attrs[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp1_min_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_alarm.dev_attr.attr, - &sensor_dev_attr_heater_enable.dev_attr.attr, - &sensor_dev_attr_update_interval.dev_attr.attr, &sensor_dev_attr_repeatability.dev_attr.attr, NULL }; ATTRIBUTE_GROUPS(sht3x); -ATTRIBUTE_GROUPS(sts3x); -static const struct i2c_device_id sht3x_ids[]; +static umode_t sht3x_is_visible(const void *data, enum hwmon_sensor_types type, + u32 attr, int channel) +{ + const struct sht3x_data *chip_data = data; + struct i2c_client *client = chip_data->client; + + switch (type) { + case hwmon_chip: + switch (attr) { + case hwmon_chip_update_interval: + return 0644; + default: + break; + } + break; + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + case hwmon_temp_alarm: + return 0444; + case hwmon_temp_max: + case hwmon_temp_max_hyst: + case hwmon_temp_min: + case hwmon_temp_min_hyst: + return 0644; + default: + break; + } + break; + case hwmon_humidity: + if (i2c_match_id(sht3x_ids, client)->driver_data == sts3x) + return 0; + switch (attr) { + case hwmon_humidity_input: + case hwmon_humidity_alarm: + return 0444; + case hwmon_humidity_max: + case hwmon_humidity_max_hyst: + case hwmon_humidity_min: + case hwmon_humidity_min_hyst: + return 0644; + default: + break; + } + break; + default: + break; + } + + return 0; +} + +static int sht3x_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + enum sht3x_limits index; + + switch (type) { + case hwmon_chip: + switch (attr) { + case hwmon_chip_update_interval: + *val = update_interval_read(dev); + break; + default: + return -EOPNOTSUPP; + } + break; + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + *val = temp1_input_read(dev); + break; + case hwmon_temp_alarm: + *val = temp1_alarm_read(dev); + break; + case hwmon_temp_max: + index = limit_max; + *val = temp1_limit_read(dev, index); + break; + case hwmon_temp_max_hyst: + index = limit_max_hyst; + *val = temp1_limit_read(dev, index); + break; + case hwmon_temp_min: + index = limit_min; + *val = temp1_limit_read(dev, index); + break; + case hwmon_temp_min_hyst: + index = limit_min_hyst; + *val = temp1_limit_read(dev, index); + break; + default: + return -EOPNOTSUPP; + } + break; + case hwmon_humidity: + switch (attr) { + case hwmon_humidity_input: + *val = humidity1_input_read(dev); + break; + case hwmon_humidity_alarm: + *val = humidity1_alarm_read(dev); + break; + case hwmon_humidity_max: + index = limit_max; + *val = humidity1_limit_read(dev, index); + break; + case hwmon_humidity_max_hyst: + index = limit_max_hyst; + *val = humidity1_limit_read(dev, index); + break; + case hwmon_humidity_min: + index = limit_min; + *val = humidity1_limit_read(dev, index); + break; + case hwmon_humidity_min_hyst: + index = limit_min_hyst; + *val = humidity1_limit_read(dev, index); + break; + default: + return -EOPNOTSUPP; + } + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int sht3x_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + enum sht3x_limits index; + + switch (type) { + case hwmon_chip: + switch (attr) { + case hwmon_chip_update_interval: + return update_interval_write(dev, (const char *)&val); + default: + return -EOPNOTSUPP; + } + case hwmon_temp: + switch (attr) { + case hwmon_temp_max: + index = limit_max; + break; + case hwmon_temp_max_hyst: + index = limit_max_hyst; + break; + case hwmon_temp_min: + index = limit_min; + break; + case hwmon_temp_min_hyst: + index = limit_min_hyst; + break; + default: + return -EOPNOTSUPP; + } + return temp1_limit_write(dev, index, (const char *)&val); + case hwmon_humidity: + switch (attr) { + case hwmon_humidity_max: + index = limit_max; + break; + case hwmon_humidity_max_hyst: + index = limit_max_hyst; + break; + case hwmon_humidity_min: + index = limit_min; + break; + case hwmon_humidity_min_hyst: + index = limit_min_hyst; + break; + default: + return -EOPNOTSUPP; + } + return humidity1_limit_write(dev, index, (const char *)val); + default: + return -EOPNOTSUPP; + } +} + +static const struct hwmon_ops sht3x_ops = { + .is_visible = sht3x_is_visible, + .read = sht3x_read, + .write = sht3x_write, +}; + +static const struct hwmon_chip_info sht3x_chip_info = { + .ops = &sht3x_ops, + .info = sht3x_channel_info, +}; static int sht3x_probe(struct i2c_client *client) { @@ -730,7 +864,6 @@ static int sht3x_probe(struct i2c_client *client) struct device *hwmon_dev; struct i2c_adapter *adap = client->adapter; struct device *dev = &client->dev; - const struct attribute_group **attribute_groups; /* * we require full i2c support since the sht3x uses multi-byte read and @@ -771,15 +904,11 @@ static int sht3x_probe(struct i2c_client *client) if (ret) return ret; - if (i2c_match_id(sht3x_ids, client)->driver_data == sts3x) - attribute_groups = sts3x_groups; - else - attribute_groups = sht3x_groups; - - hwmon_dev = devm_hwmon_device_register_with_groups(dev, - client->name, - data, - attribute_groups); + hwmon_dev = devm_hwmon_device_register_with_info(dev, + client->name, + data, + &sht3x_chip_info, + sht3x_groups); if (IS_ERR(hwmon_dev)) dev_dbg(dev, "unable to register hwmon device\n"); From patchwork Sat Jun 24 16:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13291679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2568EB64DA for ; Sat, 24 Jun 2023 16:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbjFXQC1 (ORCPT ); Sat, 24 Jun 2023 12:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFXQCX (ORCPT ); Sat, 24 Jun 2023 12:02:23 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2034.outbound.protection.outlook.com [40.92.89.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69A0E5F; Sat, 24 Jun 2023 09:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbABwz8SXG3WN7XqNBGENLH1pj0/bkb6zdqhly7N77teCuZJVAWuWyWeD0tnAw8ZmYQWG1DcWoJB8289hxRJBKGJKA4vdQKOAk85JUnX30hkBAjwRE5V452hmwYqSF4YlbuEI3aoqO3VO2mbzZgrSE/Pext/tw/HFJzYoHs9VYSuSmQJ8FxSbRoG2quCtrQNLwdl7HVXkrcVpTWVAPFhRk8n8dinAD/R/sQmEU4rKihqHJ/cakZvUAIatH7V/2IZohLVl3ExeQV2fkjJUyc80nWOlPL7IgWiOBu6XynQlJjMzBcsrODz9OenM6CtvR+R3DrYMyltuwMUef3ml73vaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/h7pafd5UrjLQONNEg0P/Pj78wXpnRORgZc854zpH2Q=; b=eMO+aiZ3IO3kw5cP4lcK3UGyT8Uu0aDb0nC52t7YPIzFRUN3X9t52grWZxqunAK/leejpEynqZJOpuqsk3JmdFTGaGKB2uXkWMBePY0xQKMNVrv+vklmreq6IA3CIR5FUgWHcH/QqSE2Eu9YI3Qs12x4GEjkR6veVR5dJJRgYQroGz2DuwpKlUKVDiuJEPN5P/jBU9Gco/Hw76rsEjC6JOF0TojvJr1FgVoMCQaelvxXDGeezXNyFzG7MzVTA5tzamymqY0n1W5j2JMJ0iScqweyWQffFK6rIgNGhFtZTFoGN22CSiLd6A3Z6RGNjCIiyGxJjxS7XIjR/arJ71NVxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/h7pafd5UrjLQONNEg0P/Pj78wXpnRORgZc854zpH2Q=; b=aWTwDhgvuSoS7KlppLDuhplyibENyEADF+yeIrvYK3LJI6r/+rc+UzY87qk+9V1lPOFrcaeVw1e5+kC2sO4rrJ5Tt/A8pSvLyzRa4iJuyLXeJszKqGtpkKeR98Z5SHekNSMCye/uv88iDX9f1KKgmUNw5Sh25MLN7tSnNBkuLTDiWibNtmvT1vp2o6LwxcVrkKEwDt+5xo6gVmUY97GeGoEhCsxGFHn1l+OsvKBLZ4j3K6T/5wMHI5HRrHpgC765ut/pqmBfLmCz43yA+kytK2zqTVJoSU3cEcSXlEbhH96eEy3WvPEsoCbbLAOnmpBCHN5Mjt8mDWYAUkRnXXoKXA== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by AS8PR10MB6102.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:570::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Sat, 24 Jun 2023 16:02:21 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%7]) with mapi id 15.20.6521.024; Sat, 24 Jun 2023 16:02:21 +0000 From: JuenKit_Yip@hotmail.com To: jdelvare@suse.com, linux@roeck-us.net, krzysztof.kozlowki+dt@linaro.org, conor+dt@kernel.org, broonie@kernel.org, vincent@vtremblay.dev, michal.simek@amd.com, geert+renesas@glider.be Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 2/3] hwmon: (sht3x) add device-tree support Date: Sun, 25 Jun 2023 00:01:47 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230624160148.218786-1-JuenKit_Yip@hotmail.com> References: <20230624160148.218786-1-JuenKit_Yip@hotmail.com> X-TMN: [JrKxpSX0kTrz7X1sw6tVWGcXZnPhKkgm] X-ClientProxiedBy: TYCPR01CA0136.jpnprd01.prod.outlook.com (2603:1096:400:2b7::6) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230624160148.218786-2-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|AS8PR10MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e765205-61ca-4ae2-2a09-08db74cc641f X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO8+XqhgFcE/gp7gtTgZ/RFY7abg/gSsBcG/bcc2aMCOyP/uLBNiycN2EVuY96h9hO/oBAsEIHfurams20hAAit7bubAG/RZEkl606Kr2cdX8xFnFmVlH0IbKq0Acx9M6zv8C7ArCbitmKBTpIXYxK7g876diqm/Hs6YXBH/XvByEhcJCr7yugALaZWiH9qDWm+m7gC6J0q/J8NJisqC6lRK3JYr9+Yv3e4h6wayaR1G97pis+xnpqX+Z1x8DoI84WzaMrqbHyEVo7svNEQd2TwSkKq6PqR4s7aDaQ8fIk7KBLMH7S7x3l1xCoTXxz1f0CIjmGvBozbU/2cFRLjzCUUwbwJO76as3wg7o0JzjoVc+Vu/Kn7k12jbRQD0A38Y87BNDABtV0NBw1BGM735DFSlcgj4aVcz7Anukqx1ojOnkL22vx+bXq55a6UC5RFuFBrNTnjHSLAfFpRHsMO13bVEqtxHTJkqME++LiWVk4fz5SGUR2pG+kK+ingKCVHZxq0+f5fSJwyGniC0I5u3GhZ1PIgqHrEZESz/FBvxw+XJjFVoYiUHjC7w1L7Mz8Wg6ePr7MazQ0wsXneklmfKyLmwkVHNlsLJP34XN784HEVRiDpkjx5CytrcRz8RFojyLKVlmrkOccTXPDXohwull6W8bxYVukvTmV43SSyhLF8mcBgINYr59KXthJpxQ/TRRs/9IdrTkIauAg== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zN1fZ7BU9jRS8F5tK2/n0FF+N/wzqRXBBFMDtmJHn3nPtVn95GWggFphNgWjruJa2csasC+EBdJyaGA/c66OlAeSzHQ0ntda8uWjboL2ZjTryZoiAU/zo5PaW8XmuAn1mBSn8kAuHLkk7NboBVqU8p7zxEGGX+qVCAUIu5XgewMWHjaCj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MTFkbpAK1pPhbe8u051MwjUdrjoXQ8UNCaVOkw6FmBesol7a+B2NpciVv5Yj06xOdXmSxl5GoPuoJau1jNEp7XrV5N8rWHNFM+FmwhnSgMedwIBQn8tcRCJlw7vm9h1ix4pfJuK1EdYFsJSIpsRjmyQKIAFgHGM//OlFXuzggdrZOUf6OWOznhlXwd7XOzSwq1gVLdHpgQNvR4u1Qn8GHDeWffUUqoReAiqqFvu8EUk+3OC4h2eB/hRgEfBpKOLlOkkjDu4rZTSK9RprNaRNP73+KPdUg5iqHdTTs8V5ejrfpddFGkZ+wjWIuiiGQBacIW09OLNEuz2AFIKLt8SfigASKJeFu+AYGWWRi+F8ZbwUW0xVESnYzptEBOl943VHyws+dfPnAdxIZiqIdykNkpG8u+YHlM9MVipl2nAdP/TQ1zouShdYC7QNkqm2LEFI2OFqZblwNjJNQpsby9tNopQxJoBBmJiBn+ua9xqrT761GELanYqsVCiXxkfusnXHL3jjuW8aHAPZbQsU6jyqeOOYsFvK8Hzoa/7jCS/xk4Xpfewgkh/eL5q3Ypsm4OFh+HuUpZb4r7dxhVxxq8Atp5KtMkCG1Ha0HM2gbs5tw0z1oBm2RZ0cP6XHJWOy3ATcN7n9Z+01c+QLqxWQyiQDou63/Ff/YXPcA45JMZNu25P0DqNOjG++tLcFE= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 3e765205-61ca-4ae2-2a09-08db74cc641f X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2023 16:02:20.9622 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB6102 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: JuenKit Yip add "compatible" property for supporting device-tree Signed-off-by: JuenKit Yip --- drivers/hwmon/sht3x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index 9b2dadd11eeb..e7648c011e5f 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -925,8 +925,18 @@ static const struct i2c_device_id sht3x_ids[] = { MODULE_DEVICE_TABLE(i2c, sht3x_ids); +/* devicetree ID table */ +static const struct of_device_id sht3x_of_match[] = { + { .compatible = "sensirion,sht3x" }, + { .compatible = "sensirion,sts3x" }, + {}, +}; + static struct i2c_driver sht3x_i2c_driver = { - .driver.name = "sht3x", + .driver = { + .name = "sht3x", + .of_match_table = of_match_ptr(sht3x_of_match), + }, .probe = sht3x_probe, .id_table = sht3x_ids, }; From patchwork Sat Jun 24 16:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JuenKit Yip X-Patchwork-Id: 13291680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39B29EB64DA for ; Sat, 24 Jun 2023 16:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbjFXQCz (ORCPT ); Sat, 24 Jun 2023 12:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233234AbjFXQCa (ORCPT ); Sat, 24 Jun 2023 12:02:30 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2049.outbound.protection.outlook.com [40.92.89.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3581C1BD6; Sat, 24 Jun 2023 09:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZexbc2+HkrRTHDedhVgXfReX+n61Gn8w3Py6K7GsUuMT1Bj702rlPBp1ReEQvDgi5Xphz1RhnVxmlOckQUwKkT4GYzZT9v4E5pdjlnJzisAnQqLtkzjOCk/A90FPZcHPtGXVf9yqwUGsmbV7G2GkPVuBQg+C3/g3rZiczcjKSRtTcotw82WEuIWKVjSk2xIzIdCVSm34XFEmrPZLgb8mSg1Q/9Qqd7tnNMbYl8V8dzGa2rGGqKiN9FjEW90B0QaoU4IIEnJyFFL6c/sW50GlJmhNSJHGlG65X8xCRQTgXnob6/ltfU+f4QNgMr4zKEuZfuX59yTlIy8Do6e7MbX7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2e9HJZCoQUV7mmtKPw/q+Qk7W8Q2v2DjbJwMZYYEp3M=; b=ggj+2ualM48RuVOt3SR2yjN+81nMTg8+CEtXku9UivGFzNhv8CbnPPVBLqLpY2Ryh43TnYMpLFdsuNzVjAjgzMf/cTL8pyMpCbBCVLo9ItF6A8uvIGVNrglI4DBy7edzOUTfd8YePimWWnI+WQxXQDIcLWxzIj+701TqU3O7AVIa0TQ9AoccPWWLOAPU507PzDCdkCnPBpDfxPkUKkzBjYa5G43inz/5tRMvKC53JMeq0keqxS8dZ8j3VnYKtoDceukMCVcVIyFg/pYGQDcCH1ZH9pSvLAzl2iGyvEc+vtcBxB1qiDW36jgiNwnABjlv26yObboBky9ptH2fYz1hRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2e9HJZCoQUV7mmtKPw/q+Qk7W8Q2v2DjbJwMZYYEp3M=; b=OZwcfegCzf+otEu2BnqaOhh/vn/FieVTeweDh3iONQOvsBphq9JRJXephhJXQ+bYKQ9THQMuxMF47rlBBta0HnCCmUD9LabUQ97NfPtrTnuLfocfwJU5LPjHRIRn+V+a/Mlt6fyHjp3RDXW3v0QOKA6vzYy5PU1FU5O/iRDbIlrSqGvlhzWkxCPU/fZhcxDPDekpar10pAz0P0Ip1gSXIgUxTb9DsWXyrd4mv8mCFM2O1TVA2TyYpz9edHXon6m0rRia/gyv45Qq5EqRxHCbOcXOzQ13vmaUbrOsQS2hZotNJunXHNQf/hGyFOrfTie0FHPCGSBhonzUURROBjWEUw== Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) by AS8PR10MB6102.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:570::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Sat, 24 Jun 2023 16:02:26 +0000 Received: from DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88]) by DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM ([fe80::628a:d617:46f:2a88%7]) with mapi id 15.20.6521.024; Sat, 24 Jun 2023 16:02:26 +0000 From: JuenKit_Yip@hotmail.com To: jdelvare@suse.com, linux@roeck-us.net, krzysztof.kozlowki+dt@linaro.org, conor+dt@kernel.org, broonie@kernel.org, vincent@vtremblay.dev, michal.simek@amd.com, geert+renesas@glider.be Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, JuenKit Yip Subject: [PATCH 3/3] dt-bindings: : add sht3x devicetree binding Date: Sun, 25 Jun 2023 00:01:48 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230624160148.218786-1-JuenKit_Yip@hotmail.com> References: <20230624160148.218786-1-JuenKit_Yip@hotmail.com> X-TMN: [b0qT3Nkq/x3z1OTN1gB7Mg4hNGENkDoB] X-ClientProxiedBy: TYCPR01CA0136.jpnprd01.prod.outlook.com (2603:1096:400:2b7::6) To DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:383::21) X-Microsoft-Original-Message-ID: <20230624160148.218786-3-JuenKit_Yip@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR10MB6261:EE_|AS8PR10MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d975e2d-e0d5-4bc0-cbb7-08db74cc676f X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnrMCE58nQssOil7WqC2+V8M62fc6FDVzwqWhMXtf6tbyWA5eGrzgcH+Uf20DsQudom6/mFa/wHsXdJklIpxj39VBdxSapuaeOF2WR35EG5hzfLsWDu2NR9L5hzgy7lzrDHwYWbbE9eRmBAT8Ky3NP9naEZGKcq0/vfOXwFvA/8eF5UCxdU6e1MNPWRuLgCzcA5ZfNsTdd13vfo1wRlxlQ2FNpyfvWfbtiaLI6e1OT8B0XciX4E0U3hsjzSQL5iwbMYkyIbyPHtwf2qTZDJWzw0la5n4cJfqIOl5ZkmwgpNPLueho7n0LGC+kG3XKT/BCbEm9S5E7yLzclWG/JkAGm+JEt0SZA0TvFtqnV6Rkk979Zi2i/8S/EkUM7D7hj4NWwkHSvYa2ucUmtMLJEPpKy+6mKPzZ/Nc1KejpoKaGARKJwLj9keDhDoECTdiARN1tTGvFXwjviSrZNVBrIQfZvZLJ8o8ScNtO4R+JA/9ABGEHdPua939WZMXC9C0613SlNxwg8jRNfBt+GIFZEW2A2hlW5Lcbx8JsT0IxjcJj8eOVG0yTHOi+VIJt020hGoeVAHKRgAkU0y5ajPB6AgGi8eKF265eKkwdbMNyk2mQlgy+2kdYDAAWbVGKCrdhrVz7ER4n/QZOP5yiTGOf+HSbb7bQfLCS3reQSYqeG37WcfB2N13n5XS5e+51ToMEi9BFJbwm9M++er9+U5leBdSt7gEQfxIVy62q88IGFeZtJTg+F75nplPP+fLPqhGkYAbnNM= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wSQLxcFQyvIVVp3ndxexXZc7ucF5EbIjDj6h1Q5zgMB5FreT32vf3DigGPZx7LFzSaVxAgKzMVLMFcskBALBmMjpatYG1w5nXn+6IzVsUAvt+FObl0AUFmtfcyzbSVRiTWEpEJJ1TIFLwifBlS8kkuLCEJ1tMnc4kRTroYc6LAsVQps6Z5Xw+S3PgQpUxTJXfsvOaAL8leMuskepS3+GmhjQCnyZIY5gT+loe7mNrfrSEREq68kQjvY8n4+RGL70o9yMtcv39JVf0JimxXHaCe5rj8hDEuOcvL3r9YcZe89aUXZZBSQBy7xvUBQop7V42nAcO0T4VJFXA2PZChutTNLApttQTq106s/DA47khPBer0Js+MLtqG8Qu1sS/+yphPGbIYWcoB2H4ow8o2LeveXJoNQS5Y20Cj01OJq3Ru5tAFYzIQTma35bovBXy8sUuQMDZec4QCf5box0PxgOZZI8lN+q14kNvlnhd2BOfx5ttRqfcLHgboLrbWZpAn7f4YbCYqXLAESj0RI+Qbg/pJLFHXStkrGceqBaWUpRcPf91S+LUwIphSJjQObUp2pBMFlEmKdYQF5y5W+wo4kwTYcMuMsutrEt63vEcRfZG8I= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LB909VzRWCy0WmVPWbMyM5Hft557c/HGKnN81Qffa0nOWKQlyvvkk3rTPMMqFDt9Ugl+7e49WC3QuDJiOdyynw24VkTy0wmjF271enGGG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OdewaWzXNwHBIziJ4lUNFUX4SXc6s6bLaidduBektMo3Ojb0MBknLZI3qw/Blbb+mgA1uiWo= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 3d975e2d-e0d5-4bc0-cbb7-08db74cc676f X-MS-Exchange-CrossTenant-AuthSource: DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2023 16:02:26.2937 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR10MB6102 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: JuenKit Yip add sht3x devicetree binding files Signed-off-by: JuenKit Yip --- .../devicetree/bindings/hwmon/sht3x.yaml | 31 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/sht3x.yaml diff --git a/Documentation/devicetree/bindings/hwmon/sht3x.yaml b/Documentation/devicetree/bindings/hwmon/sht3x.yaml new file mode 100644 index 000000000000..8ff0b8d41f91 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/sht3x.yaml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause +% YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/sensirion,sht3x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SHT3x-DIS humidity and temperature sensor + +maintainers: + - JuenKit Yip + +properties: + compatible: + enum: + - sensirion,sht3x + - sensirion,sts3x + reg: + maxItems: 1 + +required: + - compatible + - reg + +addtionalProperties: false + +examples: + - | + sensor@4a { + compatible = "sensirion,sht3x"; + reg = <0x4a>; + }; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index ba2bfb547909..b2369d1fad68 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -331,6 +331,10 @@ properties: - sensirion,sgp30 # Sensirion gas sensor with I2C interface - sensirion,sgp40 + # Sensirion SHT3x-DIS humidity and temperature sensor + - sensirion,sht3x + # Sensirion STS3x humidity sensor + - sensirion,sts3x # Sensirion temperature & humidity sensor with I2C interface - sensirion,sht4x # Sensortek 3 axis accelerometer