From nobody Thu Apr 9 07:17:15 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 33B5D365A0A for ; Tue, 10 Mar 2026 07:56:03 +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=1773129366; cv=none; b=Yw+Ust5Tj9vv4GySNSRR/9U9qSZZ6qnuhX2x5aEMkPSiSMMxwJKJ7gOI3Q7Y/aNOhwcdo8bhhj9slGjqWNb4dK0lZPnfxVPIMI7YfB1eCYfQfR7rtmdBQ+c/Crl+DLaKM7EStzqmFcJeKbzM9PC470LEfwY/JgnWCdRLObFsYUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129366; c=relaxed/simple; bh=v5e/DxyGISXuWGTly0K6hLPabucxx/f/+ZMbtBjb6TY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YTpjgVOn84ZkiFMcMEZBQZnIJ3W+lZb0OBDmgkHPY6IkaJJWNTePJEnYL6xZUchD6hD9ZdKgFyfmmaJeL7ZYEyQRhWv5WGTD98D6uq+vgghal8z18VppD7qA3odYWJyVwOd5A8oPQs5U3eH/WwBoVm8CNaKtpjm2oxXiIRvv5FQ= 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=Jv+wtlXL; 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="Jv+wtlXL" 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=giHulHp/dlRiUxdh2pIugbOCY78tk9Tnbt/aIN3rJPw=; b=Jv+wtl XLmxUDPdR3zpant6xZesfcEUpOcT7Ei2lzYSDe6rkBbEU/VodorU1B+aOyD+ob4z Nll9cyPpL/4Xdv1pLIvlvVFDMxJ98V/KWA1jrpKPiu64mbEr5/DtMYLvugy8gMsL rjDh0vdl7ZIddov9mnIuR27rqQJpbLfOL60Qo3Ic43TPwvIJk5SOUtSfV1Gy4AVS +eQ7WnyxRMAZ/CIXTu/LMMoNT9Mk4NzCNuZ6pJhgeClmugUXgx1RUCmmndUdG+s5 rdvUJBvnauJy2ING2taBlvFJJCVOskTNiifgcJaaraCtZDMmea7dk+r5sJRvLJY/ wqMKs76Oxtu7UYIA== Received: (qmail 3112571 invoked from network); 10 Mar 2026 08:55:48 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:48 +0100 X-UD-Smtp-Session: l3s3148p1@A3Lv2KZMopAujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Linus Walleij , Andy Shevchenko , Bjorn Andersson , Baolin Wang , linux-remoteproc@vger.kernel.org Subject: [PATCH v4 01/15] hwspinlock: u8500: delete driver Date: Tue, 10 Mar 2026 08:55:16 +0100 Message-ID: <20260310075539.11701-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" The U8500 platform was converted to DT around 2013 and is DT only meanwhile. This driver has never been converted to a DT driver, so it clearly hasn't been used since then. To ease upcoming refactoring in the hwspinlock subsystem, remove this obsolete driver. Signed-off-by: Wolfram Sang Reviewed-by: Linus Walleij Acked-by: Andy Shevchenko --- MAINTAINERS | 1 - drivers/hwspinlock/Kconfig | 10 --- drivers/hwspinlock/Makefile | 1 - drivers/hwspinlock/u8500_hsem.c | 155 -------------------------------- 4 files changed, 167 deletions(-) delete mode 100644 drivers/hwspinlock/u8500_hsem.c diff --git a/MAINTAINERS b/MAINTAINERS index 77fdfcb55f06..5e5282c62d2e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3155,7 +3155,6 @@ F: drivers/clocksource/clksrc-dbx500-prcmu.c F: drivers/dma/ste_dma40* F: drivers/pmdomain/st/ste-ux500-pm-domain.c F: drivers/gpio/gpio-nomadik.c -F: drivers/hwspinlock/u8500_hsem.c F: drivers/i2c/busses/i2c-nomadik.c F: drivers/iio/adc/ab8500-gpadc.c F: drivers/mfd/ab8500* diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index 3874d15b0e9b..d84e00084ee2 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig @@ -53,14 +53,4 @@ config HWSPINLOCK_SUN6I =20 If unsure, say N. =20 -config HSEM_U8500 - tristate "STE Hardware Semaphore functionality" - depends on ARCH_U8500 || COMPILE_TEST - help - Say y here to support the STE Hardware Semaphore functionality, which - provides a synchronisation mechanism for the various processor on the - SoC. - - If unsure, say N. - endif # HWSPINLOCK diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile index a0f16c9aaa82..3a740805949d 100644 --- a/drivers/hwspinlock/Makefile +++ b/drivers/hwspinlock/Makefile @@ -9,4 +9,3 @@ obj-$(CONFIG_HWSPINLOCK_QCOM) +=3D qcom_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) +=3D sprd_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_STM32) +=3D stm32_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SUN6I) +=3D sun6i_hwspinlock.o -obj-$(CONFIG_HSEM_U8500) +=3D u8500_hsem.o diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hse= m.c deleted file mode 100644 index 5a2d8c3e0d80..000000000000 --- a/drivers/hwspinlock/u8500_hsem.c +++ /dev/null @@ -1,155 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * u8500 HWSEM driver - * - * Copyright (C) 2010-2011 ST-Ericsson - * - * Implements u8500 semaphore handling for protocol 1, no interrupts. - * - * Author: Mathieu Poirier - * Heavily borrowed from the work of : - * Simon Que - * Hari Kanigeri - * Ohad Ben-Cohen - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "hwspinlock_internal.h" - -/* - * Implementation of STE's HSem protocol 1 without interrutps. - * The only masterID we allow is '0x01' to force people to use - * HSems for synchronisation between processors rather than processes - * on the ARM core. - */ - -#define U8500_MAX_SEMAPHORE 32 /* a total of 32 semaphore */ -#define RESET_SEMAPHORE (0) /* free */ - -/* - * CPU ID for master running u8500 kernel. - * Hswpinlocks should only be used to synchonise operations - * between the Cortex A9 core and the other CPUs. Hence - * forcing the masterID to a preset value. - */ -#define HSEM_MASTER_ID 0x01 - -#define HSEM_REGISTER_OFFSET 0x08 - -#define HSEM_CTRL_REG 0x00 -#define HSEM_ICRALL 0x90 -#define HSEM_PROTOCOL_1 0x01 - -static int u8500_hsem_trylock(struct hwspinlock *lock) -{ - void __iomem *lock_addr =3D lock->priv; - - writel(HSEM_MASTER_ID, lock_addr); - - /* get only first 4 bit and compare to masterID. - * if equal, we have the semaphore, otherwise - * someone else has it. - */ - return (HSEM_MASTER_ID =3D=3D (0x0F & readl(lock_addr))); -} - -static void u8500_hsem_unlock(struct hwspinlock *lock) -{ - void __iomem *lock_addr =3D lock->priv; - - /* release the lock by writing 0 to it */ - writel(RESET_SEMAPHORE, lock_addr); -} - -/* - * u8500: what value is recommended here ? - */ -static void u8500_hsem_relax(struct hwspinlock *lock) -{ - ndelay(50); -} - -static const struct hwspinlock_ops u8500_hwspinlock_ops =3D { - .trylock =3D u8500_hsem_trylock, - .unlock =3D u8500_hsem_unlock, - .relax =3D u8500_hsem_relax, -}; - -static int u8500_hsem_probe(struct platform_device *pdev) -{ - struct hwspinlock_pdata *pdata =3D pdev->dev.platform_data; - struct hwspinlock_device *bank; - struct hwspinlock *hwlock; - void __iomem *io_base; - int i, num_locks =3D U8500_MAX_SEMAPHORE; - ulong val; - - if (!pdata) - return -ENODEV; - - io_base =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(io_base)) - return PTR_ERR(io_base); - - /* make sure protocol 1 is selected */ - val =3D readl(io_base + HSEM_CTRL_REG); - writel((val & ~HSEM_PROTOCOL_1), io_base + HSEM_CTRL_REG); - - /* clear all interrupts */ - writel(0xFFFF, io_base + HSEM_ICRALL); - - bank =3D devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks), - GFP_KERNEL); - if (!bank) - return -ENOMEM; - - platform_set_drvdata(pdev, bank); - - for (i =3D 0, hwlock =3D &bank->lock[0]; i < num_locks; i++, hwlock++) - hwlock->priv =3D io_base + HSEM_REGISTER_OFFSET + sizeof(u32) * i; - - return devm_hwspin_lock_register(&pdev->dev, bank, - &u8500_hwspinlock_ops, - pdata->base_id, num_locks); -} - -static void u8500_hsem_remove(struct platform_device *pdev) -{ - struct hwspinlock_device *bank =3D platform_get_drvdata(pdev); - void __iomem *io_base =3D bank->lock[0].priv - HSEM_REGISTER_OFFSET; - - /* clear all interrupts */ - writel(0xFFFF, io_base + HSEM_ICRALL); -} - -static struct platform_driver u8500_hsem_driver =3D { - .probe =3D u8500_hsem_probe, - .remove =3D u8500_hsem_remove, - .driver =3D { - .name =3D "u8500_hsem", - }, -}; - -static int __init u8500_hsem_init(void) -{ - return platform_driver_register(&u8500_hsem_driver); -} -/* board init code might need to reserve hwspinlocks for predefined purpos= es */ -postcore_initcall(u8500_hsem_init); - -static void __exit u8500_hsem_exit(void) -{ - platform_driver_unregister(&u8500_hsem_driver); -} -module_exit(u8500_hsem_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Hardware Spinlock driver for u8500"); -MODULE_AUTHOR("Mathieu Poirier "); --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 3BB99364959 for ; Tue, 10 Mar 2026 07:56:04 +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=1773129369; cv=none; b=X5WVRzMj8aEmaJnxkckxjvlz3lVkDTMZfIIg1Ggnnv3LBh0K+/00k195zU/o0tgur5vREOwlOtUiKpQYRfImSckKuJCw7llOtOdsML7g3yatKuOxSyKCD1R9WP7ovhD/iPehNRaZylyv55sJNezITrUuLr4heY/c/IPwFduPyeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129369; c=relaxed/simple; bh=NzPexpQeiqadjqeObMLphMshtxAmoA9bstBE15Mzb8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fC5YbCY5syUeFowQ1M7vl2+9OPgcacTzsOkSl1VWJrNRrhS4YOjQ4CJwkPCSXF6Pph34x/k2lrxO+SiNHaFbFHfVCBuXdjEtdg2IHtXI+bNa5IdXeLwOXkOSdytxRAS8FVTO0CFykb73aANbVKccXnttmdlOtrGr6NZ9aNas5RI= 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=Y1ZkUaoL; 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="Y1ZkUaoL" 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=0O02edZSieAasjS+spevR8oO5F5Dn3qakXZ4rFeyaVM=; b=Y1ZkUa oLiS4+kvBtrV91cZBWD523zEBhOIaUDO/eR/Y9+mg5b8gyYtKgtccYXdIXhLJwTJ VtQgSWHDcTi64dTx8Ecu6Fwx60zTWG1TRXLmRUBUXH/UTp75lFLvBugxRpXMTvLt hEyNz2MrnWIE7WcWMcexEGaMOC0bAhVifkoECCGgaQRWp/1UQLHP7RUWF0vWlYRV 7OUvT31Xm7nxL5eNupx9T95pVxp1eyEdWSD8jLLt7YyppLnOkNGzm8WO9uGQByj7 8qpFpab7DmNtfBtNBCAHm13PVH0RdyFeLu68wesURX4qikmu133irEDMJbcHDkC4 SNHfG93BNlF76z4Q== Received: (qmail 3112606 invoked from network); 10 Mar 2026 08:55:49 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:49 +0100 X-UD-Smtp-Session: l3s3148p1@6uj92KZMppAujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Linus Walleij , Andy Shevchenko Subject: [PATCH v4 02/15] hwspinlock: remove now unused pdata from header file Date: Tue, 10 Mar 2026 08:55:17 +0100 Message-ID: <20260310075539.11701-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" The last user turned out to be obsolete and was removed. Remove the unused struct now, too. Signed-off-by: Wolfram Sang Reviewed-by: Linus Walleij Acked-by: Andy Shevchenko --- include/linux/hwspinlock.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index f35b42e8c5de..74b91244fe0e 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -25,34 +25,6 @@ struct hwspinlock; struct hwspinlock_device; struct hwspinlock_ops; =20 -/** - * struct hwspinlock_pdata - platform data for hwspinlock drivers - * @base_id: base id for this hwspinlock device - * - * hwspinlock devices provide system-wide hardware locks that are used - * by remote processors that have no other way to achieve synchronization. - * - * To achieve that, each physical lock must have a system-wide id number - * that is agreed upon, otherwise remote processors can't possibly assume - * they're using the same hardware lock. - * - * Usually boards have a single hwspinlock device, which provides several - * hwspinlocks, and in this case, they can be trivially numbered 0 to - * (num-of-locks - 1). - * - * In case boards have several hwspinlocks devices, a different base id - * should be used for each hwspinlock device (they can't all use 0 as - * a starting id!). - * - * This platform data structure should be used to provide the base id - * for each device (which is trivially 0 when only a single hwspinlock - * device exists). It can be shared between different platforms, hence - * its location. - */ -struct hwspinlock_pdata { - int base_id; -}; - #ifdef CONFIG_HWSPINLOCK =20 int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 26F14364954 for ; Tue, 10 Mar 2026 07:56:05 +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=1773129367; cv=none; b=oeYFnlBzhWYbsr646th5TBU4qr6RGMSgot6YT0BRA4G3yLTafnUYpnjYHazuYifQO/sm5nwl9AUCB3lZ9xbLUhHLKKhIfnF4SNfyuh8z6L4+tXCn16u04gBQLblw7AX+n9iZx+RPxwrINlsgfJiRGdf3FiB0jX7ZakHrvCw85Vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129367; c=relaxed/simple; bh=ie25SIPrCyJJGxZvKcNfxyNV67pa8xcffLXnNnSW+7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUjZfH6xhWXWZ86HqJwfcTfG4J+QSMKZ6EfytaS8+YbVtlLkWko6JpfsdCBTNJb5e1VQKydw8SNPQRfaEPYYRSZvX4tWngfZ7A9FSK0FJstSU2O4hl22GNybMeUfuCPD6Tu4CYy9KtY45rUiJCx6jm+EAXpIUPlKbbFzjzo61pY= 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=jSnsmLqY; 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="jSnsmLqY" 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=Ww4nYucVcxYHOiIbxAnzL68uueWTV/h2bRDqOLnsme0=; b=jSnsmL qYMbsKvWcgJkDyGTS/MKc6CavAjUlEjTs7Jc1fq4TKz63lF18ap7o8k4SN8PXbyS AHL8q+PdihoH4HtcqxO1Zy9d6w3gs2vfEITGwDJ18954tz/bYbrqQpz/k5n1K+Nt vqA+pg0pr/pfiZ2fyH5RHWpZiNLfI2uD5UnE6EKKWdtKakY3rKSVsxEeWvmAX4PB +B3SdKbjJvBo2xJWzM61toM3yRYMNng1r3e81RTJbF7WjE0V86GHf4eX9TX5YlDv GFNVWeKy9ahgzUkxhBCCWgdgtJ2nAGza2RYfakik/k4ZYVxFHNsMPQILQ5qr5KgQ co7yFG/J9Xj4yChg== Received: (qmail 3112619 invoked from network); 10 Mar 2026 08:55:50 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:50 +0100 X-UD-Smtp-Session: l3s3148p1@Bz4S2aZMrpAujntP 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 v4 03/15] hwspinlock: add helpers to retrieve core data Date: Tue, 10 Mar 2026 08:55:18 +0100 Message-ID: <20260310075539.11701-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" This is a first step to hide internal core structs from hwspinlock providers. It adds helper functions to retrieve the data needed by them. Because all users are only within the hwspinlock subsystem and the change there is trivial, conversion is included in this patch as well. Signed-off-by: Wolfram Sang Acked-by: Chen-Yu Tsai # sun6i --- drivers/hwspinlock/hwspinlock_core.c | 12 ++++++++++++ drivers/hwspinlock/omap_hwspinlock.c | 4 ++-- drivers/hwspinlock/qcom_hwspinlock.c | 11 ++++++----- drivers/hwspinlock/sprd_hwspinlock.c | 6 +++--- drivers/hwspinlock/stm32_hwspinlock.c | 4 ++-- drivers/hwspinlock/sun6i_hwspinlock.c | 4 ++-- include/linux/hwspinlock.h | 2 ++ 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index cc8e952a6772..2c9eceba7fe8 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -888,5 +888,17 @@ struct hwspinlock *devm_hwspin_lock_request_specific(s= truct device *dev, } EXPORT_SYMBOL_GPL(devm_hwspin_lock_request_specific); =20 +void *hwspin_lock_get_priv(struct hwspinlock *hwlock) +{ + return hwlock->priv; +} +EXPORT_SYMBOL_GPL(hwspin_lock_get_priv); + +struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock) +{ + return hwlock->bank->dev; +} +EXPORT_SYMBOL_GPL(hwspin_lock_get_dev); + MODULE_DESCRIPTION("Hardware spinlock interface"); MODULE_AUTHOR("Ohad Ben-Cohen "); diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 1832e0c3af6b..5bf0061d3fd6 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -37,7 +37,7 @@ =20 static int omap_hwspinlock_trylock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 /* attempt to acquire the lock by reading its value */ return (SPINLOCK_NOTTAKEN =3D=3D readl(lock_addr)); @@ -45,7 +45,7 @@ static int omap_hwspinlock_trylock(struct hwspinlock *loc= k) =20 static void omap_hwspinlock_unlock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 /* release the lock by writing 0 to it */ writel(SPINLOCK_NOTTAKEN, lock_addr); diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 0390979fd765..7ff89c3e8c6b 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -27,7 +27,7 @@ struct qcom_hwspinlock_of_data { =20 static int qcom_hwspinlock_trylock(struct hwspinlock *lock) { - struct regmap_field *field =3D lock->priv; + struct regmap_field *field =3D hwspin_lock_get_priv(lock); u32 lock_owner; int ret; =20 @@ -44,7 +44,7 @@ static int qcom_hwspinlock_trylock(struct hwspinlock *loc= k) =20 static void qcom_hwspinlock_unlock(struct hwspinlock *lock) { - struct regmap_field *field =3D lock->priv; + struct regmap_field *field =3D hwspin_lock_get_priv(lock); u32 lock_owner; int ret; =20 @@ -66,13 +66,14 @@ static void qcom_hwspinlock_unlock(struct hwspinlock *l= ock) =20 static int qcom_hwspinlock_bust(struct hwspinlock *lock, unsigned int id) { - struct regmap_field *field =3D lock->priv; + struct regmap_field *field =3D hwspin_lock_get_priv(lock); + struct device *dev =3D hwspin_lock_get_dev(lock); u32 owner; int ret; =20 ret =3D regmap_field_read(field, &owner); if (ret) { - dev_err(lock->bank->dev, "unable to query spinlock owner\n"); + dev_err(dev, "unable to query spinlock owner\n"); return ret; } =20 @@ -81,7 +82,7 @@ static int qcom_hwspinlock_bust(struct hwspinlock *lock, = unsigned int id) =20 ret =3D regmap_field_write(field, 0); if (ret) { - dev_err(lock->bank->dev, "failed to bust spinlock\n"); + dev_err(dev, "failed to bust spinlock\n"); return ret; } =20 diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 22e2ffb91743..0d08efbdfb07 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -40,8 +40,8 @@ struct sprd_hwspinlock_dev { static int sprd_hwspinlock_trylock(struct hwspinlock *lock) { struct sprd_hwspinlock_dev *sprd_hwlock =3D - dev_get_drvdata(lock->bank->dev); - void __iomem *addr =3D lock->priv; + dev_get_drvdata(hwspin_lock_get_dev(lock)); + void __iomem *addr =3D hwspin_lock_get_priv(lock); int user_id, lock_id; =20 if (!readl(addr)) @@ -59,7 +59,7 @@ static int sprd_hwspinlock_trylock(struct hwspinlock *loc= k) /* unlock the hardware spinlock */ static void sprd_hwspinlock_unlock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 writel(HWSPINLOCK_NOTTAKEN, lock_addr); } diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index bb5c7e5f7a80..1d75dc03f4ad 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -27,7 +27,7 @@ struct stm32_hwspinlock { =20 static int stm32_hwspinlock_trylock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); u32 status; =20 writel(STM32_MUTEX_LOCK_BIT | STM32_MUTEX_COREID, lock_addr); @@ -38,7 +38,7 @@ static int stm32_hwspinlock_trylock(struct hwspinlock *lo= ck) =20 static void stm32_hwspinlock_unlock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 writel(STM32_MUTEX_COREID, lock_addr); } diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index c2d314588046..8ff81cb5880a 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -62,14 +62,14 @@ static void sun6i_hwspinlock_debugfs_init(struct sun6i_= hwspinlock_data *priv) =20 static int sun6i_hwspinlock_trylock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 return (readl(lock_addr) =3D=3D SPINLOCK_NOTTAKEN); } =20 static void sun6i_hwspinlock_unlock(struct hwspinlock *lock) { - void __iomem *lock_addr =3D lock->priv; + void __iomem *lock_addr =3D hwspin_lock_get_priv(lock); =20 writel(SPINLOCK_NOTTAKEN, lock_addr); } diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 74b91244fe0e..dffa1dff7289 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -27,6 +27,8 @@ struct hwspinlock_ops; =20 #ifdef CONFIG_HWSPINLOCK =20 +void *hwspin_lock_get_priv(struct hwspinlock *hwlock); +struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, const struct hwspinlock_ops *ops, int base_id, int num_locks); int hwspin_lock_unregister(struct hwspinlock_device *bank); --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 2DACA364E82 for ; Tue, 10 Mar 2026 07:56:10 +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=1773129373; cv=none; b=SYAxD4woOkhiHmNqO1GR8xu967LHdcMIFlXKXhldHJ8//74cloGkF9jQ3enfB1lDbU05+Gr7B+JatnEtGOZUBi2VVD6EoUiY4zxUvMTAM8ubSIEPIDaS0tsNk266k/eF/Pj3vqsQUFFp6mw4sFm+Ksxxz5vXWiCzuaQzZRAgWxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129373; c=relaxed/simple; bh=QdAPQ/wgPjYWXA5UouD20DLZ3JnNeWjKMNF0ZnmgYT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BSN22MF5ElfsW/29dSD68NcWcqoRhzh+FuK1GvXGVhaUH0MwfvFkyqn33FFFUl6RKawVODgq9UhMSMVsrWCLMm4ND/j2ouvXKy4y79RVbNw6fpCzg5Robp/jHhAPqzq4XX5lnYZmaJawRi6UrhS6t+3/d9JSUWD7Yawz0RGlWNU= 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=WUxZQC63; 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="WUxZQC63" 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=DrYbAeF/DBAGfsthsqCRbLaGggzDcpjeVSk1HFVUxu0=; b=WUxZQC 63ndJu3cy8ghzOVpHbL/TxVuLnSZDeMa3nmXddnpEcDPGzGWJvTDW5+YbDTI8OhG mvBJy3nfTXwUWt26h98bBW2G/974SxMnWVBQpeMkbkIB0QLwgGfqb/w6fG9+CkUY fNav8drcTE8XHbiIWGi5zj2+LkXzuYK8TVYlJDGl8vRmbfJxa913Qp0KBgtQGqZQ hQvEtlfXIWk/M9a8Z9jq2peeXsXro5pUdeTWUX4PWVTBLhTdE9csqC1+ZPYbC9gA XXIMCpogydoswZ8Ky5VXdjyuUkxGINAX5ZlGTCzPSUzxBBKQj7wsPdsv9FyI+big 24j9SMtKQ/rJ+WPQ== Received: (qmail 3112640 invoked from network); 10 Mar 2026 08:55:52 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:52 +0100 X-UD-Smtp-Session: l3s3148p1@B5Yn2aZMtpAujntP 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 v4 04/15] hwspinlock: add callback to fill private data of a hwspinlock Date: Tue, 10 Mar 2026 08:55:19 +0100 Message-ID: <20260310075539.11701-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" To hide internal core structures from providers, a callback is added to the ops which allows to set the 'priv' field of a hwspinlock. It is called when a hwspinlock device is registered and, thus, iterated over all locks. The register-functions are also extended to pass a data pointer to this callback, so it can do necessary calculations for the priv field of each hwspinlock. Providers are added only an empty placeholder and are converted separately because these changes need dedicated reviews. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 19 +++++++++++++++---- drivers/hwspinlock/hwspinlock_internal.h | 19 +++++++++++-------- 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 | 4 ++-- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index 2c9eceba7fe8..afe1e7ce2829 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -507,6 +507,7 @@ static struct hwspinlock *hwspin_lock_unregister_single= (unsigned int id) * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device + * @init_data: additional data passed on to the init_priv callback * * This function should be called from the underlying platform-specific * implementation, to register a new hwspinlock device instance. @@ -516,10 +517,11 @@ static struct hwspinlock *hwspin_lock_unregister_sing= le(unsigned int id) * Returns: %0 on success, or an appropriate error code on failure */ int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks) + const struct hwspinlock_ops *ops, int base_id, int num_locks, + void *init_data) { struct hwspinlock *hwlock; - int ret =3D 0, i; + int ret, i; =20 if (!bank || !ops || !dev || !num_locks || !ops->trylock || !ops->unlock) { @@ -538,6 +540,14 @@ int hwspin_lock_register(struct hwspinlock_device *ban= k, struct device *dev, spin_lock_init(&hwlock->lock); hwlock->bank =3D bank; =20 + if (ops->init_priv) { + hwlock->priv =3D ops->init_priv(i, init_data); + if (IS_ERR(hwlock->priv)) { + ret =3D PTR_ERR(hwlock->priv); + goto reg_failed; + } + } + ret =3D hwspin_lock_register_single(hwlock, base_id + i); if (ret) goto reg_failed; @@ -633,6 +643,7 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device + * @init_data: additional data passed on to the init_priv callback * * This function should be called from the underlying platform-specific * implementation, to register a new hwspinlock device instance. @@ -644,7 +655,7 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); int devm_hwspin_lock_register(struct device *dev, struct hwspinlock_device *bank, const struct hwspinlock_ops *ops, - int base_id, int num_locks) + int base_id, int num_locks, void *init_data) { struct hwspinlock_device **ptr; int ret; @@ -653,7 +664,7 @@ int devm_hwspin_lock_register(struct device *dev, if (!ptr) return -ENOMEM; =20 - ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks); + ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks, init_dat= a); if (!ret) { *ptr =3D bank; devres_add(dev, ptr); diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/= hwspinlock_internal.h index f298fc0ee5ad..3c835d96bf86 100644 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ b/drivers/hwspinlock/hwspinlock_internal.h @@ -18,20 +18,23 @@ 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 hwspinlo= ck - * core while spinning on a lock, between two successive - * invocations of @trylock. may _not_ sleep. + * @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); }; =20 /** diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 5bf0061d3fd6..adff502bcbc4 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -120,7 +120,7 @@ static int omap_hwspinlock_probe(struct platform_device= *pdev) bank->lock[i].priv =3D io_base + LOCK_BASE_OFFSET + sizeof(u32) * i; =20 return devm_hwspin_lock_register(&pdev->dev, bank, &omap_hwspinlock_ops, - base_id, num_locks); + base_id, num_locks, NULL); } =20 static const struct of_device_id omap_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 7ff89c3e8c6b..7960a4972eab 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -236,7 +236,7 @@ static int qcom_hwspinlock_probe(struct platform_device= *pdev) } =20 return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops, - 0, QCOM_MUTEX_NUM_LOCKS); + 0, QCOM_MUTEX_NUM_LOCKS, NULL); } =20 static struct platform_driver qcom_hwspinlock_driver =3D { diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0d08efbdfb07..0b91bdd4303d 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -132,7 +132,7 @@ static int sprd_hwspinlock_probe(struct platform_device= *pdev) =20 return devm_hwspin_lock_register(&pdev->dev, &sprd_hwlock->bank, &sprd_hwspinlock_ops, 0, - SPRD_HWLOCKS_NUM); + SPRD_HWLOCKS_NUM, NULL); } =20 static const struct of_device_id sprd_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 1d75dc03f4ad..51e8e533ac31 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -110,7 +110,7 @@ static int stm32_hwspinlock_probe(struct platform_devic= e *pdev) hw->bank.lock[i].priv =3D io_base + i * sizeof(u32); =20 ret =3D devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops, - 0, STM32_MUTEX_NUM_LOCKS); + 0, STM32_MUTEX_NUM_LOCKS, NULL); =20 if (ret) dev_err(dev, "Failed to register hwspinlock\n"); diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index 8ff81cb5880a..a0c76bba3f05 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -180,7 +180,7 @@ static int sun6i_hwspinlock_probe(struct platform_devic= e *pdev) platform_set_drvdata(pdev, priv); =20 return devm_hwspin_lock_register(&pdev->dev, priv->bank, &sun6i_hwspinloc= k_ops, - SPINLOCK_BASE_ID, priv->nlocks); + SPINLOCK_BASE_ID, priv->nlocks, NULL); =20 bank_fail: clk_disable_unprepare(priv->ahb_clk); diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index dffa1dff7289..094a6d0d39d6 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -30,7 +30,7 @@ struct hwspinlock_ops; void *hwspin_lock_get_priv(struct hwspinlock *hwlock); struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks); + const struct 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); @@ -49,7 +49,7 @@ int devm_hwspin_lock_unregister(struct device *dev, int devm_hwspin_lock_register(struct device *dev, struct hwspinlock_device *bank, const struct hwspinlock_ops *ops, - int base_id, int num_locks); + int base_id, int num_locks, void *init_data); =20 #else /* !CONFIG_HWSPINLOCK */ =20 --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 B41E336605E for ; Tue, 10 Mar 2026 07:56:08 +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=1773129370; cv=none; b=chCIs4F09E3dOrN7TDfFnmKvSeNpRrIlHEF6NzDmiVKPu0XlKFWe9fFJdqSeLbunnPLwyynsmr6ySrKHW/y31ph/QBvL6ti8ngGdxoeRfnkK7mwRUk3l4+l0yWd5s6eMQxvBdKTr1jhD38R+PnH+xXCGzXQw0/kBAcPXEB4W+PA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129370; c=relaxed/simple; bh=nX/JNUQsoIsZPgc0eQr9bDwyuSjW/BHNg7TEpnt7i0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TRDzBzSHMVprKNwNcz934emMMGe0BbzKgiPV+o5E2WIm9c+5gwPAmVveRTU0DlFUrpd2Cxo1yXbjNxWlJ4P6eYFkZHKzUDcO+Nq0gbqEdexDyxidjt8Il4ZTl++6Tk7KXCUBtQNm0DDLKaIKlNaKCn9WPXOiG/q8eHvkvIlufFs= 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=ScLpMk9Q; 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="ScLpMk9Q" 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=m6b17guF4mqY7MErq38twR8NUyAOvnb/eht594gA9L4=; b=ScLpMk 9Q7n5ID/L/JRa1+hzrXUvaaiGAaQO9dgi/mIlkNt63SflDot19QzhM55nZpIaRJR Xxw7dLSTBOZhfKOJ4qEeR9xcbrHqX5HjPnzWUf0zYhJScyInYTcjtv0jaKTHhjaY JPgzeFOYEUUOxwOcQ6iLST/GT1aBOn1C9JZRNbH290yXXNxUl3sgAwSKdfkCIwjL dnz6ZhMKBGCHsHBSCC+J37mt8FlMUlmwQEw7/ZQ24IaU7m2SAEmiR2pCwBv+NX+y iCDZlHn1pBz91MmQieqNPwFvWpCYw5ncZyfjURlGtBVyelScfpXy/PfSZpoRq6k5 NivpAtH8tcMGyFOQ== Received: (qmail 3112659 invoked from network); 10 Mar 2026 08:55:52 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:52 +0100 X-UD-Smtp-Session: l3s3148p1@CQky2aZMwJAujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org Subject: [PATCH v4 05/15] hwspinlock: omap: use new callback to initialize hwspinlock priv Date: Tue, 10 Mar 2026 08:55:20 +0100 Message-ID: <20260310075539.11701-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Apply the new helper to avoid using internal structures from the core. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/omap_hwspinlock.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index adff502bcbc4..868b93131796 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -66,10 +66,16 @@ static void omap_hwspinlock_relax(struct hwspinlock *lo= ck) ndelay(50); } =20 +static void *omap_hwspinlock_init_priv(int local_id, void *init_data) +{ + return init_data + sizeof(u32) * local_id; +} + static const struct hwspinlock_ops omap_hwspinlock_ops =3D { .trylock =3D omap_hwspinlock_trylock, .unlock =3D omap_hwspinlock_unlock, .relax =3D omap_hwspinlock_relax, + .init_priv =3D omap_hwspinlock_init_priv, }; =20 static int omap_hwspinlock_probe(struct platform_device *pdev) @@ -116,11 +122,8 @@ static int omap_hwspinlock_probe(struct platform_devic= e *pdev) if (!bank) return -ENOMEM; =20 - for (i =3D 0; i < num_locks; i++) - bank->lock[i].priv =3D io_base + LOCK_BASE_OFFSET + sizeof(u32) * i; - return devm_hwspin_lock_register(&pdev->dev, bank, &omap_hwspinlock_ops, - base_id, num_locks, NULL); + base_id, num_locks, io_base + LOCK_BASE_OFFSET); } =20 static const struct of_device_id omap_hwspinlock_of_match[] =3D { --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 83C79364EAE for ; Tue, 10 Mar 2026 07:56:12 +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=1773129380; cv=none; b=QqMOqv3pJ3BNzk6mTqzKnf0h50dQnBu9fGIsJZawMajl11N+rYMt91eVt+sViJXo4xtlpxV+6OJIgAfBQUeZ8Swkmum+t9NppC3nW6Eb1V1//2619Fk4s6FE4Ix+dsok9EymfY4ehJiAwlCBIxix2bBGYqlprAPzrrWxrfXZNq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129380; c=relaxed/simple; bh=pGcfVVvTw1ZWJSV+BA7Cqfi35R8O7VoHAutQcsJ0fqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eski8Cvc+aipKzSCUAsMB57OEEJ3DOrod+/bNSc75jxdQmxpicriPofeFLKo9s/CihE7ZpDAGPfqyyOIKk77KkxdDiQse9NKhMTE2PzyErlwkwyA0IUNXjd+KffhfmLuJXLkWhf+GG6nBigu3e4oJFhmRv6s+yNTQ2Cjnb320Kg= 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=YNC9YuDH; 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="YNC9YuDH" 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=7vMrLv9qF9Z71L0B1gC3rLo8m3rNp4D4vQ0xv92urq4=; b=YNC9Yu DHC3vdwaWt2Df0cLQz6Ae1g+4lNqNEgGP1+fNns87u8cQatlnO1vaa0Mes8ZFQH7 PJAXsFjtx4+TrgxY4ZbzG1bP6aXInekXTMPeaGSU1zHEO1NPpj2iBt2nhEmU7WqE hTaNU1sA6tgyZnZpVVtIKDGHSDk3I/t8h14iqr4+bIezwHrQgg8UZOlfy48+bCKt 9tVD0f1TGWr07nvUoX9gM78YMNN0ykgiCZxT345ErLlw/0ZiAjPuBgb1ZDDUstE0 k27fSpeE7vuCsb+bE+Q0OKi/o0tq9gy660pnQVlMaM1a92g4v6p+i1TNR6vZJdad zNMR4SULu68i5DWA== Received: (qmail 3112682 invoked from network); 10 Mar 2026 08:55:53 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:53 +0100 X-UD-Smtp-Session: l3s3148p1@3Qs92aZMxpAujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Konrad Dybcio , Bjorn Andersson , Baolin Wang , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org Subject: [PATCH v4 06/15] hwspinlock: qcom: use new callback to initialize hwspinlock priv Date: Tue, 10 Mar 2026 08:55:21 +0100 Message-ID: <20260310075539.11701-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Apply the new helper to avoid using internal structures from the core. Remove superfluous setting of drvdata while here. Signed-off-by: Wolfram Sang Acked-by: Konrad Dybcio --- drivers/hwspinlock/qcom_hwspinlock.c | 45 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 7960a4972eab..73b280988109 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -25,6 +25,13 @@ struct qcom_hwspinlock_of_data { const struct regmap_config *regmap_config; }; =20 +struct qcom_hwspinlock_priv_init_data { + struct device *dev; + struct regmap *regmap; + u32 base; + u32 stride; +}; + static int qcom_hwspinlock_trylock(struct hwspinlock *lock) { struct regmap_field *field =3D hwspin_lock_get_priv(lock); @@ -89,10 +96,23 @@ static int qcom_hwspinlock_bust(struct hwspinlock *lock= , unsigned int id) return 0; } =20 +static void *qcom_hwspinlock_init_priv(int local_id, void *init_data) +{ + struct qcom_hwspinlock_priv_init_data *init =3D init_data; + struct reg_field field; + + field.reg =3D init->base + local_id * init->stride; + field.lsb =3D 0; + field.msb =3D 31; + + return devm_regmap_field_alloc(init->dev, init->regmap, field); +} + static const struct hwspinlock_ops qcom_hwspinlock_ops =3D { .trylock =3D qcom_hwspinlock_trylock, .unlock =3D qcom_hwspinlock_unlock, .bust =3D qcom_hwspinlock_bust, + .init_priv =3D qcom_hwspinlock_init_priv, }; =20 static const struct regmap_config sfpb_mutex_config =3D { @@ -202,17 +222,14 @@ static struct regmap *qcom_hwspinlock_probe_mmio(stru= ct platform_device *pdev, =20 static int qcom_hwspinlock_probe(struct platform_device *pdev) { + struct qcom_hwspinlock_priv_init_data init; struct hwspinlock_device *bank; - struct reg_field field; struct regmap *regmap; size_t array_size; - u32 stride; - u32 base; - int i; =20 - regmap =3D qcom_hwspinlock_probe_syscon(pdev, &base, &stride); + regmap =3D qcom_hwspinlock_probe_syscon(pdev, &init.base, &init.stride); if (IS_ERR(regmap) && PTR_ERR(regmap) =3D=3D -ENODEV) - regmap =3D qcom_hwspinlock_probe_mmio(pdev, &base, &stride); + regmap =3D qcom_hwspinlock_probe_mmio(pdev, &init.base, &init.stride); =20 if (IS_ERR(regmap)) return PTR_ERR(regmap); @@ -222,21 +239,11 @@ static int qcom_hwspinlock_probe(struct platform_devi= ce *pdev) if (!bank) return -ENOMEM; =20 - platform_set_drvdata(pdev, bank); - - for (i =3D 0; i < QCOM_MUTEX_NUM_LOCKS; i++) { - field.reg =3D base + i * stride; - field.lsb =3D 0; - field.msb =3D 31; - - bank->lock[i].priv =3D devm_regmap_field_alloc(&pdev->dev, - regmap, field); - if (IS_ERR(bank->lock[i].priv)) - return PTR_ERR(bank->lock[i].priv); - } + init.dev =3D &pdev->dev; + init.regmap =3D regmap; =20 return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops, - 0, QCOM_MUTEX_NUM_LOCKS, NULL); + 0, QCOM_MUTEX_NUM_LOCKS, &init); } =20 static struct platform_driver qcom_hwspinlock_driver =3D { --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 14820366067 for ; Tue, 10 Mar 2026 07:56:14 +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=1773129376; cv=none; b=lIwX8V9OBJH8WeBtr31j0TaW5Uxxa6hRHvOJZPZuQ7SIZS3sYkcosepj8YA23XW1jyKBd1A/M+oLTZIEdg86azq1okOQvh+Z1xC5io5DOz1xAyDP2rYHy6Q5iRbONQ7M9K0PBBh27AfjQndzXekfgzakkggTJnsdZecPLwAX7ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129376; c=relaxed/simple; bh=UXawvM/5ghyvuCTf9RumFTnoPGsX/4pCNQpBlbuHXI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MKHEJNTgftMeNhq9yoV/cwPuscrf2bwdvjrULjV5HuXjvpaPXwRxIkLQz7qYRSeI7peWh7RGzbqFSBYFIvZ9MrU+mvlFXn1M9MhnevlImQS4s/NY6b2TmcRI0MV8dpwZxPYbXbec1OFfjEpkp01bGEzxpJKhsidTUnlBOZsnQ00= 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=FPvv7T6C; 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="FPvv7T6C" 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=Z1ZYQaSGEP80w9qRTwVgX2BTs1CF8gzc4bx6qr/pC8E=; b=FPvv7T 6CnqNmHizNqAhVpK4Zejt0JUPuhPsakIURNoENAsRVX8IrOGgemdiJiqR4L+j/Iu /HOYVme8RZ8PPpWIiC5xEhYGO1GS6BJO5gVbenAXSXlLV6sjkT6G6afWCZz1zzkC +qAxvEyvAWBMvKTZn2ISh0jmawL8LMzTIf0ukHbKwlIrrA5+7kjBljDMecDS6sze YlxwpVpb6GsNx5LoyBZVTAF/eXukUsTSKUsOMCMlqsRAeMwMrd6MRI8N+45Zpgmd 4/bFOvejjTnKH6as5n2afXE6mCsGont+mr9pDc7RogopXiIJbLDOOHaAYWUDizzc 7naeIQK+XuWjtBig== Received: (qmail 3112703 invoked from network); 10 Mar 2026 08:55:54 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:54 +0100 X-UD-Smtp-Session: l3s3148p1@+SRI2aZMwtIujntP 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 , linux-remoteproc@vger.kernel.org Subject: [PATCH v4 07/15] hwspinlock: sprd: use new callback to initialize hwspinlock priv Date: Tue, 10 Mar 2026 08:55:22 +0100 Message-ID: <20260310075539.11701-8-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Apply the new helper to avoid using internal structures from the core. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/sprd_hwspinlock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0b91bdd4303d..f906f5fa74ef 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -70,10 +70,16 @@ static void sprd_hwspinlock_relax(struct hwspinlock *lo= ck) ndelay(10); } =20 +static void *sprd_hwspinlock_init_priv(int local_id, void *init_data) +{ + return init_data + HWSPINLOCK_TOKEN(local_id); +} + static const struct hwspinlock_ops sprd_hwspinlock_ops =3D { .trylock =3D sprd_hwspinlock_trylock, .unlock =3D sprd_hwspinlock_unlock, .relax =3D sprd_hwspinlock_relax, + .init_priv =3D sprd_hwspinlock_init_priv, }; =20 static void sprd_hwspinlock_disable(void *data) @@ -86,8 +92,7 @@ static void sprd_hwspinlock_disable(void *data) static int sprd_hwspinlock_probe(struct platform_device *pdev) { struct sprd_hwspinlock_dev *sprd_hwlock; - struct hwspinlock *lock; - int i, ret; + int ret; =20 if (!pdev->dev.of_node) return -ENODEV; @@ -123,16 +128,11 @@ static int sprd_hwspinlock_probe(struct platform_devi= ce *pdev) /* set the hwspinlock to record user id to identify subsystems */ writel(HWSPINLOCK_USER_BITS, sprd_hwlock->base + HWSPINLOCK_RECCTRL); =20 - for (i =3D 0; i < SPRD_HWLOCKS_NUM; i++) { - lock =3D &sprd_hwlock->bank.lock[i]; - lock->priv =3D sprd_hwlock->base + HWSPINLOCK_TOKEN(i); - } - platform_set_drvdata(pdev, sprd_hwlock); =20 return devm_hwspin_lock_register(&pdev->dev, &sprd_hwlock->bank, &sprd_hwspinlock_ops, 0, - SPRD_HWLOCKS_NUM, NULL); + SPRD_HWLOCKS_NUM, sprd_hwlock->base); } =20 static const struct of_device_id sprd_hwspinlock_of_match[] =3D { --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 937663659ED for ; Tue, 10 Mar 2026 07:56:16 +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=1773129381; cv=none; b=ZDavZqsswy7eObeB6UItholYtvl8PrMIzMO7EP/NDyc1kVyRkDuDDHthGlAVRiLd9tCwuR7rkxLTJJ5xQtkvY2sbefvgw/ZIR+77fKLqcVTPvknb6tT3w7w1cF1gB5BY2IUgTS7mIAh7p5yKMiZd9YCgw0NV6VvoAgkgFO0k2lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129381; c=relaxed/simple; bh=U1qZ9jIrkPpwE5zid3eu2tzycTF41Kp+jVWr8Ch5bjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z2gE8tfIBmi5yIBVsy28EfaGI7Lozg5XgVclNmOa3mS4QTd9MVj3aeVnneob5jR/JczScAiwiZOuZmHV4VDeBXHO8wdD4g7k7X9f1eWad5+L/PRkwdJ+3jxqG6EyZDu5WYVahS3hIff/+4jtlkiVA2JzlpOpRByXedoKNujdViI= 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=QWR0TbGP; 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="QWR0TbGP" 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=LDIMIHD5xh8qvwSFq+3EkqfTJhIyn7kfCnloFC1bgFA=; b=QWR0Tb GPPxLY8rjfvrErDgwaDJyfSR/zyQ6OQr5MfiQGSSDrhzqw6CwcaJpHeD+etoMke4 QJyXZdgzva9hfM75WMz6wcTswK9PttUr/aDqlc1PR4KoKbZ5/0SfkpMDbA606OFD Tj0EXLbBukqtyWuZffCTURrF0E8HTwFH+bEPBEAUsOsVPcSINqR6/ZD1bKAmUlbg eq49RS+CzOy7i4yd0qnbL/yi+SW5MH6y72eOaLc7KjOiG+8oOAB0TVhNrcqP33jj S1b/nOqLAytbE3QBWAOYpy8EWzFymGyPo4HMEjr7375/TvDA13p+aliIbAcUCe7x N3OP0TO7eW9EWL9A== Received: (qmail 3112715 invoked from network); 10 Mar 2026 08:55:54 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:54 +0100 X-UD-Smtp-Session: l3s3148p1@I0tS2aZMytIujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Maxime Coquelin , Alexandre Torgue , linux-remoteproc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 08/15] hwspinlock: stm32: use new callback to initialize hwspinlock priv Date: Tue, 10 Mar 2026 08:55:23 +0100 Message-ID: <20260310075539.11701-9-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Apply the new helper to avoid using internal structures from the core. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/stm32_hwspinlock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 51e8e533ac31..62214f31f909 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -48,10 +48,16 @@ static void stm32_hwspinlock_relax(struct hwspinlock *l= ock) ndelay(50); } =20 +static void *stm32_hwspinlock_init_priv(int local_id, void *init_data) +{ + return init_data + local_id * sizeof(u32); +} + static const struct hwspinlock_ops stm32_hwspinlock_ops =3D { .trylock =3D stm32_hwspinlock_trylock, .unlock =3D stm32_hwspinlock_unlock, .relax =3D stm32_hwspinlock_relax, + .init_priv =3D stm32_hwspinlock_init_priv, }; =20 static void stm32_hwspinlock_disable_clk(void *data) @@ -73,7 +79,7 @@ static int stm32_hwspinlock_probe(struct platform_device = *pdev) struct device *dev =3D &pdev->dev; struct stm32_hwspinlock *hw; void __iomem *io_base; - int i, ret; + int ret; =20 io_base =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(io_base)) @@ -106,11 +112,8 @@ static int stm32_hwspinlock_probe(struct platform_devi= ce *pdev) return ret; } =20 - for (i =3D 0; i < STM32_MUTEX_NUM_LOCKS; i++) - hw->bank.lock[i].priv =3D io_base + i * sizeof(u32); - ret =3D devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops, - 0, STM32_MUTEX_NUM_LOCKS, NULL); + 0, STM32_MUTEX_NUM_LOCKS, io_base); =20 if (ret) dev_err(dev, "Failed to register hwspinlock\n"); --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 D829636654F for ; Tue, 10 Mar 2026 07:56:17 +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=1773129382; cv=none; b=USRXJVNvmlinVVycxJiroAWt+vGzOEo7M4C7aAepJwKwciEFyKm3T9MAFBzJ4AXkaGkp2Dl9Jw1zPauPXu56g7x4tm0ed7bD7l0I8NRkcwffdnt+/SwurKrXQUuaKxAS5pwRIa1pFfOErn050zw94jDxJMiAPQNGKqwK/X2At9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129382; c=relaxed/simple; bh=42u90bGiuD4aeqHVuUHXKa5boniiN0wJ3UdVXzh+u7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B8njMhbFvbJyfIi8zky+zTA2MdBEYpuZKD5tHXNwdErADiYdQaMs7hdwgkW8uIG63DG/JSRkC4RaJeyGETAmt7tlZRWDb7DSoK7FuZP2kpiMqUyQ/c3FlOd6mb5qTN64bso6kGgFB+FuArBRCcGV2QpcoCHR1bB1dxK1iBH8LsA= 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=XA4+C49x; 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="XA4+C49x" 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=V811ZnR3+6B2X2veFZsr6SS9lD2yc+/nKwkhuTtKc88=; b=XA4+C4 9xPLCLeAkef9lQ4nB92JMnoImim/26HnCm8q+lVdPdrRZDgFN00qJWJlQGZ5JYee 4JUtrw0jBAlyvTJZOfwtPRncKcPpbHxTHYa61KfrYNVzJAt9coLRDdsvMfop4HIC uIMXHkIbBEdc8i0Tag25QnJvqULhZp4qupUIJ/Vso1wp/0diZ35PSnzWxc9utRs/ gJdj8J7cQgzRN/YwcAmzxfUgOwVPgz5IcLiR9pXc2usd+ymJvFIsocI3OgCI8HvL NNkUveh+mAOAYqyGnqkBb3UGlbSW5QoErXXVUci4jQsAEisIPRX+S6t0gQ0ddTs/ osHX73I95y75ecHw== Received: (qmail 3112731 invoked from network); 10 Mar 2026 08:55:55 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:55 +0100 X-UD-Smtp-Session: l3s3148p1@LcRc2aZM2NIujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Chen-Yu Tsai , Wilken Gottwalt , Bjorn Andersson , Baolin Wang , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v4 09/15] hwspinlock: sun6i: use new callback to initialize hwspinlock priv Date: Tue, 10 Mar 2026 08:55:24 +0100 Message-ID: <20260310075539.11701-10-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Apply the new helper to avoid using internal structures from the core. Remove superfluous setting of drvdata while here. Signed-off-by: Wolfram Sang Reviewed-by: Chen-Yu Tsai --- drivers/hwspinlock/sun6i_hwspinlock.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index a0c76bba3f05..c3db81cb1793 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -74,9 +74,15 @@ static void sun6i_hwspinlock_unlock(struct hwspinlock *l= ock) writel(SPINLOCK_NOTTAKEN, lock_addr); } =20 +static void *sun6i_hwspinlock_init_priv(int local_id, void *init_data) +{ + return init_data + sizeof(u32) * local_id; +} + static const struct hwspinlock_ops sun6i_hwspinlock_ops =3D { .trylock =3D sun6i_hwspinlock_trylock, .unlock =3D sun6i_hwspinlock_unlock, + .init_priv =3D sun6i_hwspinlock_init_priv, }; =20 static void sun6i_hwspinlock_disable(void *data) @@ -91,10 +97,9 @@ static void sun6i_hwspinlock_disable(void *data) static int sun6i_hwspinlock_probe(struct platform_device *pdev) { struct sun6i_hwspinlock_data *priv; - struct hwspinlock *hwlock; void __iomem *io_base; u32 num_banks; - int err, i; + int err; =20 io_base =3D devm_platform_ioremap_resource(pdev, SPINLOCK_BASE_ID); if (IS_ERR(io_base)) @@ -161,11 +166,6 @@ static int sun6i_hwspinlock_probe(struct platform_devi= ce *pdev) goto bank_fail; } =20 - for (i =3D 0; i < priv->nlocks; ++i) { - hwlock =3D &priv->bank->lock[i]; - hwlock->priv =3D io_base + SPINLOCK_LOCK_REGN + sizeof(u32) * i; - } - /* failure of debugfs is considered non-fatal */ sun6i_hwspinlock_debugfs_init(priv); if (IS_ERR(priv->debugfs)) @@ -177,10 +177,8 @@ static int sun6i_hwspinlock_probe(struct platform_devi= ce *pdev) goto bank_fail; } =20 - platform_set_drvdata(pdev, priv); - return devm_hwspin_lock_register(&pdev->dev, priv->bank, &sun6i_hwspinloc= k_ops, - SPINLOCK_BASE_ID, priv->nlocks, NULL); + SPINLOCK_BASE_ID, priv->nlocks, io_base + SPINLOCK_LOCK_REGN); =20 bank_fail: clk_disable_unprepare(priv->ahb_clk); --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 2E8103D34A0 for ; Tue, 10 Mar 2026 07:56:19 +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=1773129384; cv=none; b=eaEIqJ8zeI6twXzXAwKENdTMdLDyaCoNosgm7dNr/nA0gFWntlWfknQMDMlWaAP9SqvOUtRsZ7wmIBeKUcTCgXegckKmU2GVOkoE/bFR8WKaz1i1oouEJxvBt2Ws6X+bSeLF4RL3erbl8ackC3Ur56qSamP9FxaBcp+Mk5BtZ6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129384; c=relaxed/simple; bh=AlOrengIMhbczEUUr+bbQBX5sdtAkgzqbeSlazfayXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWhFN8zuVELnYP3jpIM1YDQzNlwSUjWwqtqoikvR9zBI0NlJu3yQHxXYGhlhMg7v7U1am2F6AmVdJSTqf64Rlt9QUlPXYI0+Z6occ6bgTpWaxwAWnLle95+PSBEMb/+wLbMtEq/PUb5jiKKy6alwcpfmjz/acf2EiF3aSyT8Dwc= 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=JeDwJroC; 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="JeDwJroC" 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=EMGJQBKk3iRQb/TPpDntOCN2HXfcMFp2fpsLhTqCbd4=; b=JeDwJr oC5Qe93RjiDvMZBM9yNPNucdSc8YUUK/dmMzTJssnf+Rnkle3RTVkUd/zM9XHBu/ BEkCfN1m3N2W0HgitJyyYPu6aZiIzlohzfucQcds8kMhXUBsAtGoAjUgFZL/nwv0 g6rXG0pEuZ6U4VUSCTleHt5X3odrIKWsLFssAdV+OsPyWAp3qPzkRhFLqwTgri1m 4F/8jbyFN85NnZDMoDOxCR8hW1pDsPsQhvOKDqDyDKl1bqNUj5dZZZOYTcpvkTaj eIFzwnMZgLhtcg2oglSuPar9vWgeT7ZY6chmAovmgc0tiJPL8Vbo853Wqt2V2BZ3 9LBAYI358hZBtGfw== Received: (qmail 3112752 invoked from network); 10 Mar 2026 08:55:56 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:56 +0100 X-UD-Smtp-Session: l3s3148p1@I0xx2aZM3NIujntP 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 v4 10/15] hwspinlock: handle hwspinlock device allocation in the core Date: Tue, 10 Mar 2026 08:55:25 +0100 Message-ID: <20260310075539.11701-11-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Providers have been refactored to avoid using core internal structures. As a result, they do not need to allocate the hwspinlock device on their own anymore because they can access everything they need with helpers. So, the allocation is moved to the core. As a result, the registering functions now return a pointer to the (soon) opaque hwspinlock device which may be needed for unregistering only. Because the argument list of the registering functions is changed, all users are changed here as well. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 48 +++++++++++++++------------ drivers/hwspinlock/omap_hwspinlock.c | 10 ++---- drivers/hwspinlock/qcom_hwspinlock.c | 11 ++---- drivers/hwspinlock/sprd_hwspinlock.c | 17 ++++------ drivers/hwspinlock/stm32_hwspinlock.c | 7 ++-- drivers/hwspinlock/sun6i_hwspinlock.c | 12 ++----- include/linux/hwspinlock.h | 17 ++++++---- 7 files changed, 52 insertions(+), 70 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index afe1e7ce2829..a7610ba755b4 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include "hwspinlock_internal.h" =20 @@ -502,7 +503,6 @@ static struct hwspinlock *hwspin_lock_unregister_single= (unsigned int id) =20 /** * hwspin_lock_register() - register a new hw spinlock device - * @bank: the hwspinlock device, which usually provides numerous hw locks * @dev: the backing device * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank @@ -514,21 +514,25 @@ static struct hwspinlock *hwspin_lock_unregister_sing= le(unsigned int id) * * Should be called from a process context (might sleep) * - * Returns: %0 on success, or an appropriate error code on failure + * Returns: a pointer to the device (needed for unregistering), or an + * appropriate error pointer on failure */ -int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks, - void *init_data) +struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data) { + struct hwspinlock_device *bank; struct hwspinlock *hwlock; int ret, i; =20 - if (!bank || !ops || !dev || !num_locks || !ops->trylock || - !ops->unlock) { + if (!ops || !dev || !num_locks || !ops->trylock || !ops->unlock) { pr_err("invalid parameters\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } =20 + bank =3D kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL); + if (!bank) + return ERR_PTR(-ENOMEM); + bank->dev =3D dev; bank->ops =3D ops; bank->base_id =3D base_id; @@ -553,12 +557,13 @@ int hwspin_lock_register(struct hwspinlock_device *ba= nk, struct device *dev, goto reg_failed; } =20 - return 0; + return bank; =20 reg_failed: while (--i >=3D 0) hwspin_lock_unregister_single(base_id + i); - return ret; + kfree(bank); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(hwspin_lock_register); =20 @@ -589,6 +594,8 @@ int hwspin_lock_unregister(struct hwspinlock_device *ba= nk) WARN_ON(tmp !=3D hwlock); } =20 + kfree(bank); + return 0; } EXPORT_SYMBOL_GPL(hwspin_lock_unregister); @@ -639,7 +646,6 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * devm_hwspin_lock_register() - register a new hw spinlock device for * a managed device * @dev: the backing device - * @bank: the hwspinlock device, which usually provides numerous hw locks * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device @@ -650,29 +656,27 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * * Should be called from a process context (might sleep) * - * Returns: %0 on success, or an appropriate error code on failure + * Returns: a pointer to the device (usable for unregistering), or an + * appropriate error pointer on failure */ -int devm_hwspin_lock_register(struct device *dev, - struct hwspinlock_device *bank, - const struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data) +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) { - struct hwspinlock_device **ptr; - int ret; + struct hwspinlock_device **ptr, *bank; =20 ptr =3D devres_alloc(devm_hwspin_lock_unreg, sizeof(*ptr), GFP_KERNEL); if (!ptr) - return -ENOMEM; + return ERR_PTR(-ENOMEM); =20 - ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks, init_dat= a); - if (!ret) { + bank =3D hwspin_lock_register(dev, ops, base_id, num_locks, init_data); + if (!IS_ERR(bank)) { *ptr =3D bank; devres_add(dev, ptr); } else { devres_free(ptr); } =20 - return ret; + return bank; } EXPORT_SYMBOL_GPL(devm_hwspin_lock_register); =20 diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 868b93131796..87ab30614e1d 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -80,7 +80,6 @@ static const struct hwspinlock_ops omap_hwspinlock_ops = =3D { =20 static int omap_hwspinlock_probe(struct platform_device *pdev) { - struct hwspinlock_device *bank; void __iomem *io_base; int num_locks, i, ret; /* Only a single hwspinlock block device is supported */ @@ -117,13 +116,8 @@ static int omap_hwspinlock_probe(struct platform_devic= e *pdev) =20 num_locks =3D i * 32; /* actual number of locks in this device */ =20 - bank =3D devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks), - GFP_KERNEL); - if (!bank) - return -ENOMEM; - - return devm_hwspin_lock_register(&pdev->dev, bank, &omap_hwspinlock_ops, - base_id, num_locks, io_base + LOCK_BASE_OFFSET); + return devm_hwspin_lock_register_errno(&pdev->dev, &omap_hwspinlock_ops, = base_id, + num_locks, io_base + LOCK_BASE_OFFSET); } =20 static const struct of_device_id omap_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 73b280988109..e2836d6728e8 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -223,9 +223,7 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct= platform_device *pdev, static int qcom_hwspinlock_probe(struct platform_device *pdev) { struct qcom_hwspinlock_priv_init_data init; - struct hwspinlock_device *bank; struct regmap *regmap; - size_t array_size; =20 regmap =3D qcom_hwspinlock_probe_syscon(pdev, &init.base, &init.stride); if (IS_ERR(regmap) && PTR_ERR(regmap) =3D=3D -ENODEV) @@ -234,16 +232,11 @@ static int qcom_hwspinlock_probe(struct platform_devi= ce *pdev) if (IS_ERR(regmap)) return PTR_ERR(regmap); =20 - array_size =3D QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock); - bank =3D devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL); - if (!bank) - return -ENOMEM; - init.dev =3D &pdev->dev; init.regmap =3D regmap; =20 - return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops, - 0, QCOM_MUTEX_NUM_LOCKS, &init); + return devm_hwspin_lock_register_errno(&pdev->dev, &qcom_hwspinlock_ops, + 0, QCOM_MUTEX_NUM_LOCKS, &init); } =20 static struct platform_driver qcom_hwspinlock_driver =3D { diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index f906f5fa74ef..bbae37e25243 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -33,15 +33,14 @@ struct sprd_hwspinlock_dev { void __iomem *base; struct clk *clk; - struct hwspinlock_device bank; }; =20 /* try to lock the hardware spinlock */ static int sprd_hwspinlock_trylock(struct hwspinlock *lock) { - struct sprd_hwspinlock_dev *sprd_hwlock =3D - dev_get_drvdata(hwspin_lock_get_dev(lock)); void __iomem *addr =3D hwspin_lock_get_priv(lock); + struct device *dev =3D hwspin_lock_get_dev(lock); + struct sprd_hwspinlock_dev *sprd_hwlock =3D dev_get_drvdata(dev); int user_id, lock_id; =20 if (!readl(addr)) @@ -50,8 +49,7 @@ static int sprd_hwspinlock_trylock(struct hwspinlock *loc= k) lock_id =3D hwlock_to_id(lock); /* get the hardware spinlock master/user id */ user_id =3D readl(sprd_hwlock->base + HWSPINLOCK_MASTERID(lock_id)); - dev_warn(sprd_hwlock->bank.dev, - "hwspinlock [%d] lock failed and master/user id =3D %d!\n", + dev_warn(dev, "hwspinlock [%d] lock failed and master/user id =3D %d!\n", lock_id, user_id); return 0; } @@ -97,9 +95,7 @@ static int sprd_hwspinlock_probe(struct platform_device *= pdev) if (!pdev->dev.of_node) return -ENODEV; =20 - sprd_hwlock =3D devm_kzalloc(&pdev->dev, - struct_size(sprd_hwlock, bank.lock, SPRD_HWLOCKS_NUM), - GFP_KERNEL); + sprd_hwlock =3D devm_kzalloc(&pdev->dev, sizeof(*sprd_hwlock), GFP_KERNEL= ); if (!sprd_hwlock) return -ENOMEM; =20 @@ -130,9 +126,8 @@ static int sprd_hwspinlock_probe(struct platform_device= *pdev) =20 platform_set_drvdata(pdev, sprd_hwlock); =20 - return devm_hwspin_lock_register(&pdev->dev, &sprd_hwlock->bank, - &sprd_hwspinlock_ops, 0, - SPRD_HWLOCKS_NUM, sprd_hwlock->base); + return devm_hwspin_lock_register_errno(&pdev->dev, &sprd_hwspinlock_ops, = 0, + SPRD_HWLOCKS_NUM, sprd_hwlock->base); } =20 static const struct of_device_id sprd_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 62214f31f909..ed937bc26bf5 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -22,7 +22,6 @@ =20 struct stm32_hwspinlock { struct clk *clk; - struct hwspinlock_device bank; }; =20 static int stm32_hwspinlock_trylock(struct hwspinlock *lock) @@ -85,7 +84,7 @@ static int stm32_hwspinlock_probe(struct platform_device = *pdev) if (IS_ERR(io_base)) return PTR_ERR(io_base); =20 - hw =3D devm_kzalloc(dev, struct_size(hw, bank.lock, STM32_MUTEX_NUM_LOCKS= ), GFP_KERNEL); + hw =3D devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL); if (!hw) return -ENOMEM; =20 @@ -112,8 +111,8 @@ static int stm32_hwspinlock_probe(struct platform_devic= e *pdev) return ret; } =20 - ret =3D devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops, - 0, STM32_MUTEX_NUM_LOCKS, io_base); + ret =3D devm_hwspin_lock_register_errno(dev, &stm32_hwspinlock_ops, + 0, STM32_MUTEX_NUM_LOCKS, io_base); =20 if (ret) dev_err(dev, "Failed to register hwspinlock\n"); diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index c3db81cb1793..8bbed23af5f4 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -27,7 +27,6 @@ #define SPINLOCK_NOTTAKEN 0 =20 struct sun6i_hwspinlock_data { - struct hwspinlock_device *bank; struct reset_control *reset; struct clk *ahb_clk; struct dentry *debugfs; @@ -159,13 +158,6 @@ static int sun6i_hwspinlock_probe(struct platform_devi= ce *pdev) goto bank_fail; } =20 - priv->bank =3D devm_kzalloc(&pdev->dev, struct_size(priv->bank, lock, pri= v->nlocks), - GFP_KERNEL); - if (!priv->bank) { - err =3D -ENOMEM; - goto bank_fail; - } - /* failure of debugfs is considered non-fatal */ sun6i_hwspinlock_debugfs_init(priv); if (IS_ERR(priv->debugfs)) @@ -177,8 +169,8 @@ static int sun6i_hwspinlock_probe(struct platform_devic= e *pdev) goto bank_fail; } =20 - return devm_hwspin_lock_register(&pdev->dev, priv->bank, &sun6i_hwspinloc= k_ops, - SPINLOCK_BASE_ID, priv->nlocks, io_base + SPINLOCK_LOCK_REGN); + return devm_hwspin_lock_register_errno(&pdev->dev, &sun6i_hwspinlock_ops,= SPINLOCK_BASE_ID, + priv->nlocks, io_base + SPINLOCK_LOCK_REGN); =20 bank_fail: clk_disable_unprepare(priv->ahb_clk); diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 094a6d0d39d6..58733cda7a9a 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -29,8 +29,8 @@ struct hwspinlock_ops; =20 void *hwspin_lock_get_priv(struct hwspinlock *hwlock); struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); -int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks, void *init= _data); +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); @@ -46,10 +46,15 @@ struct hwspinlock *devm_hwspin_lock_request_specific(st= ruct device *dev, unsigned int id); int devm_hwspin_lock_unregister(struct device *dev, struct hwspinlock_device *bank); -int devm_hwspin_lock_register(struct device *dev, - struct hwspinlock_device *bank, - const struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data); +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)); +} =20 #else /* !CONFIG_HWSPINLOCK */ =20 --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 C8BE73D667D for ; Tue, 10 Mar 2026 07:56:23 +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=1773129386; cv=none; b=VuXEPahE7jEzUgNI8z7XZcaeSUgGEfsFasjGo1CfhMVi7z7CQfGmMbHkmjyjexHIsEiLcsnoYmYpIqakimj+d411857+VUazubfXGhKA6OhgYqkD0mRz9Gil6fx+CnqSyUpbl9kxNgEUvRu0MH6Txf2LVk6YbLA2AKvz+jFP2Bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129386; c=relaxed/simple; bh=asNNZO3T9J/zCvAshr8ECVC12qbgcjwJBEdnKjW8eco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u1GpbB0tSXkvkMQI0Zbi7/Cbh9A/GUaKkPCS84auznp0b9U7HhwS60Mp3Xd/1+Xygqxqp93/PLixEkjnA/mKM7nf4pVsQCVinpahwERRzF9xAl5Y2rNNmHieIrK2MbML9+aEvQnwhsRnIkaV6wzwRByTT9ol8uIvXRS1QCv/xvQ= 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=B3cMMvxA; 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="B3cMMvxA" 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=ZRMTNQrz0U6t5XnH9AMNswJjY22nKrWom0qhpwEtk9U=; b=B3cMMv xA1iERRotAgLTpQZiW593f9fq1ZyAfoFw8Kx0QHNkAiBVip/JOl5Tnm4u9ejpyGA BGvA4PllKr6ecoahdZ/fqfMwheXAQSayWKmCdY62dLiOYEcSkcwu/Fbbp4rjyPQO 5Q7hiLGbNajoBSpe8j+A1iIfncz/+qHWNmvra+WDHHvbSOIKh7ltP9vp384g8upr hg11kaab1P1HDSUkTowW3rtyuUzd8gETsTjr1lGcUOyoyvljuRRS4JGP01YRnnaS K7ucTKGy5UFVAU3fGm/HsWR9YNSqhZbY/mnFNVhoOBoUr5MhknaYC/Qpnw75u5uJ I3Y5DGJ3dQj/azaQ== Received: (qmail 3112771 invoked from network); 10 Mar 2026 08:55:58 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:58 +0100 X-UD-Smtp-Session: l3s3148p1@tCuG2aZM5NIujntP 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 v4 11/15] hwspinlock: move entries from internal to public header Date: Tue, 10 Mar 2026 08:55:26 +0100 Message-ID: <20260310075539.11701-12-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Providers need the ops-structure and the hwlock_to_id-function. Move these entries to the public header. With this change, all providers are also updated to use the public header only. The internal header is now used by the core only. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 8 +++++++ drivers/hwspinlock/hwspinlock_internal.h | 29 ------------------------ 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 | 23 +++++++++++++++++++ 8 files changed, 31 insertions(+), 39 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index a7610ba755b4..e0227d027cf2 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -915,5 +915,13 @@ struct device *hwspin_lock_get_dev(struct hwspinlock *= hwlock) } EXPORT_SYMBOL_GPL(hwspin_lock_get_dev); =20 +int hwlock_to_id(struct hwspinlock *hwlock) +{ + int local_id =3D hwlock - &hwlock->bank->lock[0]; + + return hwlock->bank->base_id + local_id; +} +EXPORT_SYMBOL_GPL(hwlock_to_id); + MODULE_DESCRIPTION("Hardware spinlock interface"); MODULE_AUTHOR("Ohad Ben-Cohen "); diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/= hwspinlock_internal.h index 3c835d96bf86..20ae531fc389 100644 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ b/drivers/hwspinlock/hwspinlock_internal.h @@ -15,28 +15,6 @@ =20 struct hwspinlock_device; =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); -}; - /** * struct hwspinlock - this struct represents a single hwspinlock instance * @bank: the hwspinlock_device structure which owns this lock @@ -65,11 +43,4 @@ struct hwspinlock_device { struct hwspinlock lock[]; }; =20 -static inline int hwlock_to_id(struct hwspinlock *hwlock) -{ - int local_id =3D hwlock - &hwlock->bank->lock[0]; - - return hwlock->bank->base_id + local_id; -} - #endif /* __HWSPINLOCK_HWSPINLOCK_H */ diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 87ab30614e1d..41a8812708ef 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -23,8 +23,6 @@ #include #include =20 -#include "hwspinlock_internal.h" - /* Spinlock register offsets */ #define SYSSTATUS_OFFSET 0x0014 #define LOCK_BASE_OFFSET 0x0800 diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index e2836d6728e8..22cc6f9003df 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -14,8 +14,6 @@ #include #include =20 -#include "hwspinlock_internal.h" - #define QCOM_MUTEX_APPS_PROC_ID 1 #define QCOM_MUTEX_NUM_LOCKS 32 =20 diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index bbae37e25243..0f4fc622e3cd 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -15,8 +15,6 @@ #include #include =20 -#include "hwspinlock_internal.h" - /* hwspinlock registers definition */ #define HWSPINLOCK_RECCTRL 0x4 #define HWSPINLOCK_MASTERID(_X_) (0x80 + 0x4 * (_X_)) diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index ed937bc26bf5..8eafe1a74b1b 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -14,8 +14,6 @@ #include #include =20 -#include "hwspinlock_internal.h" - #define STM32_MUTEX_COREID BIT(8) #define STM32_MUTEX_LOCK_BIT BIT(31) #define STM32_MUTEX_NUM_LOCKS 32 diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index 8bbed23af5f4..145d284c5ab5 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -17,8 +17,6 @@ #include #include =20 -#include "hwspinlock_internal.h" - #define DRIVER_NAME "sun6i_hwspinlock" =20 #define SPINLOCK_BASE_ID 0 /* there is only one hwspinlock device per SoC = */ diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 58733cda7a9a..4f5b6932712e 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -27,8 +27,31 @@ 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); --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 CCB1B3D413D for ; Tue, 10 Mar 2026 07:56:26 +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=1773129389; cv=none; b=hmC+YtRwbPB92Cu3s8uz0KOTk3mKYYUxhzPyoPDqIHrfCdkQAv97zV3Zkl3wAaxkpxGGfGLj8+IQ3jcRyT08x/zrceyRKT6deHH3QImDYvoyXFPbOOgIG1AmHW3hi13hUIJPRU7jow9C/qYfXWd93drn1G4R6Clxr3itInm5Yyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129389; c=relaxed/simple; bh=0BpfEzdJ/CP5RPB9drxCOpncawCXIiZayrIjpodhx44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tfdMpGX35ZLKw7Jgmo5UmZT5OJzsmAFpHcGIM2VrOOsLa/SybhkI+9B+4RNzKvPEm0yqcxrL+6yoVafOwGZDHv2QS2r9SMNYruRJfmhpXtMpkqCkE768FDrM/CK507dpa3+2L2fKNz99fRAtHRmVP+3RB3JF2t3/jMPK5GcKvoc= 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=UnEZMyv/; 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="UnEZMyv/" 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=OXWaEhH47IDPa7+2B714kGuQz0Ni4DVVK4CBG1WhWRQ=; b=UnEZMy v/b7iDBZu1qNdX9qFNI2z0E1qs8n9XIC4bqAFrgJkUOeLK3BpcaH84Lp2gO+kI+Y KecYeNCGeci3IGESq/ha84a0ZRPi4Nybu38zvDQ4PXAi5XlT672nv8humm4eWo6d pa9MzFlc5rCN/cG+gOnY8FuLpljHrTNZj0DJZ1C8DrTzPReA1QEphcLTF5PuVM7I vCQvFFk2hsncf+Z0Jk/3FWuNGBIziWG3Auxbfmd3WGZZomskrZ9gkE6SHjmSvltN PKZ/7ivuv6AAmP6y0X6fz56rojKp4p11yV8XUlCfAxIDLzj4s5nmv0vrzLEOzRwP YpEVvOG4eF/pWXpQ== Received: (qmail 3112790 invoked from network); 10 Mar 2026 08:55:59 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:59 +0100 X-UD-Smtp-Session: l3s3148p1@aIqU2aZM6tIujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , linux-remoteproc@vger.kernel.org Subject: [PATCH v4 12/15] hwspinlock: remove internal header Date: Tue, 10 Mar 2026 08:55:27 +0100 Message-ID: <20260310075539.11701-13-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" Because the internal header is now used by the core only, it can also be merged into source file itself. The header was small enough. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 31 +++++++++++++++- drivers/hwspinlock/hwspinlock_internal.h | 46 ------------------------ 2 files changed, 30 insertions(+), 47 deletions(-) delete mode 100644 drivers/hwspinlock/hwspinlock_internal.h diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index e0227d027cf2..838bb2ab5eba 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ =20 #include +#include #include #include #include @@ -23,7 +24,35 @@ #include #include =20 -#include "hwspinlock_internal.h" +struct hwspinlock_device; + +/** + * struct hwspinlock - this struct represents a single hwspinlock instance + * @bank: the hwspinlock_device structure which owns this lock + * @lock: initialized and used by hwspinlock core + * @priv: private data, owned by the underlying platform-specific hwspinlo= ck drv + */ +struct hwspinlock { + struct hwspinlock_device *bank; + spinlock_t lock; + void *priv; +}; + +/** + * struct hwspinlock_device - a device which usually spans numerous hwspin= locks + * @dev: underlying device, will be used to invoke runtime PM api + * @ops: platform-specific hwspinlock handlers + * @base_id: id index of the first lock in this device + * @num_locks: number of locks in this device + * @lock: dynamically allocated array of 'struct hwspinlock' + */ +struct hwspinlock_device { + struct device *dev; + const struct hwspinlock_ops *ops; + int base_id; + int num_locks; + struct hwspinlock lock[]; +}; =20 /* retry delay used in atomic context */ #define HWSPINLOCK_RETRY_DELAY_US 100 diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/= hwspinlock_internal.h deleted file mode 100644 index 20ae531fc389..000000000000 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Hardware spinlocks internal header - * - * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com - * - * Contact: Ohad Ben-Cohen - */ - -#ifndef __HWSPINLOCK_HWSPINLOCK_H -#define __HWSPINLOCK_HWSPINLOCK_H - -#include -#include - -struct hwspinlock_device; - -/** - * struct hwspinlock - this struct represents a single hwspinlock instance - * @bank: the hwspinlock_device structure which owns this lock - * @lock: initialized and used by hwspinlock core - * @priv: private data, owned by the underlying platform-specific hwspinlo= ck drv - */ -struct hwspinlock { - struct hwspinlock_device *bank; - spinlock_t lock; - void *priv; -}; - -/** - * struct hwspinlock_device - a device which usually spans numerous hwspin= locks - * @dev: underlying device, will be used to invoke runtime PM api - * @ops: platform-specific hwspinlock handlers - * @base_id: id index of the first lock in this device - * @num_locks: number of locks in this device - * @lock: dynamically allocated array of 'struct hwspinlock' - */ -struct hwspinlock_device { - struct device *dev; - const struct hwspinlock_ops *ops; - int base_id; - int num_locks; - struct hwspinlock lock[]; -}; - -#endif /* __HWSPINLOCK_HWSPINLOCK_H */ --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 3CE5D36495B for ; Tue, 10 Mar 2026 07:56:28 +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=1773129390; cv=none; b=bDO9UQqfBmhm48WnAYRzFXbpG6vgmvTwChMNISMojwHge7g49PBikzoRGlHxt+iObPNHPMQeBirwwAyy3yPxkHbEM3VrX+QHY7sgYL8+ephzueUid63TZx0FA8JuH0Nbeh0imGyNKXVM/CrPjcvOkbV05K5T37uQWUabj5ZRcko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129390; c=relaxed/simple; bh=XSXpLvgEtf8gkGC6vqgXnLn+x0RQgYmg32UvC5obOks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kInICDYob+B82LcEZgHzCQV8SL2ibjzAkyLz751J5Q0w6uTtheXJJvJ8RMVuQyyHJo4DDx2D1DzSdae3qdPaSlZu2blrTImOmhpehL+6VCNKmGnv2s6t+PN2ibRP+awAthtqXvTnMTdogx3Y19a/njB9OVf4NFHPUEJFKawdiSM= 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=eWQYik1A; 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="eWQYik1A" 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=V9/Xk0SE3kHSqCT1iJcjM3q5nVH3IOMXei18cV6OdNM=; b=eWQYik 1AZPSENCe6cEzL688W7NYdO7yqcoBHjbjmN5uDg9pGbNdVRgfoJ1IO8H2EFYu4LS gEptWTj8WC73202sPxE2eHKgUlLz7U2LY2gDIHCkheST/ETnMZe+CBQ0cJVQ+ypw q01yIFWjK8SlZUg1kiE2WTGv0cqRHvcsmdk/lLOwtoUSUBQnTbRJDGwe9APe5kti jEuGfxE3d/rmeF63HM/l6AsxE1LBagdMb3psr/y1KJp3/kkbL7a8m3ceiZp9SD3t FF7wwlfNnO1rieHNpPZQvGAK7WAtYeBGIUpv+q+usOpix6Ny2zWSu+z6iiq7ceK4 PXKHVhKqi/+KQlmw== Received: (qmail 3112803 invoked from network); 10 Mar 2026 08:55:59 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:55:59 +0100 X-UD-Smtp-Session: l3s3148p1@Wb6e2aZM7NIujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , linux-remoteproc@vger.kernel.org Subject: [PATCH v4 13/15] hwspinlock: sort include and update copyright Date: Tue, 10 Mar 2026 08:55:28 +0100 Message-ID: <20260310075539.11701-14-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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" During the latest refactoring, unsorted includes were a bit annoying. So, sort them to avoid this. Also, update the copyright due to said refactorings and remove the contact field in favor of MAINTAINERS entries. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index 838bb2ab5eba..adf6fefb382f 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -3,26 +3,26 @@ * Hardware spinlock framework * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com - * - * Contact: Ohad Ben-Cohen + * Copyright (C) 2026 Sang Engineering + * Copyright (C) 2026 Renesas Solutions Corp. */ =20 #define pr_fmt(fmt) "%s: " fmt, __func__ =20 #include #include -#include -#include -#include -#include #include -#include -#include #include -#include +#include +#include +#include #include #include +#include +#include #include +#include +#include =20 struct hwspinlock_device; =20 --=20 2.47.3 From nobody Thu Apr 9 07:17:15 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 0B6AD3E9F68 for ; Tue, 10 Mar 2026 07:56:28 +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=1773129391; cv=none; b=OS3T6Mf2AcAlNK/xaH+5oQlWd8iETqF3W5MrA0ZFAqmKzSKiwvgBXlFJJCR+bS1eLEZW83h8qm6eQXFsU7oWMDfKMVWsCUdwiJAt4wLuqMMhQz30er+F4bo7oLSpl3qQu4/smaxrlRgCTIiTh9jZiMwedB5M/oLDRuEWNPZOfoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129391; c=relaxed/simple; bh=LyGH8H6y1Ru4lWhS7HwUeYKy5PTKcXbz1xkDR2R82zY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CTH+hFXo0EaxPFjISiz3BSBRL9QSLhc4nVos+HUobGee9g/WeFhkvnis7ZAzc2+KsoMoVxEhqwTwatYsVTZSDE8n/WCOUfglq1nGS4X53VJdoZuPdBaZTfLHkCilF9YIOx2wzETovqREewt/9aBqoLHVrrz+wlvwHUlMfEl5iXk= 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=TdOLcU76; 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="TdOLcU76" 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=luMQZhgeUDyB0imC9jaTIqUtlvvHON7xVZeRSgfXazE=; b=TdOLcU 76BozWF7Z68PKDuVeKodIAkiSiKCQ6adthuVIOq+NGpomrnUP0sUQOSlOtCUgzCm 5toH0Ubz5BAjXQqVCRgUS2SWYbiszrTJ22XMmKxegvoS/yG3SdmJRryo14dEWlxA /mHWkDlH+EG1/3c/v5N2qXcKHT9EKjda0FZZMGsZJ8bKLpT4fiN0wgsGoMW79w/D KuzsUS9oWF2s2IYA2EcLGyW+7t74l0E6UNrl0YN2myf96gbN5qtxWmX/Ko0oCwIw NXnefDg8JuX/XzFfpvX3HdMOJY2+fP1UKOMPe39aO+0sE3wnH+CyvMO3dNBjKR7+ 5NLw9pOLT0E+lb6Q== Received: (qmail 3112847 invoked from network); 10 Mar 2026 08:56:01 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:56:01 +0100 X-UD-Smtp-Session: l3s3148p1@RV222aZM8tIujntP 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 v4 14/15] hwspinlock: refactor provider.h from public header Date: Tue, 10 Mar 2026 08:55:29 +0100 Message-ID: <20260310075539.11701-15-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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 --- 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 5e5282c62d2e..d5d78f08bfca 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11212,6 +11212,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.47.3 From nobody Thu Apr 9 07:17:15 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 816AC365A10 for ; Tue, 10 Mar 2026 07:56:31 +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=1773129401; cv=none; b=hMv6lDJWHbtFUDW8fKOJTdAMf8pz9dU89xIrt8A3PiIamueiPWxyY2W7ekuB8UNw1hd+N5hqgA1fOszFD9S/pY9Jy3L+NRV5+x1cj1KewUmUPo83USh3Cijw52KF/DjpjUt2gs+vSaEVmCoOSMgALJAIRcx/wLQJo761icnSgzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773129401; c=relaxed/simple; bh=YQYoMl9cJ2YRn65PkaBbiPVREIoceypt3NqeBMjR1eA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hkk6mYxOxZ1y/MgzjHiX/FBVh2MtPixBHynasdM14plA2VUeZrWpA1zxlSWNkfSDXPM8dC6fz2zgbHUYj9c8ZwU+oN03N+8E727g/yKTn3Xlh5inr/oPtwWdRHdb7WJlUYeMQRQ91sLEZU5Ngp8SgcJ2gsMCE0Og8HHuOH5TPj8= 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=dZrru0GX; 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="dZrru0GX" 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=VR3bz5kc4VcI1PQY8TwV4x5GtzDKGF8AtE87sZOuzTU=; b=dZrru0 GXM++14D1PbCtyngDrMW8bonktJHKvt9XeOUkdDaxOXlM9NRre3Vd3APZ5cxZFIC f14v8TBO29iO5BU0eZet6ismxA9rjm2dFjLdqiKB74WpuV1gyDyThm3AeO6Cago5 YTH3bqYH6cMhgSq4vjiDCFP0HWuZ0q4dxt4OQyjRwx9QzOX6J4qQokLjTqD8Qpin 0t2/ojU2/9cJulIAxn/KrNdCKDJ6bLGq8S2cju1wMCIoe6eEYnYbz1q/sETFrOzE seq3fEvjDeCrOyipkspFtTZgGc5YzEAUOkx2f0THGSsEwFjbW8iABQGkIOIP5U1z 8Jc6iJm42q5pRLbQ== Received: (qmail 3112920 invoked from network); 10 Mar 2026 08:56:03 +0100 Received: by mail.zeus03.de with UTF8SMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 10 Mar 2026 08:56:03 +0100 X-UD-Smtp-Session: l3s3148p1@CnfT2aZM/tIujntP From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Mark Brown , Jonathan Cameron , Lee Jones , Bjorn Andersson , Baolin Wang , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Jonathan Corbet , Shuah Khan , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Orson Zhai , Chunyan Zhang , Thomas Gleixner , Maxime Coquelin , Alexandre Torgue , Arnd Bergmann , Srinivas Kandagatla , Antonio Borneo , Linus Walleij , Konrad Dybcio , linux-remoteproc@vger.kernel.org, linux-doc@vger.kernel.org, driver-core@lists.linux.dev, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH v4 15/15] hwspinlock/treewide: refactor consumer.h from public header Date: Tue, 10 Mar 2026 08:55:30 +0100 Message-ID: <20260310075539.11701-16-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260310075539.11701-1-wsa+renesas@sang-engineering.com> References: <20260310075539.11701-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 consumers from the generic public header. This allows for a clean separation between providers and consumers. Also remove contact field in favor of MAINTAINERS entries. Fix the users, too. Signed-off-by: Wolfram Sang Acked-by: Mark Brown Acked-by: Jonathan Cameron # for IIO Acked-by: Lee Jones # for MFD Acked-by: Linus Walleij --- Documentation/locking/hwspinlock.rst | 2 +- MAINTAINERS | 1 - drivers/base/regmap/regmap.c | 2 +- drivers/hwspinlock/hwspinlock_core.c | 2 +- drivers/iio/adc/sc27xx_adc.c | 2 +- drivers/irqchip/irq-stm32mp-exti.c | 2 +- drivers/mfd/syscon.c | 2 +- drivers/nvmem/sc27xx-efuse.c | 2 +- drivers/nvmem/sprd-efuse.c | 2 +- drivers/pinctrl/stm32/pinctrl-stm32.c | 2 +- drivers/soc/qcom/smem.c | 2 +- drivers/spi/spi-sprd-adi.c | 2 +- .../linux/{hwspinlock.h =3D> hwspinlock/consumer.h} | 15 ++++++--------- 13 files changed, 17 insertions(+), 21 deletions(-) rename include/linux/{hwspinlock.h =3D> hwspinlock/consumer.h} (98%) diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/h= wspinlock.rst index a737c702a7d1..001bcab86690 100644 --- a/Documentation/locking/hwspinlock.rst +++ b/Documentation/locking/hwspinlock.rst @@ -306,7 +306,7 @@ Typical usage =20 :: =20 - #include + #include #include =20 int hwspinlock_example(void) diff --git a/MAINTAINERS b/MAINTAINERS index d5d78f08bfca..11421b205874 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11213,7 +11213,6 @@ 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 M: Alexander Shishkin diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 607c1246d994..d25494495469 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include =20 #define CREATE_TRACE_POINTS diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index 6c8a03deb00c..e78ec4b5cfa3 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c index 6209499c5c37..8a881d63b7dd 100644 --- a/drivers/iio/adc/sc27xx_adc.c +++ b/drivers/iio/adc/sc27xx_adc.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2018 Spreadtrum Communications Inc. =20 -#include +#include #include #include #include diff --git a/drivers/irqchip/irq-stm32mp-exti.c b/drivers/irqchip/irq-stm32= mp-exti.c index a24f4f1a4f8f..25d5aa67728a 100644 --- a/drivers/irqchip/irq-stm32mp-exti.c +++ b/drivers/irqchip/irq-stm32mp-exti.c @@ -6,7 +6,7 @@ */ =20 #include -#include +#include #include #include #include diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 21a7fcdd2737..8ec74f8513d7 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/nvmem/sc27xx-efuse.c b/drivers/nvmem/sc27xx-efuse.c index 4e2ffefac96c..309090cd4ff0 100644 --- a/drivers/nvmem/sc27xx-efuse.c +++ b/drivers/nvmem/sc27xx-efuse.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2018 Spreadtrum Communications Inc. =20 -#include +#include #include #include #include diff --git a/drivers/nvmem/sprd-efuse.c b/drivers/nvmem/sprd-efuse.c index 1a7e4e5d8b86..92e3092719ba 100644 --- a/drivers/nvmem/sprd-efuse.c +++ b/drivers/nvmem/sprd-efuse.c @@ -3,7 +3,7 @@ =20 #include #include -#include +#include #include #include #include diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/= pinctrl-stm32.c index 6a99708a5a23..17b2072d609e 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index d5c94b47f431..6d574d65b4a3 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -4,7 +4,7 @@ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. */ =20 -#include +#include #include #include #include diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index e7d83c16b46c..04313e4a63dd 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -5,7 +5,7 @@ */ =20 #include -#include +#include #include #include #include diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock/consumer= .h similarity index 98% rename from include/linux/hwspinlock.h rename to include/linux/hwspinlock/consumer.h index 4fe1c8831cd1..f476222ec924 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock/consumer.h @@ -1,17 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Hardware spinlock public header + * Hardware spinlock public header for consumers * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com - * - * Contact: Ohad Ben-Cohen + * Copyright (C) 2026 Sang Engineering + * Copyright (C) 2026 Renesas Solutions Corp. */ =20 -#ifndef __LINUX_HWSPINLOCK_H -#define __LINUX_HWSPINLOCK_H +#ifndef __LINUX_HWSPINLOCK_CONSUMER_H +#define __LINUX_HWSPINLOCK_CONSUMER_H =20 #include -#include =20 /* hwspinlock mode argument */ #define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */ @@ -22,8 +21,6 @@ struct device; struct device_node; struct hwspinlock; -struct hwspinlock_device; -struct hwspinlock_ops; =20 #ifdef CONFIG_HWSPINLOCK =20 @@ -403,4 +400,4 @@ static inline void hwspin_unlock(struct hwspinlock *hwl= ock) __hwspin_unlock(hwlock, 0, NULL); } =20 -#endif /* __LINUX_HWSPINLOCK_H */ +#endif /* __LINUX_HWSPINLOCK_CONSUMER_H */ --=20 2.47.3