Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3629299pxb; Sun, 31 Jan 2021 23:46:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnjqkyfr3lU5If362u4insvU54G+bwZvD/cCQWwGzxYCdUdt/ohkcrfJExUIqQcw5DfL10 X-Received: by 2002:a17:907:210d:: with SMTP id qn13mr8103333ejb.377.1612165597617; Sun, 31 Jan 2021 23:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612165597; cv=none; d=google.com; s=arc-20160816; b=cqeekANdx7Kla/CHm/iNUASSqRB6zYG4EXIa1kebcAsCQBTFu/6hiKbz0/x/SZGG8v 16iA+TtywKSzeNJFqz39xDTw5uBOHrk4ewm6A4b8+dN78bRUG8J2+tJRDvW8rJHOS2dx Of6ramYqHQBFhWfpV5JkgKRPAOmvDfp6UoDBUl0eKkyoK1MUGjdvBjYPXYR1uCTMve16 x3kdXtR2vFFNIgft0Iuzs/456r6lKsPz9FzM5JJON+ujcBUZUILMrUl1JAkbhJ9gHm2A K/SggjUBQODzM/6nfR0XSHKQUvYcezCulu0x1AAvArkStV1R6vsgI9fW1J2evC/tVoEG tZEQ== 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=/ZDaTUGmg4foB8aX13uOc6TBE3ehUpc6onVnqvoQ/Es=; b=VKJV6aph3zOqO6oftsAQfvYLby6IlzX0zxwPz25ZKvBV7D+mP7QkmX77WZRntFXLo2 CyDdnq/+xOWYZgpKDXINWdcxLZwK3f5Dv4O9yvjyNShvnScOpPBxBeLF3V82apHRozTq iVi8QUFKd1tLoC6qB7E63+fUXRhHWkahKV6q+nX3yr2dSghhnJds3YIHUm03QqZ2CFgY 1ww/TTI56Wr4ZJ2DT6+pFRql46gwn9s5abTeuccYuuo2ei1LT7JISrImq7YQMF30Ufvr Ei87tL5kSZrLOJYxmOtr5Jdt2Dv4n6Utt4QpS0+0XUGYGzW84LwwTgV+H9O+xnXcPm21 IYYg== 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 m25si397064eda.322.2021.01.31.23.46.13; Sun, 31 Jan 2021 23:46:37 -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 S232278AbhBAHn5 (ORCPT + 99 others); Mon, 1 Feb 2021 02:43:57 -0500 Received: from mga12.intel.com ([192.55.52.136]:46039 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232215AbhBAHnu (ORCPT ); Mon, 1 Feb 2021 02:43:50 -0500 IronPort-SDR: EjOT25gxAylLeFWunstVpRoFrzHC/HmIywKqzXuYTHk0NWT0DyA6BUhe5j6hw5HTtAgu19XL8I nWQ/UxshWMhw== X-IronPort-AV: E=McAfee;i="6000,8403,9881"; a="159813881" X-IronPort-AV: E=Sophos;i="5.79,391,1602572400"; d="scan'208";a="159813881" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2021 23:43:10 -0800 IronPort-SDR: SYO1Z+gug+MgUX9DKbHORRey7fluggwFcC/OJHDikvhNFpqbp7NV5UZSf0N9KQWaUqvyOKKVT1 rs/9D00g9aQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,391,1602572400"; d="scan'208";a="432235895" Received: from host.sh.intel.com ([10.239.154.115]) by orsmga001.jf.intel.com with ESMTP; 31 Jan 2021 23:43:07 -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 2/3] iio: hid-sensor-als: Add relative hysteresis support Date: Mon, 1 Feb 2021 15:43:57 +0800 Message-Id: <20210201074358.18435-3-xiang.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210201074358.18435-1-xiang.ye@intel.com> References: <20210201074358.18435-1-xiang.ye@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hid sensor als uses 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