Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp475127lqp; Mon, 10 Jun 2024 09:30:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU49mYCt16p0T9CCl3u4qFdWAh3fRLdHVeJXJ9T4E3z8eiyzxzpVzdwfLdHCDwkmITIQIB7kVrBxdPqhLjOkVqikauz7E7r20ZFM17NpQ== X-Google-Smtp-Source: AGHT+IGscsQH33BmtTaCs9HjH1vj0jJ4RUuc76XiQcSUGPKWSlsZCfiC+jI8n7pg0vHzWs3ekmWo X-Received: by 2002:a17:90b:14d:b0:2c2:feca:7bbd with SMTP id 98e67ed59e1d1-2c2feca7c51mr3659742a91.39.1718037053881; Mon, 10 Jun 2024 09:30:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037053; cv=pass; d=google.com; s=arc-20160816; b=0LEd2I81GgCsEwmdR5k9jCKuFLuBug8AWwI7q2VBPH6wLduFncld04xjaOUfAk5eXd 4C8vmwiRvsjZl38EcmAnYwrS1O2vm5N6pAzRvXKJ+dd7PkxHDpYFvg6aR7eVrhj9y8rT BYRj32VWuVNTAzLc4hfATxz4UWTMQyRDgWqjxKRp1GZj6x8cQkta6qPBFKTRMXOpb6R7 vwukLMlQfrOBy6eg6warvaO7uoW9IEFgxpN+z+GPVB/HUyfdaFBVpZzStFOKeIpv5m0T 6YfQ9+ScWDxR3Z4YOGWz7RHUIXrhm5rQT0wpOPXyprfyNjySpnxEJy9//CIUDBFjAYAj 5JIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=vFW4QMDXEfiSRxy7aS4QsiVoTt08DVq0GrTNcQt+urE=; fh=MokHlb72PmRo6PnZKBrO1/2RG2epMh4LWTb4CSb+e3Q=; b=TW3/GMBJFpq+9DYVbaoKm4xKID+VGUjCPtTSHMV/dKxNTM5STnHLC/ZJpdo+PyA37L nZy94jz8lZYx3nR52kB5BJCCXXGiEe02Oy0B5V5XiL1FRDkaqcpjPKN0OGYUNBax4Ou0 6bjntm6hE11vWqr1zxFWvCV3XfAMuFJZGP5wFPrC2pM+nwcWr+w6pDi1YkKzI3LA2leG +7FAiXA/Vohauvv/0iGjSRR+9A/saWdTAUqbQwNFqAGrSt/R8CaPjTbDlpgMsl+uU5/3 86Dx9Xf4l3gat2Xmx1EM4lDHxU3hXWzCu5QcxuGkdGwh1ofpbh1YsufjSPTGAUL2hlgW /S6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nhKY5lZW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-208552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208552-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2d1133c33si5244335a91.139.2024.06.10.09.30.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:30:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nhKY5lZW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-208552-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208552-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 587312870A1 for ; Mon, 10 Jun 2024 16:29:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7F4014387C; Mon, 10 Jun 2024 16:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nhKY5lZW" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 992DB5B1F8; Mon, 10 Jun 2024 16:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718036958; cv=none; b=PDQZNR70u8QLPj4JNwzuotyd0wV/KCdg+KG2aBHv2T2to/2t7If7cswuXCkJynYsAwx3B/cKa+36V4OIMcq+DpFNyh/x5AV6m0Ih1Ld2kdDwN0BBJpgAd/gbltzfRGupzb5Bw8KH4xHaQjNqVWDNJXbwEeK521l0G6oODFurc1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718036958; c=relaxed/simple; bh=XbZF71q1zYnvPsR2ymkEb7s6SSdeVRGUxy4y1HaDNj0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iJcVK3vsOkDS2TA+YZReIp8/hnCKQLcHdjLcXXDlSimdOFrTEUCL3/MrPlJR6sW27AfAUKEzNqcm5kFgB9TaPUNfIwOOXtxS98nS4l/YUXUh7VoQgY599u/LFqRjhgk+TdT2u0pgpX+riHATsTKu5/2fkqxCjkwWR+f9/L3r67Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nhKY5lZW; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1f480624d10so41525485ad.1; Mon, 10 Jun 2024 09:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718036956; x=1718641756; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=vFW4QMDXEfiSRxy7aS4QsiVoTt08DVq0GrTNcQt+urE=; b=nhKY5lZWj68rnTFyiMmZmRTKHnQbPa6mbWxuPrpc96pDtjPKJmXqnfs3bT4BMIXZcu UnlP6K/ovePHnHqOts3Dl6xvM4t+HXrfSI3IKazKsqw6x6jEQcCq/nbtdqKy2aMPeDqd 4gi061l56oH9zEQBQNLwEyOYj2/2IS77cBecOEoInvDDUeFSMFNaA8RAJf1Ks46+zVft Hu+sLOrAwEiedJIUYI7WXKPHDlG/eRSUtN0wa9bFGu+51GJZrFl7D/L1EWMQjnArNG4+ /sgDoUFlOw8CB0JD0eXEmwuCOy2S9WM/l/bBlwwBPy3hhfJ29UAzWV4i9qMtQiP3E3aU dljg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718036956; x=1718641756; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vFW4QMDXEfiSRxy7aS4QsiVoTt08DVq0GrTNcQt+urE=; b=If4wbNX78LBSEwYCh8Q+JRTQGxvCxAISiCrzH+eakreL4WEFkooldjB/vwDdn5KNgG hpAnHB68ds/T0KGfMmwPRsRYdF7pt97R6jiAVxiLaEKEOVgaRQ2Tduu7SZk3qYse3dsJ q7/uHCIurEKQQEe9gtlFQw6x8O1zBV+JKbVjJoQYMO+DJDYYrfG0Bb3BkxW1sbwyVUYt /U/4h1mh+U32BfxQvb8f5W0hg8wHaqKa4hYGU1bnMJQzO7Au68QFWLMG7u9Tp3kYC9Sq ns3+13Olhf92eTao6Cc3iBTMxe3qXgq7G0BpezVpCU9x6GuHfq6Sgi/tjpT+zdvq8Had maNA== X-Forwarded-Encrypted: i=1; AJvYcCXXJsRf3IguYszILqBxjf2PiBIrm8E74mUydgp1UJ9lYmehtF2+CSG0d6oQC47bEWBGI5SCs3PYo2PV11TRhLecKwiMuu3OuEELDHe4RSEes1IXf+O5sznwZrdKLooBnGtUo+QyBqCi7tUabW96AJggyskDNVSXooPHkd1aM+b2lfPhekYg X-Gm-Message-State: AOJu0YyQwe8e8xhXcf4PiahIcnPq4BeK7+HLPqrNN8ra/VXSNnLe0VNI ACMBsSFZ2cUbuDy7VA0Dv5N5b/i6ADVjWQQ/ttDwPFcXtoe8mv8wFLEZpg== X-Received: by 2002:a17:902:ecc7:b0:1f2:fb02:3dfd with SMTP id d9443c01a7336-1f6d02d2170mr128827675ad.11.1718036955727; Mon, 10 Jun 2024 09:29:15 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f728492becsm1350945ad.78.2024.06.10.09.29.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 09:29:15 -0700 (PDT) Sender: Guenter Roeck Message-ID: <33f421f0-f52a-4bf5-9efe-727ea5701cd1@roeck-us.net> Date: Mon, 10 Jun 2024 09:29:13 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] hwmon: (ina2xx) Add device tree support to pass alert polarity To: Amna Waseem , Jean Delvare , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Krzysztof Kozlowski , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@axis.com References: <20240603-apol-ina2xx-fix-v3-0-b9eff3158e4e@axis.com> <20240603-apol-ina2xx-fix-v3-2-b9eff3158e4e@axis.com> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBd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jva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240603-apol-ina2xx-fix-v3-2-b9eff3158e4e@axis.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/3/24 03:08, Amna Waseem wrote: > The INA230 has an Alert pin which is asserted when the alert > function selected in the Mask/Enable register exceeds the > value programmed into the Alert Limit register. Assertion is based > on the Alert Polarity Bit (APOL, bit 1 of the Mask/Enable register). > It is default set to value 0 i.e Normal (active-low open collector). > However, hardware can be designed in such a way that expects Alert pin > to become active high if a user-defined threshold in Alert limit > register has been exceeded. This patch adds a way to pass alert polarity > value to the driver via device tree. > > Signed-off-by: Amna Waseem > --- > drivers/hwmon/ina2xx.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c > index d8415d1f21fc..101346d26c88 100644 > --- a/drivers/hwmon/ina2xx.c > +++ b/drivers/hwmon/ina2xx.c > @@ -73,6 +73,11 @@ > #define INA226_READ_AVG(reg) (((reg) & INA226_AVG_RD_MASK) >> 9) > #define INA226_SHIFT_AVG(val) ((val) << 9) > > +#define INA226_ALERT_POLARITY_MASK 0x0002 > +#define INA226_SHIFT_ALERT_POLARITY(val) ((val) << 1) > +#define INA226_ALERT_POL_LOW 0 > +#define INA226_ALERT_POL_HIGH 1 > + > /* bit number of alert functions in Mask/Enable Register */ > #define INA226_SHUNT_OVER_VOLTAGE_BIT 15 > #define INA226_SHUNT_UNDER_VOLTAGE_BIT 14 > @@ -178,6 +183,17 @@ static u16 ina226_interval_to_reg(int interval) > return INA226_SHIFT_AVG(avg_bits); > } > > +static int ina2xx_set_alert_polarity(struct ina2xx_data *data, > + unsigned long val) > +{ > + if (!(val == 0 || val == 1)) > + return -EINVAL; > + The above check is completely unnecessary. This is a static function, and the parameters are known to be either INA226_ALERT_POL_LOW or INA226_ALERT_POL_HIGH. Guenter