Re: [PATCH 1/7] hwspinlock: Introduce refcount

From: Chris Lew
Date: Fri May 17 2024 - 14:33:16 EST




On 5/17/2024 1:58 AM, Bryan O'Donoghue wrote:
On 17/05/2024 00:58, Chris Lew wrote:
+    unsigned int refcnt;

Why int and not refcount_t ?

Have you an argument for or against use of one over another ?


I wanted to avoid the warning if you try to do a refcount_inc on 0. In this case, 0 means the the hwlock is unused but the hwlock should persist while waiting for another request. It seemed like refcount_t expected the associated object to be released once the count hit 0.

Also the count here is serialized by hwspinlock_tree_lock so the need for the atomicity provided by refcount_t was unneeded. Using unsigned int here seemed simpler.

---
bod