From nobody Mon Nov 25 10:32:29 2024 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3CC31DEFFD for ; Mon, 28 Oct 2024 16:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730133506; cv=none; b=VJpJEOtpLpYbj0HU4vVj8IonccbC/B5j8nJdO5FyPb2E0GSt66LbAoQ4SR/1aL5rPF0MPm3tsB6wnhpOTizagFqxuoDpDWMPrRHcJ6zOdaqgz9N2vglKU/ct2FU8jcuyOGbSb0rOwxseWM8j6e0EhrQJNcX1PI3+ECfIn+mZqdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730133506; c=relaxed/simple; bh=DdpcXG86yQKHjwGV1wZp83j21Iocs6OVFoX2GrPRNF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=khxR8Mwmoog1kj7GNsi/Cpo3LRCtCC5oQvlZhjQqLYVmbK+PjgH/mJ0zbhfD4CSfXaVTnmNwz7+qEHKYTkJzgxCfz5l64jWPitDbTPRkQV7ecLmDlsFC232LpLJ0sk5h6ZO9cclzGQyj6ZYmNOUB0h49EeTUDJNvkmgtCqo5mt8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Bdo2ly5b; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Bdo2ly5b" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so42206305e9.0 for ; Mon, 28 Oct 2024 09:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730133502; x=1730738302; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ABkPdp6W6/7TraRKOCc3eYdKt9nFCUN5Ze+SrjQuTOs=; b=Bdo2ly5b7LdcHQsCbWR+JGEgV1Br9NcG3LCAqU46vXvRagiub1kwTK+91+4TvRpBCb PeFMWxgCzOyyfgDIT7d+sqfFr+pmbUJHJ/sVzafGAnhPGIndRkUN6q8aK+HKlfjw15uo ginoeZayQiFSsnXRVyRGvdLbz/mwz+wAAyPcdNaZbxKAUpRSnWEDF3bLD4RgbrHv3yL8 Qh6O44arqN3LnGXLa8aNFCoL+JTsoG+OgIi9E0JsIVCrlOk09kfMkHy9T52P/pszRToN X5zMMBD9YY7nfynos9hcFOlJktj8TIob7v8oRADz48ZnHPaxmOxLh7Lw5tQrYl9UJfQ1 RNUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730133502; x=1730738302; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ABkPdp6W6/7TraRKOCc3eYdKt9nFCUN5Ze+SrjQuTOs=; b=URmeJgtwGfaGq2Lm0pLuoleU5RzAuFWdbDyVe2pEqdJnxK2NlTCHCSTLaK3dYdddEl 8tubTWmIhuSrRuEY3BbRcNZ/wKGNka8ReoGaf4NUTaQVoRQau5KcNHxHHilQ0gSN0t/y o835B6yJFcroEtfyy8rHpDsHK/gYsolpbUMK1xBv9CxqzRU8lTdjuUs/Bup7qYWB7q2O OaTuL6w0JZhmqLe/RJ4THT3bixftZjKqqpc5H5eReDBbG+y0tdW8e4D+lIFoL40kQ/qI jJWDgqv2FN3hui7lQX6T+4z3rx9LJrxxywzDlrNUwo9Nb77y3hxlSZ3SXOppGMvrAUxT tT2A== X-Forwarded-Encrypted: i=1; AJvYcCUrMU2CAtnvfoxpTyF3Oq7LmMMLDpI9yw6nvRaRW+ZeRvC2c8+bVP2DsXqX9mvgQ7s8EmqCrpcFZRVOiyc=@vger.kernel.org X-Gm-Message-State: AOJu0YxaFOHjTuHquEHbEOSbAJcYfHWaBaeuCa4KcpXgDiQB+ijYFPux D9Zw19svPIE7+K3jQf5Qn7G5gePiz3cu/AedrMC5YDvGK+9XCi6SecEuvl3vE0fByi6WXkev9s+ fuyI= X-Google-Smtp-Source: AGHT+IEasamIcI+PZCE+cvM4eiyJPSM/zmLg/qvaggXa7RCvn+IAAwng/+80MgvZ7i79D4r0fs40Hg== X-Received: by 2002:a05:600c:3b1a:b0:430:52ec:1e41 with SMTP id 5b1f17b1804b1-4319acb1072mr93360515e9.17.1730133500853; Mon, 28 Oct 2024 09:38:20 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b55d753sm147308435e9.11.2024.10.28.09.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:38:20 -0700 (PDT) From: Julien Stephan Date: Mon, 28 Oct 2024 17:38:11 +0100 Subject: [PATCH 1/2] iio: events.h: add event identifier macros for differential channel Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-1-b452c90f7ea6@baylibre.com> References: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com> In-Reply-To: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com> To: Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 Currently, there are 3 helper macros in iio/events.h to create event identifiers: - IIO_EVENT_CODE : create generic event identifier for differential and non differential channels - IIO_MOD_EVENT_CODE : create event identifier for modified (non differential) channels - IIO_UNMOD_EVENT_CODE : create event identifier for unmodified (non differential) channels For differential channels, drivers are expected to use IIO_EVENT_CODE. However, only one driver in drivers/iio currently uses it correctly, leading to inconsistent event identifiers for differential channels that don=E2=80=99t match the intended attributes (such as max1363.c that supports differential channels, but only uses IIO_UNMOD_EVENT_CODE). To prevent such issues in future drivers, a new helper macro, IIO_DIFF_EVENT_CODE, is introduced to specifically create event identifiers for differential channels. Only one helper is needed for differential channels since they cannot have modifiers. Additionally, the descriptions for IIO_MOD_EVENT_CODE and IIO_UNMOD_EVENT_CODE have been updated to clarify that they are intended for non-differential channels, Signed-off-by: Julien Stephan Reviewed-by: David Lechner --- include/linux/iio/events.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/linux/iio/events.h b/include/linux/iio/events.h index a4558c45a548834e33702927609ca9ad447c67de..eeaba5e1525e44fd3b51985ffa9= 9837efc6cdd00 100644 --- a/include/linux/iio/events.h +++ b/include/linux/iio/events.h @@ -30,7 +30,8 @@ =20 =20 /** - * IIO_MOD_EVENT_CODE() - create event identifier for modified channels + * IIO_MOD_EVENT_CODE() - create event identifier for modified (non + * differential) channels * @chan_type: Type of the channel. Should be one of enum iio_chan_type. * @number: Channel number. * @modifier: Modifier for the channel. Should be one of enum iio_modifier. @@ -43,7 +44,8 @@ IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0) =20 /** - * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels + * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified (non + * differential) channels * @chan_type: Type of the channel. Should be one of enum iio_chan_type. * @number: Channel number. * @type: Type of the event. Should be one of enum iio_event_type. @@ -53,4 +55,16 @@ #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \ IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0) =20 +/** + * IIO_DIFF_EVENT_CODE() - create event identifier for differential channe= ls + * @chan_type: Type of the channel. Should be one of enum iio_chan_type. + * @chan1: First channel number for differential channels. + * @chan2: Second channel number for differential channels. + * @type: Type of the event. Should be one of enum iio_event_type. + * @direction: Direction of the event. One of enum iio_event_direction. + */ + +#define IIO_DIFF_EVENT_CODE(chan_type, chan1, chan2, type, direction) \ + IIO_EVENT_CODE(chan_type, 1, 0, direction, type, 0, chan1, chan2) + #endif --=20 2.47.0 From nobody Mon Nov 25 10:32:29 2024 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DA231DEFFB for ; Mon, 28 Oct 2024 16:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730133505; cv=none; b=T3T4tSB9NTvKSBtKL1Ra9RT/JStqsUQCNEuMCBdfslb6RcYpo+SlpBsAJiXaxVr90DOW0CzWoE7BgzEYcSGihUTT90QREfkFNcJ6lhv3ZGurwWavDUglD7Cu6wlj/HUP0OrvePdVN9u278aQURBsKmL4Ae4D6z1FXG/9H5E7pDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730133505; c=relaxed/simple; bh=GwmLKGWq7SnAKEHzZ7mh55t2QhA4SepsZELQACv3lyk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rFyC2IpTTHAEotLSmA2hwGM/Xt1MokuSVmA8T0HqxTzdzRI0a1upLJ7g9EM41Ek+XwL6g+b39WOWvY7gxGqJm2p6W94cOaNCGrevA5OVyDfCrHpFvwOjplWMxGAJLOpMr1lGaijm0pU5rVomWQvxh7kMTbjNUaxj7tPAKBQKQXw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=zGw4ABcS; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="zGw4ABcS" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so42206265e9.0 for ; Mon, 28 Oct 2024 09:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730133502; x=1730738302; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=h8d/8BdE9Dg0MG57NehuCwwrXsMFrv7Nxa30bsUkjf8=; b=zGw4ABcSo28XlzJw1u158HcVTqWt3k3MblDch96Fo130WrEEC0RQIEIjDT7HaSThIy sT9DriHfG500/bhAdtgfXbrXjOVWd4Q/7Ci4OTOXAz5Jz1AyGHS18vP89CVAzBED1pQZ wZ1AZ5y/tt+3HBrkPp/fikqAY7ggjnSjPZRPM8mwkJksyY9Rr49AWNVtoyNlNt4EDr52 X5e9keKNkAYJcOMoTeC6lrhVAn1BTvqD1l/3a1jRQdoW0sISx/UTGM4VpnsNK/zXOnbF f+J24UnYE1aFgUXu24H7zECA7cVR0dEZXBiQOieU7LHoNjAJYF0oF6CXBzkd5LtBrGy6 cyLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730133502; x=1730738302; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8d/8BdE9Dg0MG57NehuCwwrXsMFrv7Nxa30bsUkjf8=; b=Yy2tf7A81pt+wS3EAKhUiSp3xJraYyMUgo86WDuR1kMU1OZOzMLHb38vLy7o4WZQkI Leoe8hEbU2vYZRKPl5vLj2DusGw3HIeIpCDkb3kn3X3utknHaAP4L3xA1XSlewtS+Kvt SrkYnIBn7EovCQwtSC4ApBH5Ar8PzjG7pXvj6lGJME54WHFGOm73nt4Xr5TLH8k+cL6j ar3IcJln3PjGAGah2vuCPakL6T430E+KhIaSJwcLqpEiDumxq8mIE2Zqt1i/lsNaiWDT urC1E0BM2LdGWNkwvCs/xTjlKmm9pHRHpivAMStnk5dNCoQurLq9aC392xEoX+S5WuKE LbVg== X-Forwarded-Encrypted: i=1; AJvYcCULRwdyjE+G5v5R6RkNyXfedNyS1Ic1yjL5YpjAK4XUrMMQ2iI7hSA0FWOdN0uINGJpvx9cgYalDp+nB94=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5cL3fKGrvIDXKy6Jl0Y9ZOSGvhJVjJfhoAzIa1XMVITLYWQ4L 1gW11yFtsWwpLSCbTa0NlmIo32ch1fh+DGbxuuMZPw1N+hbBDhZlONRYReeILgI= X-Google-Smtp-Source: AGHT+IEcZL/+CpoQeWxFOiE+FPUFyoFFNn0hz6i51bN2N293qZI4uF4f2vK6C5Wn+vImxGpl1A9iMQ== X-Received: by 2002:a05:600c:3b94:b0:431:4e3f:9dee with SMTP id 5b1f17b1804b1-4319ac7409amr66295955e9.4.1730133501663; Mon, 28 Oct 2024 09:38:21 -0700 (PDT) Received: from [192.168.1.64] (2a02-842a-d52e-6101-6fd0-06c4-5d68-f0a5.rev.sfr.net. [2a02:842a:d52e:6101:6fd0:6c4:5d68:f0a5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b55d753sm147308435e9.11.2024.10.28.09.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:38:21 -0700 (PDT) From: Julien Stephan Date: Mon, 28 Oct 2024 17:38:12 +0100 Subject: [PATCH 2/2] iio: adc: ad7280a: use IIO_DIFF_EVENT_CODE macro helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-2-b452c90f7ea6@baylibre.com> References: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com> In-Reply-To: <20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com> To: Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Stephan X-Mailer: b4 0.14.2 The IIO_DIFF_EVENT_CODE macro helper was introduced to provide a more specific alternative to the generic IIO_EVENT_CODE macro for handling differential channels. This commit updates the code to use IIO_DIFF_EVENT_CODE for better clarity and maintainability. However, the current implementation incorrectly sets both chan1 and chan2 to 0. To maintain compatibility and avoid breaking existing user space applications, this behavior is preserved for now. Signed-off-by: Julien Stephan Reviewed-by: David Lechner --- drivers/iio/adc/ad7280a.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad7280a.c b/drivers/iio/adc/ad7280a.c index 35aa39fe4bde62290996abd3076ac350eedf1052..f9f32737db8079a5b96847442a6= 4fea811438363 100644 --- a/drivers/iio/adc/ad7280a.c +++ b/drivers/iio/adc/ad7280a.c @@ -822,17 +822,15 @@ static irqreturn_t ad7280_event_handler(int irq, void= *private) if (FIELD_GET(AD7280A_TRANS_READ_CONV_CHANADDR_MSK, channels[i]) <=3D AD7280A_CELL_VOLTAGE_6_REG) { if (val >=3D st->cell_threshhigh) { - u64 tmp =3D IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, - IIO_EV_DIR_RISING, - IIO_EV_TYPE_THRESH, - 0, 0, 0); + u64 tmp =3D IIO_DIFF_EVENT_CODE(IIO_VOLTAGE, 0, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING); iio_push_event(indio_dev, tmp, iio_get_time_ns(indio_dev)); } else if (val <=3D st->cell_threshlow) { - u64 tmp =3D IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0, - IIO_EV_DIR_FALLING, - IIO_EV_TYPE_THRESH, - 0, 0, 0); + u64 tmp =3D IIO_DIFF_EVENT_CODE(IIO_VOLTAGE, 0, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING); iio_push_event(indio_dev, tmp, iio_get_time_ns(indio_dev)); } --=20 2.47.0