Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3153154pxb; Sat, 6 Feb 2021 23:02:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1+9d66E9nTPHrfVU2HAjWKh7hW+6UqSfidqdmqyp1KG21/6QCUGUZrvd3Jji3PLlHFQz0 X-Received: by 2002:aa7:c64a:: with SMTP id z10mr11328879edr.61.1612681375344; Sat, 06 Feb 2021 23:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612681375; cv=none; d=google.com; s=arc-20160816; b=NmBTj2/fINIzEszhjvyppsthdT586zrxnRh7FQX6PqCd4lxSXybvECZ6oF/cg99qx4 kSgcA7QT4ZE3JKTGGpjZ0Ba1IyT0+pKdK6k86InSuu4HqMDGw3RNQelMSAtDQ2rQCLCy U7cZleNQhxVjNMSkpAsy7GZvwhtN9KiztcI5y0JUfE03WY2rvmAbs/bi5KOYj8lUvPdj sqA7aU7694htInNe27xmSFWS8B/eUtsvcJ/+4Duyx4NrD0nHz7jsfe7/JIe06rIC8nve l6eSiWzw90JvoDbw6h09mo3Fzhq3w891WgB0xqDNVho3t6FfMWcsMY7YgoGku2AM+Qt5 wVJg== 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:ironport-sdr:ironport-sdr; bh=vv26Hc83RgnNnXw+0mOdOvk/Jy8j4MxIgHyLVr+t4j4=; b=inYSqwzTQja+Pk1FO+MUrLr1UJNsJz3Ik+QrvDKY4ZepWAnOsOybBGq1+FrS4zr7fm xaCznFXNB2kEc+FharR1X4W/sR+rGTRZCk8KcwjMTK/fOaXkmR1PVp4sDr03oQiaYR0M GkYRKaJtx3ukzlbwg3ljGVsxk0K752ziK7NwtLybSf/zAYcDd0WIu3KP1ROCgO/KoLrk 2jHFP0AIkp1jIw2bk0ZmHydxqYfmt5cfKEbdojIAupoZbtIBQSxg/e2GYuQYOGazkfb/ Fne+bR8urY6AmwUIR+nOMK2TkUwPJK4/GnJh4Qr12Z9IdvNeaFlFH6xhk+l/fHaGInEv jMSw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk20si4680918ejb.203.2021.02.06.23.02.32; Sat, 06 Feb 2021 23:02:55 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbhBGHBf (ORCPT + 99 others); Sun, 7 Feb 2021 02:01:35 -0500 Received: from mga11.intel.com ([192.55.52.93]:37942 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbhBGHAp (ORCPT ); Sun, 7 Feb 2021 02:00:45 -0500 IronPort-SDR: pJmBNURaKSUNGpw2XBWSsAtR5phrLA7BxkuOkt+3nr5C8gjhwtCsGCjSvTqkNu7zUa8Lm/wMub vynZCv+9V8uA== X-IronPort-AV: E=McAfee;i="6000,8403,9887"; a="178080529" X-IronPort-AV: E=Sophos;i="5.81,159,1610438400"; d="scan'208";a="178080529" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 23:00:04 -0800 IronPort-SDR: tVoW+3raKaBNdfPkP1uqmsmqMj78Lz9JHKc7vY6Mk3C+3mo+YN4tvW4VF2bN6m0oJzF5wWjV7K yv6IwQtaFU9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,159,1610438400"; d="scan'208";a="374982582" Received: from host.sh.intel.com ([10.239.154.115]) by fmsmga008.fm.intel.com with ESMTP; 06 Feb 2021 23:00:02 -0800 From: Ye Xiang To: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@linux.intel.com Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ye Xiang Subject: [PATCH v2 2/3] iio: hid-sensor-als: Add relative hysteresis support Date: Sun, 7 Feb 2021 15:00:47 +0800 Message-Id: <20210207070048.23935-3-xiang.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210207070048.23935-1-xiang.ye@intel.com> References: <20210207070048.23935-1-xiang.ye@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hid sensor als use relative hysteresis, this patch adds the support. Signed-off-by: Ye Xiang --- drivers/iio/light/hid-sensor-als.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index afcdb424bfb8..85c8a05b73cb 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -54,7 +54,8 @@ static const struct iio_chan_spec als_channels[] = { .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_HYSTERESIS), + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_INTENSITY, }, { @@ -63,7 +64,8 @@ static const struct iio_chan_spec als_channels[] = { .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_HYSTERESIS), + BIT(IIO_CHAN_INFO_HYSTERESIS) | + BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), .scan_index = CHANNEL_SCAN_INDEX_ILLUM, }, IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP) @@ -141,6 +143,10 @@ static int als_read_raw(struct iio_dev *indio_dev, ret_type = hid_sensor_read_raw_hyst_value( &als_state->common_attributes, val, val2); break; + case IIO_CHAN_INFO_HYSTERESIS_RELATIVE: + ret_type = hid_sensor_read_raw_hyst_rel_value( + &als_state->common_attributes, val, val2); + break; default: ret_type = -EINVAL; break; @@ -168,6 +174,10 @@ static int als_write_raw(struct iio_dev *indio_dev, ret = hid_sensor_write_raw_hyst_value( &als_state->common_attributes, val, val2); break; + case IIO_CHAN_INFO_HYSTERESIS_RELATIVE: + ret = hid_sensor_write_raw_hyst_rel_value( + &als_state->common_attributes, val, val2); + break; default: ret = -EINVAL; } -- 2.17.1