From nobody Mon Apr 6 13:01:27 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2FD13C8729 for ; Thu, 19 Mar 2026 11:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918044; cv=none; b=E9vosj2h/jq6+H+vB2GHZSYjTgjtjf8+/RWo3iU1RxfAiBABjAxMKvquLqDnMHHt5pR6+WTkIPvPpl33BlrFgWcnkAZJnyVlJCT4qaTx17zzX1ZRUsgVYNHrqIMboJ72oRbjZuafMe/u1xYBxwCEwKBJ7jwlxgTgaw6nfUVy0Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918044; c=relaxed/simple; bh=I2ZMZdq3pMVowiWGvuz/v7eklt+UR4xDaNbvT2+j7d0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JrKgY6zJNpFHu5hj3iFqBKVH4W6DQg+T8QfeMDb6KpfCHR0VQ09F8oDLo6oHKX5MGHoH84+bDwSgSA/znT97/0RI5CEKHbnVxYZzl8AcxyP/bnlK6MylMSjlksMvKG4CQ1tlZC6AZMeXegLUmfEadRoOg289j0LAuofZ0BtROCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=OM7oZl4w; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="OM7oZl4w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=4Tuc6A/FvFB15id+FPPkagjKPIMyqvuTmoP13uOV7sE=; b=OM7oZl 4wxQSWnDtuWEqld2AHyoETYmdLYMn7OoPkBh5yoZ54wDEQXV1SdREEMEoyKyTTr5 iGxPSyEmYu1MPIoK7XKUPNs7wcbc5FTYLzgvrfmUMe49WR8WrhwyLydGMOilHJNZ oJXeGE5St7docsKmf0BYcjRDfQgdp1OrOdinTQIXww+bFkj8MDDWfk7X/WGprYPG drSePTuacpgC+pyB6A5klblrODCcxCnZ3Nlnik8oTEWZ6tWHII6SoSgS8EACLOnE y5ZYXBEIdzsXBQflrkRN9IgAYAEJRo4DKYYeSCg7xw7WAwHWaJq2IJhW9q27ybFq vdi5+FYYDr6qtptg== Received: (qmail 1100027 invoked from network); 19 Mar 2026 12:00:12 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:12 +0100 X-UD-Smtp-Session: l3s3148p1@MJP5eF5N1q0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 14/15] hwspinlock: refactor provider.h from public header Date: Thu, 19 Mar 2026 11:59:36 +0100 Message-ID: <20260319105947.6237-15-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out the entries only needed for providers from the generic public header. This allows for a clean separation between providers and consumers. All providers are in the hwspinlock subsystem currently and are trivially converted here as well. Signed-off-by: Wolfram Sang Acked-by: Chen-Yu Tsai # for sun6i --- MAINTAINERS | 1 + drivers/hwspinlock/hwspinlock_core.c | 1 + drivers/hwspinlock/omap_hwspinlock.c | 2 +- drivers/hwspinlock/qcom_hwspinlock.c | 2 +- drivers/hwspinlock/sprd_hwspinlock.c | 2 +- drivers/hwspinlock/stm32_hwspinlock.c | 2 +- drivers/hwspinlock/sun6i_hwspinlock.c | 2 +- include/linux/hwspinlock.h | 44 -------------------- include/linux/hwspinlock/provider.h | 60 +++++++++++++++++++++++++++ 9 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 include/linux/hwspinlock/provider.h diff --git a/MAINTAINERS b/MAINTAINERS index 59bccd940fe0..117aa8d118b1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11211,6 +11211,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/gi= t/andersson/remoteproc.git hw F: Documentation/devicetree/bindings/hwlock/ F: Documentation/locking/hwspinlock.rst F: drivers/hwspinlock/ +F: include/linux/hwspinlock/ F: include/linux/hwspinlock.h =20 HARDWARE TRACING FACILITIES diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index adf6fefb382f..6c8a03deb00c 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 41a8812708ef..1be5c9d5091b 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include =20 diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 22cc6f9003df..7fdbb1e58b29 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -4,7 +4,7 @@ * Copyright (c) 2015, Sony Mobile Communications AB */ =20 -#include +#include #include #include #include diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0f4fc622e3cd..46b55d939ea8 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 8eafe1a74b1b..2620d722ee1d 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -6,7 +6,7 @@ =20 #include #include -#include +#include #include #include #include diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index 145d284c5ab5..24e60009fa76 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 4f5b6932712e..4fe1c8831cd1 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -27,34 +27,6 @@ struct hwspinlock_ops; =20 #ifdef CONFIG_HWSPINLOCK =20 -/** - * struct hwspinlock_ops - platform-specific hwspinlock handlers - * - * @trylock: make a single attempt to take the lock. returns 0 on - * failure and true on success. may _not_ sleep. - * @unlock: release the lock. always succeed. may _not_ sleep. - * @bust: optional, platform-specific bust handler, called by hwspinlock - * core to bust a specific lock. - * @relax: optional, platform-specific relax handler, called by hwspinlock - * core while spinning on a lock, between two successive - * invocations of @trylock. may _not_ sleep. - * @init_priv: optional, callback used when registering the hwspinlock dev= ice. - * Its return value will be used to fill the per-lock 'priv' data. - */ -struct hwspinlock_ops { - int (*trylock)(struct hwspinlock *lock); - void (*unlock)(struct hwspinlock *lock); - int (*bust)(struct hwspinlock *lock, unsigned int id); - void (*relax)(struct hwspinlock *lock); - void *(*init_priv)(int local_id, void *init_data); -}; - -void *hwspin_lock_get_priv(struct hwspinlock *hwlock); -struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); -int hwlock_to_id(struct hwspinlock *hwlock); -struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data); -int hwspin_lock_unregister(struct hwspinlock_device *bank); struct hwspinlock *hwspin_lock_request_specific(unsigned int id); int hwspin_lock_free(struct hwspinlock *hwlock); int of_hwspin_lock_get_id(struct device_node *np, int index); @@ -67,18 +39,6 @@ int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned= int id); int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, unsigned int id); -int devm_hwspin_lock_unregister(struct device *dev, - struct hwspinlock_device *bank); -struct hwspinlock_device *devm_hwspin_lock_register(struct device *dev, co= nst struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data); - -static inline int devm_hwspin_lock_register_errno(struct device *dev, - const struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data) -{ - return PTR_ERR_OR_ZERO(devm_hwspin_lock_register(dev, ops, base_id, num_l= ocks, init_data)); -} - #else /* !CONFIG_HWSPINLOCK */ =20 /* @@ -87,10 +47,6 @@ static inline int devm_hwspin_lock_register_errno(struct= device *dev, * code path get compiled away. This way, if CONFIG_HWSPINLOCK is not * required on a given setup, users will still work. * - * The only exception is hwspin_lock_register/hwspin_lock_unregister, with= which - * we _do_ want users to fail (no point in registering hwspinlock instance= s if - * the framework is not available). - * * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-chec= king * users. Others, which care, can still check this with IS_ERR. */ diff --git a/include/linux/hwspinlock/provider.h b/include/linux/hwspinlock= /provider.h new file mode 100644 index 000000000000..73c7b0cb6735 --- /dev/null +++ b/include/linux/hwspinlock/provider.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Hardware spinlock public header for providers + * + * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2026 Sang Engineering + * Copyright (C) 2026 Renesas Solutions Corp. + */ + +#ifndef __LINUX_HWSPINLOCK_PROVIDER_H +#define __LINUX_HWSPINLOCK_PROVIDER_H + +#include + +struct device; +struct hwspinlock; +struct hwspinlock_device; + +/** + * struct hwspinlock_ops - platform-specific hwspinlock handlers + * + * @trylock: make a single attempt to take the lock. returns 0 on + * failure and true on success. may _not_ sleep. + * @unlock: release the lock. always succeed. may _not_ sleep. + * @bust: optional, platform-specific bust handler, called by hwspinlock + * core to bust a specific lock. + * @relax: optional, platform-specific relax handler, called by hwspinlock + * core while spinning on a lock, between two successive + * invocations of @trylock. may _not_ sleep. + * @init_priv: optional, callback used when registering the hwspinlock dev= ice. + * Its return value will be used to fill the per-lock 'priv' data. + */ +struct hwspinlock_ops { + int (*trylock)(struct hwspinlock *lock); + void (*unlock)(struct hwspinlock *lock); + int (*bust)(struct hwspinlock *lock, unsigned int id); + void (*relax)(struct hwspinlock *lock); + void *(*init_priv)(int local_id, void *init_data); +}; + +void *hwspin_lock_get_priv(struct hwspinlock *hwlock); +struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); +int hwlock_to_id(struct hwspinlock *hwlock); +struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data); +int hwspin_lock_unregister(struct hwspinlock_device *bank); + +struct hwspinlock_device *devm_hwspin_lock_register(struct device *dev, co= nst struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data); +int devm_hwspin_lock_unregister(struct device *dev, + struct hwspinlock_device *bank); + +static inline int devm_hwspin_lock_register_errno(struct device *dev, + const struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data) +{ + return PTR_ERR_OR_ZERO(devm_hwspin_lock_register(dev, ops, base_id, num_l= ocks, init_data)); +} + +#endif /* __LINUX_HWSPINLOCK_PROVIDER_H */ --=20 2.51.0