From patchwork Mon Jul 20 07:03:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 11672965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB9FA6C1 for ; Mon, 20 Jul 2020 07:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6CEC207DF for ; Mon, 20 Jul 2020 07:03:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="GOYSo689" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbgGTHDp (ORCPT ); Mon, 20 Jul 2020 03:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727026AbgGTHDo (ORCPT ); Mon, 20 Jul 2020 03:03:44 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD34CC0619D2 for ; Mon, 20 Jul 2020 00:03:44 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id l63so9853171pge.12 for ; Mon, 20 Jul 2020 00:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kMPFF5ZX+ECoryjfj/273iw7Fp6u0lS+4MPrerem2k0=; b=GOYSo6893phi2CTvlcgC6spagnXPSlROhirRCZ4Zw9TOrfHOeDKPS1/9Ha82aNG6/p cRToca+B833vAW9ogDpmCq+D77bmbd3E5znAJyNUeF1v+qYxZMNjQ3Gqu6iLH37jo8J+ lSUylxEJrbWMOfSgF5hwkGN4j383kjpy3fuik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kMPFF5ZX+ECoryjfj/273iw7Fp6u0lS+4MPrerem2k0=; b=R4IUW+aq1nw1vQPtDgIxGPNBOe7c/HpxkeQBXd/YGcQ0Nl1AfxgcNllV43tDDiuv/6 GWmLxMvN+he6EGvKfcIuamy6yh5Ndr3e7mOqUu6NCH48EEgx5BltpuhJDl8ABHGccpVA VOS+IU3jbbqgoX/qrhPlrW0DkgMzBS4wVqpD7HZYNH7BqSdIM94DBxn4ZqlgMb27VYkr tYoVyWvgquF4k9tiEe/MbsD6PC2fvtsaP75KEGQV/mv5L3UzUpDRj/DEJMHVb1KZrPTN TFwAqsAlbPjQDQ3RCVtDthG8y7hX7q+hRfiD0DNb9ceFRwvJAUZTQM31UMUzqhbg6jw5 fDGg== X-Gm-Message-State: AOAM531GTHy7URh1UrdzUQHb5quVwPpcwTMYjEO1+tQVNvFlsCP5Ohie T5Moj+ib3lqOUTRrruUjcUT1RNBwolgKQQ== X-Google-Smtp-Source: ABdhPJyKPEdY7B90kaF/AvRTjCt/oNsdUbB3rTTtOiGtRarP3DxWaBRZ7I50S/BTmkvvjsQZozt6Tw== X-Received: by 2002:a63:e80e:: with SMTP id s14mr18139172pgh.32.1595228624002; Mon, 20 Jul 2020 00:03:44 -0700 (PDT) Received: from ubuntu.Home (anon-62-111.vpn.ipredator.se. [46.246.62.111]) by smtp.gmail.com with ESMTPSA id gn5sm10613862pjb.23.2020.07.20.00.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 00:03:43 -0700 (PDT) From: Matt Ranostay To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, Matt Ranostay Subject: [PATCH v2 1/3] iio: add IIO_MOD_O2 modifier Date: Mon, 20 Jul 2020 00:03:28 -0700 Message-Id: <20200720070330.259954-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720070330.259954-1-matt.ranostay@konsulko.com> References: <20200720070330.259954-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add modifier IIO_MOD_O2 for O2 concentration reporting Signed-off-by: Matt Ranostay --- Documentation/ABI/testing/sysfs-bus-iio | 2 ++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index d3e53a6d8331..5166d905a830 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1564,6 +1564,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_concentration_ethanol_raw What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_ethanol_raw What: /sys/bus/iio/devices/iio:deviceX/in_concentration_h2_raw What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_h2_raw +What: /sys/bus/iio/devices/iio:deviceX/in_concentration_o2_raw +What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_o2_raw What: /sys/bus/iio/devices/iio:deviceX/in_concentration_voc_raw What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_voc_raw KernelVersion: 4.3 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 352533342702..b25c5af148de 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -132,6 +132,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_PM10] = "pm10", [IIO_MOD_ETHANOL] = "ethanol", [IIO_MOD_H2] = "h2", + [IIO_MOD_O2] = "o2", }; /* relies on pairs of these shared then separate */ diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index fdd81affca4b..48c13147c0a8 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -94,6 +94,7 @@ enum iio_modifier { IIO_MOD_PM10, IIO_MOD_ETHANOL, IIO_MOD_H2, + IIO_MOD_O2, }; enum iio_event_type { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index f115d166c985..bb03859db89d 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -119,6 +119,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_PM2P5] = "pm2p5", [IIO_MOD_PM4] = "pm4", [IIO_MOD_PM10] = "pm10", + [IIO_MOD_O2] = "o2", }; static bool event_is_known(struct iio_event_data *event) @@ -211,6 +212,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_MOD_PM2P5: case IIO_MOD_PM4: case IIO_MOD_PM10: + case IIO_MOD_O2: break; default: return false; From patchwork Mon Jul 20 07:03:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 11672967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 408286C1 for ; Mon, 20 Jul 2020 07:03:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28E2A20734 for ; Mon, 20 Jul 2020 07:03:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="I6q1y0tc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbgGTHDt (ORCPT ); Mon, 20 Jul 2020 03:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727026AbgGTHDt (ORCPT ); Mon, 20 Jul 2020 03:03:49 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DDD2C0619D4 for ; Mon, 20 Jul 2020 00:03:49 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o22so9605520pjw.2 for ; Mon, 20 Jul 2020 00:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S91pqBIXOMqhpCywJzCF5HgxB4jKWpemY7PxHePdq0o=; b=I6q1y0tcxAMjjdoJod5qWJYE7KSLaohAiISvZTT5LBHNp+Ib+Q3NJ4EIIQTdFlo/Bg RlZVLz1JqElwkcxzTtVSxJH5PDGgZcZ3sSy/B3jv01PPAAFKCnJ38HMtArX0saZ9e5Eq ZHfhh+BypuEeX61UngdMaWabPSO+ZeQWxBBWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S91pqBIXOMqhpCywJzCF5HgxB4jKWpemY7PxHePdq0o=; b=HnovUHe8rJMIhw79YR25c9BlgLTuyU4avAMcp2izccp/Y5+rbxYJPmEkajfW2J3xab TWZODa0lbAER1rySO8FZoDGf2/94QfcXrU5N24O6XI8TFZVmfCSJk7mhTJ6u2bJiJn42 ZGF3xbSAp9SqKTPuDXm0Qkih2E+OT+hxKAA1Z4HRXbZyhGo/+mGsQ/s+Nhr3LzAfzgqu W5uZx56PMBzAHEncpFY+wb2kMf+PITpZ8i/D3iXzLfswRHtLBS9z/8Gv1pGCSQBT66xI aiKzn/tsyfM3cVRpKpMJda7YdATUZNHiXbre1fIUPotlr8ktBAkilIKYNV2/GPGwjajl 7gTQ== X-Gm-Message-State: AOAM532hfZh6bOo10k3nL9yvvUyUI87VIkcR34eABXLAlfYBzBPtDFLK CGJczSUbqRjexYp4mBpuJWlTwgzbsEMtEQ== X-Google-Smtp-Source: ABdhPJyU0s4WREt+vb3NfmlvNYiYPuiSOOW1vWuul25+/XsrNtiGhLF7+dza35AzIiS1VSeZwurVxA== X-Received: by 2002:a17:90a:1109:: with SMTP id d9mr22659634pja.201.1595228627529; Mon, 20 Jul 2020 00:03:47 -0700 (PDT) Received: from ubuntu.Home (anon-62-111.vpn.ipredator.se. [46.246.62.111]) by smtp.gmail.com with ESMTPSA id gn5sm10613862pjb.23.2020.07.20.00.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 00:03:46 -0700 (PDT) From: Matt Ranostay To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, Matt Ranostay , devicetree@vger.kernel.org Subject: [PATCH v2 2/3] dt-bindings: iio: chemical: add O2 EZO module documentation Date: Mon, 20 Jul 2020 00:03:29 -0700 Message-Id: <20200720070330.259954-3-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720070330.259954-1-matt.ranostay@konsulko.com> References: <20200720070330.259954-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Matt Ranostay Acked-by: Rob Herring --- .../devicetree/bindings/iio/chemical/atlas,sensor.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml b/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml index 69e8931e0ae8..46496dc250f2 100644 --- a/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml +++ b/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml @@ -19,6 +19,7 @@ description: | http://www.atlas-scientific.com/_files/_datasheets/_oem/pH_oem_datasheet.pdf http://www.atlas-scientific.com/_files/_datasheets/_oem/RTD_oem_datasheet.pdf http://www.atlas-scientific.com/_files/_datasheets/_probe/EZO_CO2_Datasheet.pdf + https://www.atlas-scientific.com/files/EZO_O2_datasheet.pdf properties: compatible: @@ -29,6 +30,7 @@ properties: - atlas,ph-sm - atlas,rtd-sm - atlas,co2-ezo + - atlas,o2-ezo reg: maxItems: 1 From patchwork Mon Jul 20 07:03:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 11672969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 189A7138C for ; Mon, 20 Jul 2020 07:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0153220734 for ; Mon, 20 Jul 2020 07:03:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="ieNE+kVt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgGTHDv (ORCPT ); Mon, 20 Jul 2020 03:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgGTHDv (ORCPT ); Mon, 20 Jul 2020 03:03:51 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C772C0619D2 for ; Mon, 20 Jul 2020 00:03:51 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id mn17so9742138pjb.4 for ; Mon, 20 Jul 2020 00:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YCDSxGJaqCTGCHhKUyNTBRjUkC1aBRbMkiZdv2yCaVY=; b=ieNE+kVtIiKgTbFFyayjdWeGr6YQagiKdIMjWE4z0V2gPyYa2MKvltwPZH0JcZ9/nt hrR3OozjdR1qDMf+41PWUIANDmIu9VWFC2FcZ8DhC3yPQ2gXvAmt++Ns1JsTg2hJxf8v 01+VCCef7UrZRfzoOrVP0x5oYh5lnj1nYCSWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCDSxGJaqCTGCHhKUyNTBRjUkC1aBRbMkiZdv2yCaVY=; b=ZbC00acpps/Uui4zM43gPg1XD97AyTlGMYUwUg3NTG+jNKkr7mPFIpknFIzAjVlr5z iz9vkD2YofNIwzmMBfXnNtBeTugfvdV9q3cWZ476UCJS7V7VEbvLUeCHFSNNf6yXW55n gHvQ0o72OXTd9oF3Zc6tfaVn5xSmnrUtY278HGuf7cbmVi8ZsN1noGm3RSIm4RbifqCl BkHwxSbDw37lW/YyZUf3ia/yglgzjPjS7ZX+18u+1ylSMCJnGPKilk9EdHCV76Uytuu4 Bef5XoQBUfmpG2Gq3E2yWR8mNTlNhlJfGjTODb4V5OpB0sao5MOf3jBhgF7SsPIohM+r SIZg== X-Gm-Message-State: AOAM530K95e8rQxgz+hDdt4rllssiIiEHcfDCe66Q8Mt7q/CPY5ggKfh D3OdGvoNRky6pdOrYrcXp1PJcv0MniU3Zg== X-Google-Smtp-Source: ABdhPJzuAQDK5dynOp8MQ/bA726fns0+SKLLiOL460k/KAzc0wjay8nOpphiXZuk7AxtmT6wmzDE/w== X-Received: by 2002:a17:902:b113:: with SMTP id q19mr16954272plr.170.1595228630598; Mon, 20 Jul 2020 00:03:50 -0700 (PDT) Received: from ubuntu.Home (anon-62-111.vpn.ipredator.se. [46.246.62.111]) by smtp.gmail.com with ESMTPSA id gn5sm10613862pjb.23.2020.07.20.00.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 00:03:50 -0700 (PDT) From: Matt Ranostay To: linux-iio@vger.kernel.org Cc: jic23@kernel.org, Matt Ranostay Subject: [PATCH v2 3/3] iio: chemical: atlas-ezo-sensor: add support for O2 sensor Date: Mon, 20 Jul 2020 00:03:30 -0700 Message-Id: <20200720070330.259954-4-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720070330.259954-1-matt.ranostay@konsulko.com> References: <20200720070330.259954-1-matt.ranostay@konsulko.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add support for the Atlas EZO O2 chemical sensor which required some refactoring of the driver and parsing of i2c transfer. Sensor data is converted by the scaling value from percent to IIO_CONCENTRATION. Signed-off-by: Matt Ranostay --- drivers/iio/chemical/atlas-ezo-sensor.c | 74 ++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c index a94eb8a6bf32..94188c84e65f 100644 --- a/drivers/iio/chemical/atlas-ezo-sensor.c +++ b/drivers/iio/chemical/atlas-ezo-sensor.c @@ -16,10 +16,11 @@ #include #define ATLAS_EZO_DRV_NAME "atlas-ezo-sensor" -#define ATLAS_CO2_INT_TIME_IN_MS 950 +#define ATLAS_INT_TIME_IN_MS 950 enum { ATLAS_CO2_EZO, + ATLAS_O2_EZO, }; struct atlas_ezo_device { @@ -38,31 +39,54 @@ struct atlas_ezo_data { u8 buffer[8]; }; +#define ATLAS_CONCENTRATION_CHANNEL(_modifier) \ + { \ + .type = IIO_CONCENTRATION, \ + .modified = 1,\ + .channel2 = _modifier, \ + .info_mask_separate = \ + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = 0, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 32, \ + .storagebits = 32, \ + .endianness = IIO_CPU, \ + }, \ + } + static const struct iio_chan_spec atlas_co2_ezo_channels[] = { - { - .type = IIO_CONCENTRATION, - .modified = 1, - .channel2 = IIO_MOD_CO2, - .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), - .scan_index = 0, - .scan_type = { - .sign = 'u', - .realbits = 32, - .storagebits = 32, - .endianness = IIO_CPU, - }, - }, + ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_CO2), +}; + +static const struct iio_chan_spec atlas_o2_ezo_channels[] = { + ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_O2), }; static struct atlas_ezo_device atlas_ezo_devices[] = { [ATLAS_CO2_EZO] = { .channels = atlas_co2_ezo_channels, .num_channels = 1, - .delay = ATLAS_CO2_INT_TIME_IN_MS, + .delay = ATLAS_INT_TIME_IN_MS, }, + [ATLAS_O2_EZO] = { + .channels = atlas_o2_ezo_channels, + .num_channels = 1, + .delay = ATLAS_INT_TIME_IN_MS, + } }; +static void atlas_ezo_sanitize(char *buf) +{ + char *ptr = strchr(buf, '.'); + + if (!ptr) + return; + + for (; *ptr; ptr++) + *ptr = *(ptr + 1); +} + static int atlas_ezo_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -96,6 +120,9 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev, return -EBUSY; } + /* removing floating point for fixed number representation */ + atlas_ezo_sanitize(data->buffer + 2); + ret = kstrtol(data->buffer + 1, 10, &tmp); *val = tmp; @@ -105,9 +132,16 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev, return ret ? ret : IIO_VAL_INT; } case IIO_CHAN_INFO_SCALE: - *val = 0; - *val2 = 100; /* 0.0001 */ - return IIO_VAL_INT_PLUS_MICRO; + switch (chan->channel2) { + case IIO_MOD_CO2: + *val = 0; + *val2 = 100; /* 0.0001 */ + return IIO_VAL_INT_PLUS_MICRO; + case IIO_MOD_O2: + *val = 100; + return IIO_VAL_INT; + } + return -EINVAL; } return 0; @@ -119,12 +153,14 @@ static const struct iio_info atlas_info = { static const struct i2c_device_id atlas_ezo_id[] = { { "atlas-co2-ezo", ATLAS_CO2_EZO }, + { "atlas-o2-ezo", ATLAS_O2_EZO }, {} }; MODULE_DEVICE_TABLE(i2c, atlas_ezo_id); static const struct of_device_id atlas_ezo_dt_ids[] = { { .compatible = "atlas,co2-ezo", .data = (void *)ATLAS_CO2_EZO, }, + { .compatible = "atlas,o2-ezo", .data = (void *)ATLAS_O2_EZO, }, {} }; MODULE_DEVICE_TABLE(of, atlas_ezo_dt_ids);