diff mbox series

hwmon: (nct6775) Flip Caseopen alarm as 1 is OK

Message ID 20230715153234.1307325-1-ahmad@khalifa.ws (mailing list archive)
State Rejected
Headers show
Series hwmon: (nct6775) Flip Caseopen alarm as 1 is OK | expand

Commit Message

Ahmad Khalifa July 15, 2023, 3:32 p.m. UTC
we flip intrusion alarms as nc6796d-s datasheet states:
- CASEOPEN0_STS. CaseOpen Status.
  * 1: Caseopen0 is detected and latched.
  * 0: Caseopen0 is not latched.

Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>
---
 drivers/hwmon/nct6775-core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)


base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
prerequisite-patch-id: 36e3467bd9ea72cb3ad2bef638a8389a9537d111
prerequisite-patch-id: 85db508f68cabb50472c0cc5ef3953fc46bee3b1
prerequisite-patch-id: 1504eb67a66d80604d73cda09059629f102fc961

Comments

Guenter Roeck July 15, 2023, 4:33 p.m. UTC | #1
On 7/15/23 08:32, Ahmad Khalifa wrote:
> we flip intrusion alarms as nc6796d-s datasheet states:
> - CASEOPEN0_STS. CaseOpen Status.
>    * 1: Caseopen0 is detected and latched.
>    * 0: Caseopen0 is not latched.
> 
> Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>
> ---
>   drivers/hwmon/nct6775-core.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
> index 1006765d8483..b0435b0bb1ba 100644
> --- a/drivers/hwmon/nct6775-core.c
> +++ b/drivers/hwmon/nct6775-core.c
> @@ -1734,6 +1734,16 @@ nct6775_show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
>   		return PTR_ERR(data);
>   
>   	nr = data->ALARM_BITS[sattr->index];
> +
> +	/* nc6796d-s datasheet states: CASEOPEN0_STS. CaseOpen Status.
> +	 * 1: Caseopen0 is detected and latched.
> +	 * 0: Caseopen0 is not latched.
> +	 * so we flip intrusion alarms, 1 is OK
> +	 */
> +	if (data->kind == nct6799 && sattr->index >= INTRUSION_ALARM_BASE)
> +		return sprintf(buf, "%u\n",
> +		       (unsigned int)!((data->alarms >> nr) & 0x01));
> +

Ok, I am lost here. 1 means that case open is detected and latched. That
is no different to all other chips of the series. Why would you want
to return 0 (no alarm) in this case for nc6796d-s ?

Guenter

>   	return sprintf(buf, "%u\n",
>   		       (unsigned int)((data->alarms >> nr) & 0x01));
>   }
> 
> base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
> prerequisite-patch-id: 36e3467bd9ea72cb3ad2bef638a8389a9537d111
> prerequisite-patch-id: 85db508f68cabb50472c0cc5ef3953fc46bee3b1
> prerequisite-patch-id: 1504eb67a66d80604d73cda09059629f102fc961
Ahmad Khalifa July 15, 2023, 4:43 p.m. UTC | #2
On 15/07/2023 17:33, Guenter Roeck wrote:
> On 7/15/23 08:32, Ahmad Khalifa wrote:
>> +    /* nc6796d-s datasheet states: CASEOPEN0_STS. CaseOpen Status.
>> +     * 1: Caseopen0 is detected and latched.
>> +     * 0: Caseopen0 is not latched.
>> +     * so we flip intrusion alarms, 1 is OK
>> +     */
> Ok, I am lost here. 1 means that case open is detected and latched. That
> is no different to all other chips of the series. Why would you want
> to return 0 (no alarm) in this case for nc6796d-s ?

I read it as 'latched' vs 'not latched', but if it's the same for all
of them, then I take this patch back.
My mistake.
Guenter Roeck July 15, 2023, 5:29 p.m. UTC | #3
On 7/15/23 09:43, Ahmad Khalifa wrote:
> On 15/07/2023 17:33, Guenter Roeck wrote:
>> On 7/15/23 08:32, Ahmad Khalifa wrote:
>>> +    /* nc6796d-s datasheet states: CASEOPEN0_STS. CaseOpen Status.
>>> +     * 1: Caseopen0 is detected and latched.
>>> +     * 0: Caseopen0 is not latched.
>>> +     * so we flip intrusion alarms, 1 is OK
>>> +     */
>> Ok, I am lost here. 1 means that case open is detected and latched. That
>> is no different to all other chips of the series. Why would you want
>> to return 0 (no alarm) in this case for nc6796d-s ?
> 
> I read it as 'latched' vs 'not latched', but if it's the same for all
> of them, then I take this patch back.
> My mistake.
> 
> 
The chips latch the case open signal, so once case open is detected
it has to be reset by writing into the attribute. The rest (latched
vs. not latched) is just wording; "not latched" just means that
case open was not detected since the bit was last reset.

Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 1006765d8483..b0435b0bb1ba 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1734,6 +1734,16 @@  nct6775_show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
 		return PTR_ERR(data);
 
 	nr = data->ALARM_BITS[sattr->index];
+
+	/* nc6796d-s datasheet states: CASEOPEN0_STS. CaseOpen Status.
+	 * 1: Caseopen0 is detected and latched.
+	 * 0: Caseopen0 is not latched.
+	 * so we flip intrusion alarms, 1 is OK
+	 */
+	if (data->kind == nct6799 && sattr->index >= INTRUSION_ALARM_BASE)
+		return sprintf(buf, "%u\n",
+		       (unsigned int)!((data->alarms >> nr) & 0x01));
+
 	return sprintf(buf, "%u\n",
 		       (unsigned int)((data->alarms >> nr) & 0x01));
 }