From nobody Mon Apr 6 11:23:55 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 3A49B3C6A3B for ; Thu, 19 Mar 2026 11:00:07 +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=1773918010; cv=none; b=cELwliP9y9L6Mp3gXwk5RNdWbone4K8IAU9QbsNOHVGzeGRdG8HyPNd7bY5zEKimNq5Vt/F6gni2pAhWgbdFF5ZVmFIyG2bAFHERkdNizcUlZ1z2JMulZqjxIpE04DXEeqa3kwBGC7rrCrIZJNQwbKQ+8hsBFnpH9jSLNPsuq9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918010; c=relaxed/simple; bh=z38a3cLh4UkRj9AZR94BRZpkDcDOXITt/wbT8smF0PQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Aq2FTOn/I5x6hDcoLRkmVX5AE+cMM75W61CLLaVOhcl0c7nL+CURv96YFqK9ofExW2nRnAHJEpKs7FZOwiY3aV7PMJgfQl1giyeZUwLsfdwRxaEWaag5ckF5rIh3GaFXef1Ug3JwAfrAHn72COEkCZrYEru4nMxJiTHO93CJsis= 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=VDM70dsv; 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="VDM70dsv" 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=x2flKYzYfRk7gyeSwNtIj63y7Q+BDaqLHhMzsOZftOs=; b=VDM70d svdIQsic3xl0Yqt59t+QPZhBcpFBSeTQuPhOYFi6oZeaxqkRWSypkJq0XfpGECec DmFzchKtG/FknbZY3cyvHQvI/SD75uLHbFhENLCOCMamwjgcNGk4uFIzQ1Sb+yHb q8KC6qoQgSsPWSvrFsNBaySyHf+Vgd8E7mAa7pc2427T2SvvHK39et2pV8yEc1Wj snlGo5uqBQnYY2JzFAsCEOfFahmRZxOa5gwDVa2P1d6dr42GcXWwdRrRERTqLF2l B5vJpxzyNXM8F2pjf3mzRY8la2LZV/YneI1Toa4KoAxaBopmCZth1QpWIJ6iAMF1 U+vtiStcsISkl1Zw== Received: (qmail 1099457 invoked from network); 19 Mar 2026 11:59:52 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:52 +0100 X-UD-Smtp-Session: l3s3148p1@xpHId15Nyt0gAwDPXzF+ANZpdrMKUeLI 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 v5 01/15] hwspinlock: u8500: delete driver Date: Thu, 19 Mar 2026 11:59:23 +0100 Message-ID: <20260319105947.6237-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 96ea84948d76..59bccd940fe0 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.51.0 From nobody Mon Apr 6 11:23:55 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 DFE6B35B63C for ; Thu, 19 Mar 2026 11:00: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=1773918011; cv=none; b=r0rTFtrIbZutcFB+raqB66dsKsod8VnkZUZ2NqEguWSBI3T6OAn+yLy3sVAlDlY5FUNHjcINFDZvr2q6NlJguAW8zeiTPsOiRC+m4NWnEIqikvIYz53F6WYa+2BTX2LruvRtT8u1esYpGzF/4c13ieV60JevKgZ1ZY4AnzUKJNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918011; c=relaxed/simple; bh=s4yz1qknYsovhomq/cNB/wPtjPAk3MtjAzmSsKjp3rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JprIOS+RWp7yR2tnNr4aXalKFcKGBT3uYvyuVogIijFyVaTbdsxRgLx3cUg9yF0PleyMsyC2BDUla+INwiOO5/R4AsaDvUWWAyri61VxnHpUpGXT38IWYl2mF+M5vXB7zGFDV+LNJkK+KG1Z/h7wCY38b46ZHa1ofd7asn6dXJU= 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=ifO6TAC7; 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="ifO6TAC7" 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=9wsX/1VG+KmMW/70MpWHcnfgt2pNqZbpfdvHVMNyqlE=; b=ifO6TA C7ICH7HTIW63VvIKZ6uBii5nFv7jCinL5igQFeTNVTeUmq0uSnBf3OYfRe9mlXS6 +jXts4fsjfSkulz40II5VT768Zz0N1FBsyimwsP82NBsd+sEKC85fC9pxaDd3eIL b/2qNELNHWZ2dbOPEOUnCw2/bykfjfn3xrGmJUIRUfRvB/Wu+gyY1tau6fKFGeUl 4Gsq0m+WtPnaSWQAbvKLz0BxGA2r3eVfUSUHWpCM/a0wXzXWi2lRST0RKGJO7GQN s1vR6I/tNkW6l1A6/N84XZHm6bebGrwUYIMxW8z8LeGk8LzEEEanwD/ZPv5pgnp9 dT2mH2b/ACw/Gi0A== Received: (qmail 1099480 invoked from network); 19 Mar 2026 11:59:53 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:53 +0100 X-UD-Smtp-Session: l3s3148p1@uP/Ud15N2t0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Linus Walleij , Andy Shevchenko Subject: [PATCH v5 02/15] hwspinlock: remove now unused pdata from header file Date: Thu, 19 Mar 2026 11:59:24 +0100 Message-ID: <20260319105947.6237-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 196163C5521 for ; Thu, 19 Mar 2026 11:00:09 +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=1773918012; cv=none; b=Je5gQBMqbMU7wS9IAqfEKWgxzdLstkFlU9+xMnvkxdEVmXj0gCXLMBbZsSMZcAjhsZAfj+CZgEJIXlkIpUoJKsQ1Y1S5i+i76hnTw2j8mUq1hcuRi30n7UWdAmFLBjGdrEtyICnC1+6qYiX/K3gTIhv+Ip60WUS1NoLBW7s0IUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918012; c=relaxed/simple; bh=xy50e2OIp3/2ajapNXpLDbRqFj3IWYNEJO+w4nlrwQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QSTNGnlr6GuU+dYM7aoSMNCid6z8zuRb5/KF8hJZ2dTQvv36e0R9F1WNIGuMvpuW0ckPJBblqzzvgQE6rrtg8cuxSiV5cDL97jcfc6Nyxw2Lx1PpHNJQnzq3zM8Si7uF2ldF1JKQuPBaHER9Z3MNEbMRraJWrt4PsTDnvNyd8fA= 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=DKJvjVcc; 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="DKJvjVcc" 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=IZFdVpEXf9xrxaE4IR8cLQeU2fEvB2OHSkK785cEcYY=; b=DKJvjV ccTsM7Z871WbtxjKI2bNa5gsZMxNOtIeJ1g8Mygg7mHvumDuAHpzJvEYC/B37hbE 7yCrexAoxc0qlUtlA69nSv1rmDPsYgV1OiiHv1d4YYJrpWodqGH0xzD53bnOGUIh EtAIdj5sl5wvTacHXQ3uyztMDHTTLPkIaFvvlr6UXYkmYQbafXso2O/Kc3efIeTN pAvKZkJ49H3xjH0vrae0He38QRZ3eHmpOD1q4NkTax/BeGV6k/fFFOzGUNcPTBFg m6Ds8HPQ4glaWfeVDqNUiKiiXJ1Y12H4HgMKzb5Ybng1oz+B/A+NRH55SSgvW83m bwiRbafqUAzJ9Hyw== Received: (qmail 1099512 invoked from network); 19 Mar 2026 11:59:54 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:54 +0100 X-UD-Smtp-Session: l3s3148p1@XVrvd15N4t0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Chen-Yu Tsai , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 03/15] hwspinlock: add helpers to retrieve core data Date: Thu, 19 Mar 2026 11:59:25 +0100 Message-ID: <20260319105947.6237-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 # for 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.51.0 From nobody Mon Apr 6 11:23:55 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 416ED3C73C0 for ; Thu, 19 Mar 2026 11:00: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=1773918016; cv=none; b=UPAJ0boD3DfFsbCE2kkz/eTvnxtUWKzHNJQJXAQEs2TGb9MmpULoLVbDzzqxCEbQmR6UVHqtN8BeIt2+4arRQmFpOHf5Sz5wv5bfQgPh9gCJYz8/YBxg4pMVUNij5YJkTSir20fyFiEdXzuSx7nMVXVUL+Di9yVgEvR0+jE9Epw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918016; c=relaxed/simple; bh=j7JsogHPEG2k3FleveztzMhcaRMl7IeOoIUkHDuMsIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HJNhnctHX17u/9JNTE4sSR8ccyqtyNqChCRviYVoO5UE6hGvUdGZ+DKcw7me3GI4cEyIivh/mMsBTxWybwOGTv35+aIomo2fxWspNOl7oZLklfa9uS756rp9lPJ1f2Ggjw5rKNfHbCunKPTaGxfjGrBeb55BJ6KW6mj6kTtVPlg= 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=fK4f3dKO; 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="fK4f3dKO" 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=52UHmgmukdvJVk0o+2tbQ5APoShQb1Fkmq5YJKeK1WA=; b=fK4f3d KOg8BCLXt8Vc1fZQxpxxQyp8tNVbAaLDZZBUSxvEK/pcXPJWX2vg8KXv+bWD+6Yb iD9aNQIv8GYJ/GAyFVAdtTwoXx1IO4Ik6NkG7x+OIZtaNttx9BO5pSDJJk44pglF eP4BkNZUWO9P/31iatpp8upWpSnISRmVkinum8MBMCwz9SGxF7Jkh4vlcYocGexh /fXQiCZIyV81S4ka9tPsFz/PbIFToBV4H0kElmLe7yG8J9IsEMJj3Mq/qFfrVGq3 r9ZgpYbUTNj2DPzhBc0uuVBkvU4MYA7ouUw8k63Gf6sSvHgSiVVSYhf0+3fxpQJY irPjsnr9yuObc6mg== Received: (qmail 1099536 invoked from network); 19 Mar 2026 11:59:56 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:56 +0100 X-UD-Smtp-Session: l3s3148p1@byoIeF5N5t0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Jonathan Corbet , Shuah Khan , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 04/15] hwspinlock: add callback to fill private data of a hwspinlock Date: Thu, 19 Mar 2026 11:59:26 +0100 Message-ID: <20260319105947.6237-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Chen-Yu Tsai # for sun6i --- Documentation/locking/hwspinlock.rst | 3 ++- 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 ++-- 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/h= wspinlock.rst index a737c702a7d1..cedeeab7387c 100644 --- a/Documentation/locking/hwspinlock.rst +++ b/Documentation/locking/hwspinlock.rst @@ -351,7 +351,8 @@ API for implementors :: =20 int hwspin_lock_register(struct hwspinlock_device *bank, struct device *= dev, - 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); =20 To be called from the underlying platform-specific implementation, in order to register a new hwspinlock device (which is usually a bank of 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.51.0 From nobody Mon Apr 6 11:23:55 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 36CC13C6A58 for ; Thu, 19 Mar 2026 11:00: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=1773918020; cv=none; b=FSgN15z0AQlKJ0UR6VmJrOH8IqgtRY8/H+Vsvg8HBFLPOfEW3daHPggbomZlpLB8E4iw4HG+0D3RSXfeVglbwULFDKV4+VHFKtkYFh/vPRZZrXVOjFm+wgfGtybYkEvo7r5eF3pq9QG5XyYiRssr55cAV29GK2oD79aKy36RD+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918020; c=relaxed/simple; bh=t92OnzR8r6jZTrmncLKGrwgpIYknSeg4sMgdsW8KWSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JLaipKiqcomUDvII+E7gkk9w5Xt0VZFZTUqB0neQct20pWAbInFw0L2yVUs6CdBKl56CYiqd0h3j9DbZSSKEBh7wfAsGU3+KhE7Fw9WxQduFye7saQMD79RRiq1YqJX8AfZB1K2Lgk36CgK6L202W0+g2UcnQ0oG4cpW/LCQi8k= 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=ILkU8tuU; 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="ILkU8tuU" 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=zNZ7iTl8FDE7U49MCjuBLAc4mKVqh5ltMfRvYgVFysQ=; b=ILkU8t uUUHii2DM03wCl3vUY2c8tVF6EcVvnHuP66XcrfE26HhVEnV+FwR0I0/ZnyoGVSt gjqTsVr7AAH/AeTwLgsjtE6Ce+RA+TzUmuLc3YoRJL3UX+Z9nkVZbzXz8pLli+rt 9c6K+w1EgwMPl9Ic0aGmjqldH5Vkr+HX4wVPxvoL4bOInO6hpvmxdfcE1yL6BPra rlE2Iuo64oQbWMIMkqAQnDPSrlsy9FxpNEGcb1cmBCIyZWAliRjtKcnySND+sJnr c1PdWgrp6aq4pCCTW90/XpalzLDwLUpF2SNBhDWOb7GyviXAa9vFKWzhjQ+yIObq UzSyNVdpFtOW5urw== Received: (qmail 1099555 invoked from network); 19 Mar 2026 11:59:57 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:57 +0100 X-UD-Smtp-Session: l3s3148p1@Im4XeF5N7N0gAwDPXzF+ANZpdrMKUeLI 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 v5 05/15] hwspinlock: omap: use new callback to initialize hwspinlock priv Date: Thu, 19 Mar 2026 11:59:27 +0100 Message-ID: <20260319105947.6237-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 5029B3A9616 for ; Thu, 19 Mar 2026 11:00:18 +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=1773918021; cv=none; b=nbhfPvFtItbiCm0z/R4EZ9ECqLnpIqCbheho7PsfYe6xNiC51nMXFm6/AjvE1LxsfCsP5jDtaleTxO8/GPbnXdFFGyB9yrn8BVIgEulwRmItUUMsbtXgAXKL42mWa0HK+tMI8/Mod1whtm3TqYrq9v6bEMe+r+YGTeJfjxZvujM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918021; c=relaxed/simple; bh=NYiPCzdYDU9BdHcA+eu/2dPkEVePnOw3CoYxF3To1jQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z6GEHKNyiPwJZDMPYQOCLr75x3g44BMrtzt+mNQSCp/hDMZH07Fjf9flutvuntxxck+kwAl0UqypEQgWvdDIDVgz2h0rNJkRoILJmAUOc5BYSEwj88/F9w3QdWi4HUkscZS1jIsdcXbqtmAzjqnV3ogMNVxK2jvMdSvRD1ckWY8= 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=fHwEAvjt; 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="fHwEAvjt" 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=c5DSTYKJVivgA9XXvmh9gEwArmRd1OpMLRV7T5NJLQc=; b=fHwEAv jt7nJiexHdNIGWyO7wr26nuVcMp7pFwk8Phi0O67qiEHdJ3i+9iPQgmf7TMM+YZh EMfBN5dniXX68ivb5yYc1mm2C7yIOTDZcg3fdAqs7ncv6b0ntPaZc0lZ1cgCR7Lt r9bboFNyDH6V+ltAawbZJYkDK5SxXPeLbAS+gmwcJA9Jyj8xfDNLq/q63V+robV6 DJFP1Yzj0qq+y7tTG6k9tXY84mxCznLwDY527Q2ePxsbEVP6AC8eCRp+ilQG79Zn maZgD2n9yebTxCtbMpQ2IoQ2oKcvrCebI40Sfi+fSIN+VbvTRef0odFD/GafN8Xr n9K4+5NmaUMIN6QQ== Received: (qmail 1099573 invoked from network); 19 Mar 2026 11:59:58 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:58 +0100 X-UD-Smtp-Session: l3s3148p1@75wieF5NYJsgAwDPXzF+ANZpdrMKUeLI 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 v5 06/15] hwspinlock: qcom: use new callback to initialize hwspinlock priv Date: Thu, 19 Mar 2026 11:59:28 +0100 Message-ID: <20260319105947.6237-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 311783C65F9 for ; Thu, 19 Mar 2026 11:00:22 +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=1773918024; cv=none; b=CakjbO/MNUajV//fjCFX8WXP8gCeZyOHFvQfe3kIkaWivbVio91vezOkLG8SsiQ8KHjTgB8N03HOFiB/YhKbs3cDLN4Aw7EGHbSnF/1Be/GpYMD3wEwXYnRO8fojh450Q48nz2Z//U386TPKaQFMhL31Du9+4YtII+u5jXZB2F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918024; c=relaxed/simple; bh=gKBddV9sinIqdmJCyXboDE9z9F21uQ+JueRqg5Hobo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HHbvQh8YyYqLMiYFznGYCb05w5EpNmgjXO90VdvFsmPoHPH14I0xeeHaZ+dLyfm5ManLgYrAiemkZ+hhm4jrdG+NzceiV2DvE8L+SPZfhxU05TYNsQIIe1l0UQKsqLduJJ4KO6qp6eJjpjhVnDEXVwGomUbRZ/LbDqJ07wV5z9Q= 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=AMU8FuT3; 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="AMU8FuT3" 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=w7ycEgeDr6Fe7llcfOqItjza7eOV0SfPJPxdSW1Pnro=; b=AMU8Fu T3bj6XGrPazpi52hVvnhjurfuvXSHk3c2ppTlcd+1CBNQwf0u9bhj/jPvMnDsKaZ CwKUJ2UX44jeM17ALXkvlxB4vAur1Q/waj6eUGfIhd+Y/q5uHloeDd6R9o5Y0tBY 5oLcSI98Bc27vOukMDyuk6TdWdli/Hv8bLk9Lj9LBuAgnOWUyMwT7RuTzi8iDTnP Xgc25GRi57l7EuJTM6K/GG5JC0fq9ibNNlFdJq2cNtJweNrSfYVlRBFELv6Xdx1t jD7O6bsT2+EYHn5R+F4NlXuZPySl9GYpee3vLJAnlILu/KdfkOOYqIGW+svFKbve xJiqnTdywbm0XG6Q== Received: (qmail 1099588 invoked from network); 19 Mar 2026 11:59:59 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:59 +0100 X-UD-Smtp-Session: l3s3148p1@XMUueF5NapsgAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang , linux-remoteproc@vger.kernel.org Subject: [PATCH v5 07/15] hwspinlock: sprd: use new callback to initialize hwspinlock priv Date: Thu, 19 Mar 2026 11:59:29 +0100 Message-ID: <20260319105947.6237-8-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 6556D3C6A37 for ; Thu, 19 Mar 2026 11:00: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=1773918030; cv=none; b=dh9TW48HMBvutT01WtQRk2vX2jsHvfJk/U3MN13+Dqg9vV32cZsngWI9mJ4w+frOM4pVt57kR+fw+AZOF2svZVcOMQWQjz+xqzT+EjUq86fv6gRBLuHVEzhgV0Vawx0thfo0ZMaoEHai5DZlU37c33xB6TrOkryjlJGHmFGRQN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918030; c=relaxed/simple; bh=KzyLEUFyySml/W/QoWMCTJFa5ir/a4hjtyApO1sVLuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AeTxWOLVtexbgTPFGqD8KPWdZ850VzScTg7kCHAH8L4ZVpQ4yv6r/yQBpjM3/YAQQr9L9JKtd/sqPsTf3Co+OVjwdF7GePkWTefg3PAlMArrg5xHPoK+FVSIL8kZcg9kUYJGqoihwYvZZjqPlkfv5rEddH/9v3FsaRpQOkrH3N0= 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=i3a2eKDx; 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="i3a2eKDx" 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=zJPnV6sWCqcikZmuYtUvxsV1HgXNWyKzDo8+0458in4=; b=i3a2eK DxSBMURYHxV4OXoM+UKykTDNhOCzRHayQxgVcIUd+QIen0ieRn56eQCrHfQvUD4R uKZN/6u1fTHyr9YMdeKvdk/VWP4tz4AwGIVh4ZSuVDKTzGIy6zZy2W4jcYfNWH2Q 4BDHHl5PW96xUcmGZq6EdSohg46AJr+0HpY6PC8wGT3z1PLjF/yMaSIRFLCPgmyE C5jJw/5W5DEdIfrxFYvlGpqYWbdqDA/GwcvC/Fco3N4voWMu3ZzML0Rr/JlCYHNn WqYuE1gq6Z6BLTBY9g3nXbniafKoA7lhbRGUVXV1KWffXQuzsuvsrH0iA6jmp3ba nvywWZbfAF3MKLPg== Received: (qmail 1099602 invoked from network); 19 Mar 2026 11:59:59 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 11:59:59 +0100 X-UD-Smtp-Session: l3s3148p1@PFs7eF5NbJsgAwDPXzF+ANZpdrMKUeLI 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 v5 08/15] hwspinlock: stm32: use new callback to initialize hwspinlock priv Date: Thu, 19 Mar 2026 11:59:30 +0100 Message-ID: <20260319105947.6237-9-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 9EA063C942E for ; Thu, 19 Mar 2026 11:00:22 +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=1773918024; cv=none; b=TVkTLDNMK/n6bpmC9oOUWoMnJtx0Qtwk3UcvGQR0CwfrY9rN+yexQMxA9dGN+Cd0R8IxJM2ktAXTObqwElrcfgmK8MEQY58eeSmwf0q5qUOFSKr7wkcU0pfO8rUhk2W9UcDkAbgLvVAoQcvWqoogjowOusXINC0SYdiKLMX8H9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918024; c=relaxed/simple; bh=lPUlWLDZEIHKetKHHdMSN3sOG8dRuYx7PE4oGAgK69o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NG+2UQ6wzMlWTQuaDksnnCy3fJHDFJgjdthfUTBihdCfWj8eyfwroZwvAesxS5aMJ/7sZ8WAOlMJPzbHey8R9Ck065k1EfBpA83Ziyrp3KeyULqCrJkiOnXyYep+/nzRbbd1mKiTVH7iVoyIIA8zHZ2Vs9oH0dGsaCisK2AcENQ= 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=Vef3M3MZ; 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="Vef3M3MZ" 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=zC6Y1AkSSP6gBbG0k4SbZrnCH1NvYvCklVNqT+RHEM0=; b=Vef3M3 MZMMYT8RPLvd1Eq3WmfHKWQqATDW/hmqBvASwumh4Xnf6rfnsqDsKQ1HKRxN3h6L LU6FLsKYCdaNhYJgjiK7rMbRKWjRVTxHt/WTrf5VVe0MDCFQr/V6i6FZfKnXLgVs AAsiZodPtcmrySpT31FfDHmqNx0F1k658iF49PvAoam5g68okZpRZ73E/D5cRLGv Dmbm4q4P/d9lza9egT98n0pl/H4o1blkUhORZ659TK3DnaBYPwEQi9ivbVTx3TjB wFoK9R9Q5SdYeY7k8Zr1YuFHMslXdvD1JTWPZCAWaWtGIwO2fpEhEmmdG0MZTCWL /Ss4U0a0ZWgnyXvg== Received: (qmail 1099649 invoked from network); 19 Mar 2026 12:00:00 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:00 +0100 X-UD-Smtp-Session: l3s3148p1@d9dHeF5NcpsgAwDPXzF+ANZpdrMKUeLI 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 v5 09/15] hwspinlock: sun6i: use new callback to initialize hwspinlock priv Date: Thu, 19 Mar 2026 11:59:31 +0100 Message-ID: <20260319105947.6237-10-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 701483C6A3A for ; Thu, 19 Mar 2026 11:00:25 +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=1773918031; cv=none; b=NCG08f9fuwlKMz2tkYRLEq2/jYxkTVAXwVnjLUcW7KidW82uZqanoEQiqJ9Vo/YIQxXStQjojJliG0rrlrHoBRpoFTgW8EG8ooNWSnAmC4MtSY8OgAe2oUglcJsE8+4m2SOt7Kqlx4bJK1m7QLMa4Ep8y5dbRKNeRRsreeCvIus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918031; c=relaxed/simple; bh=+w9EJrt58H40phI5QcHf4yLQWIr0DQ5+HQ2Md4lKb3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gstj/iztl8+z40DvOPxC98DUX3MKJj3wDR9G/vgCuM4d1uzz1WuGwaTaQiCy0UOQphxWqBfJu+AuGLLnnKcPECAu6emfAPSpqPp+f5kbvb1ZIm9VfCmNtbh1/33xfn7Nb34aMDq2h2Womb+E6/sHE0tlAqxjk/YiIM4OFius3Pc= 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=MNRNyBy3; 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="MNRNyBy3" 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=fhsUVtFpKIbK3HJ0EZngkYgaFiPAXt2fCKFcBGLp5ZY=; b=MNRNyB y3QIgSmDv8SrBWbv19HUxFoXrhXBmlBxxrRQbhT4HB0JlUbYAOhDZymhC1+34Cu8 8M803s15RFr0SsSz6eaoFkDUN2fE5MbqTJONvnaAQKlG7OnhneQ768khVwyF5s+d Evxd1Q97sUF/rRhUOCxsaCZyklmG05vecWA2NAh2G4PL3rYQ16xkRc/gD8I7Tk+N v1dNtr0jWdBHLFGkrGDydN+B3tbTKg/ct6yLpj9/CYNf6ug0G9SpcWDm26Do0xRs FDrB0t86Ci9+vsLMf/7LSipEB99KwHEgW+0Zoj/Q1sKHDO+N7sRMx5Ws8qJjLGum s6H0fPOWyFBARlbA== Received: (qmail 1099729 invoked from network); 19 Mar 2026 12:00:02 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:02 +0100 X-UD-Smtp-Session: l3s3148p1@X/5geF5NfpsgAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Jonathan Corbet , Shuah Khan , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-doc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 10/15] hwspinlock: handle hwspinlock device allocation in the core Date: Thu, 19 Mar 2026 11:59:32 +0100 Message-ID: <20260319105947.6237-11-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Chen-Yu Tsai # for sun6i --- Documentation/locking/hwspinlock.rst | 6 ++-- 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 ++++++---- 8 files changed, 55 insertions(+), 73 deletions(-) diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/h= wspinlock.rst index cedeeab7387c..6cf1975b4291 100644 --- a/Documentation/locking/hwspinlock.rst +++ b/Documentation/locking/hwspinlock.rst @@ -350,9 +350,9 @@ API for implementors =20 :: =20 - int hwspin_lock_register(struct hwspinlock_device *bank, struct device *= dev, - const struct hwspinlock_ops *ops, int base_id, - int num_locks, void *init_data); + struct hwspinlock_device *hwspin_lock_register(struct device *dev, + const struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data); =20 To be called from the underlying platform-specific implementation, in order to register a new hwspinlock device (which is usually a bank of 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.51.0 From nobody Mon Apr 6 11:23:55 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 368643CA4AD for ; Thu, 19 Mar 2026 11:00:29 +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=1773918037; cv=none; b=J7t+V6hzalzeF4zJDHlk28AtLx0uRJbj0olgdjn86GO7IfQReuuZx2U4oAb7EO8gnvGE28ipvoByID8eBk/aORPTaDyI/Jg1EN1+m4NSxm+YD4fz1HbDYpPrZ8C2Y1kcKP3UBlcmfx91uK6EcfaJACenv67IFY0oRXwveUulSeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918037; c=relaxed/simple; bh=Qq0o4FNNvBG/mWOA0PE9lYgDNYmGuDSBq6pajGH3Bx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ka0tMwczCk6UE7cBDVqTgAEbE8+5qCYPWixYLsagZsp/MQaPBXBPyPhrteL/4VzSnlVzo6ujWYKdIN3s2v4hz8N4OFWsHvD8fsNrBbRRGlp2V1E5uZIqXqyHpAOdN1Hzevkf+V5Ej+ZNOLbmlN33bbnvqYZUquNKUBvFcPTQqaA= 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=aUUAA+TI; 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="aUUAA+TI" 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=2njF1crk5JYsuohHYtW2T9uqDGU7n8lPKWVOP57dVMM=; b=aUUAA+ TIQCX0SJ4pwNyGnHcH0zdCPfLwTWLGDHElsPMF9Ilpu25xYdzGWSOVuOv8sk4aHl smE69sqboqQY9qeCEAW9pn/aMaEIONIEfygCV6MFDpCke67nmnkkgL9+SrJrTWdI Fk6W7yWEOz1FVBXo1TBgzFag76Q8y+Kf9xsOfuQdmbEZIgD/KfRqXDMCcVNluwl/ apT+Lso2+LBs4YnxOp9WV2vTgIa9vIjiXxvMt7gJFZrwxcr7dlztwyx+5ygqV0nQ JZbCWNk0uBEHrqXerCS6/G27bE61SBY0aSzTQ19mdG5NbUSfyHScytsOE+f60u82 S93eOd3pxgDrJy2g== Received: (qmail 1099899 invoked from network); 19 Mar 2026 12:00:08 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:08 +0100 X-UD-Smtp-Session: l3s3148p1@MEzEeF5NuK0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 11/15] hwspinlock: move entries from internal to public header Date: Thu, 19 Mar 2026 11:59:33 +0100 Message-ID: <20260319105947.6237-12-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Chen-Yu Tsai # for sun6i --- 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.51.0 From nobody Mon Apr 6 11:23:55 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 524E53CAE9E for ; Thu, 19 Mar 2026 11:00:35 +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=1773918042; cv=none; b=aUZuOAZDxOMiIi914Ggdbz1rilv42daKX3KV4S9IlVCLD2/Z6b3fS7xTp4jb6zEOTAS+Tv4jMsZuJVl6V0XJQOz0DWwj13TgRc9O399mSpAyAOM8Guoim1cyGtRYPMdMqwdFVmdnMK7FOLERK009WlPZGsb7xzmJLB3dHvPpUeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918042; c=relaxed/simple; bh=2qHwj1Hj7wC4HlI3asFHikIH7wRdg857kdR/tWd/T/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OiNaE3m2lAB9rDyC8VZhnVGlby2tXQv3H5DC9Waim1mP8vQb+6CXVrQ+teHzu259EOlYPo2DSZ9tYwjS7GA/QhN1aci6iCYCm36lwMd0Kz0SF4G3VH+Y+at2v3uH5F4cZDx+B2MgwCNP9KzkF9QadY9FStctapQHxtnNw0Aj318= 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=P8VuVNmg; 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="P8VuVNmg" 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=/sFyPu9FMCDlNk9fEpqi+119BKQlqMiwj2wobIRKYUo=; b=P8VuVN mgfkF8El2hVCoCJiDSCT7G88SmOiJCyyGw2EWq1XkhkVbAz2TseH465w4JqFd0M1 xBK2Q706tybEuIHF6hfPFotG9vehWezBN1TG+6iEfexY8Cod6d2seLI8MQKNx/Tx VHKYQ0ELAUs5+5aCh491pbeh8bfgDKVckLXciAhQulJ403lFfjNVIZPMYvXjNeYX VLbk0IquKUG0Z74rHrS5ufHeloKHnqtEpqE92ZuxbRfc0vXhpmMqrHsGSrWtZttK FlVPUyB0dexPfIH9bepaPgnyCk5B0ztqvlAMjIwO5JWgQZEebfr/y0qPHIoiXID3 DrVMPMpZ7eJdAXnw== Received: (qmail 1099928 invoked from network); 19 Mar 2026 12:00:09 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:09 +0100 X-UD-Smtp-Session: l3s3148p1@9o3TeF5NyK0gAwDPXzF+ANZpdrMKUeLI 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 v5 12/15] hwspinlock: remove internal header Date: Thu, 19 Mar 2026 11:59:34 +0100 Message-ID: <20260319105947.6237-13-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 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 C7E903C9EC5 for ; Thu, 19 Mar 2026 11:00:33 +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=1773918039; cv=none; b=VKhocrIAQ3FNLQJMAcZfTA67s14QtKVSCk+IFtlYF6QMdm40hTYXyr3Mt3RxcgeoJJEs7VgxxV9sxjp428o3UNUA6OLWiJhUBB1wRQOjnQd2GQygGGAFDqIgIcb/MTotxAeBNhTdYZoYlWz3ZTkh8/B84H4mPu/N91Z2X0Hc2TQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918039; c=relaxed/simple; bh=cGbDtwydlJZBcEqlFjz378ZiockJrW9wvEor5EyRyG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=peyuM/kryGchnc4EWltVrcFvfwuJV7UnTwUJD/qH/BWmBRTWumeoVKs6rbusnwJqa3Dyz5FWeApRY+ljYcRrY2Rv+scnLIBm1DdeEqExVWizhcPKvpjU+OzEUcmju8Zop8kkjIV7/GWT/yvhkPsyN4XcTQ1lcR4zO1D1ZzFFpXs= 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=Mbq0SY5U; 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="Mbq0SY5U" 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=ZQ5IlfCArlNYSNVvw0cWn0DqfDcbz6f67ibVvyNg+b0=; b=Mbq0SY 5Uno1ei4rCyN213rlbTCj3LFC9wO1g1i09HMCMAZS9UZwLl2SbPjrDWfmQ7NtxRQ nShsRUTuxd8mVFRzDZktej+Jj+3Ov0iOaqB3A7TXVpzKpT9JGZCSp3D/CnW99HVR W2/oW2+wOxPCmY4uAF60q2WbF77CM/HyFMhxwHDIQpcdV/BGjXMNL0kKjv2pLyO6 i7q1aK6dDW7eR+nkhMUDsJ9Myll7VYxKP/0kksHlpnPuS5RpgezPpro9JZWnz7ZF Ey/swtknAyi1VEZ2mBtXoHX8TTfDYkdNERXbVun2vYtuXB/N/fZ9eLfXmsQpQOxZ gEHmdM0Ntp7Yf1gg== Received: (qmail 1099952 invoked from network); 19 Mar 2026 12:00:10 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:10 +0100 X-UD-Smtp-Session: l3s3148p1@C9bfeF5Nzq0gAwDPXzF+ANZpdrMKUeLI 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 v5 13/15] hwspinlock: sort include and update copyright Date: Thu, 19 Mar 2026 11:59:35 +0100 Message-ID: <20260319105947.6237-14-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.51.0 From nobody Mon Apr 6 11:23:55 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2FD13C8729 for ; Thu, 19 Mar 2026 11:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918044; cv=none; b=E9vosj2h/jq6+H+vB2GHZSYjTgjtjf8+/RWo3iU1RxfAiBABjAxMKvquLqDnMHHt5pR6+WTkIPvPpl33BlrFgWcnkAZJnyVlJCT4qaTx17zzX1ZRUsgVYNHrqIMboJ72oRbjZuafMe/u1xYBxwCEwKBJ7jwlxgTgaw6nfUVy0Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918044; c=relaxed/simple; bh=I2ZMZdq3pMVowiWGvuz/v7eklt+UR4xDaNbvT2+j7d0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JrKgY6zJNpFHu5hj3iFqBKVH4W6DQg+T8QfeMDb6KpfCHR0VQ09F8oDLo6oHKX5MGHoH84+bDwSgSA/znT97/0RI5CEKHbnVxYZzl8AcxyP/bnlK6MylMSjlksMvKG4CQ1tlZC6AZMeXegLUmfEadRoOg289j0LAuofZ0BtROCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=OM7oZl4w; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="OM7oZl4w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=4Tuc6A/FvFB15id+FPPkagjKPIMyqvuTmoP13uOV7sE=; b=OM7oZl 4wxQSWnDtuWEqld2AHyoETYmdLYMn7OoPkBh5yoZ54wDEQXV1SdREEMEoyKyTTr5 iGxPSyEmYu1MPIoK7XKUPNs7wcbc5FTYLzgvrfmUMe49WR8WrhwyLydGMOilHJNZ oJXeGE5St7docsKmf0BYcjRDfQgdp1OrOdinTQIXww+bFkj8MDDWfk7X/WGprYPG drSePTuacpgC+pyB6A5klblrODCcxCnZ3Nlnik8oTEWZ6tWHII6SoSgS8EACLOnE y5ZYXBEIdzsXBQflrkRN9IgAYAEJRo4DKYYeSCg7xw7WAwHWaJq2IJhW9q27ybFq vdi5+FYYDr6qtptg== Received: (qmail 1100027 invoked from network); 19 Mar 2026 12:00:12 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:12 +0100 X-UD-Smtp-Session: l3s3148p1@MJP5eF5N1q0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Wilken Gottwalt , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v5 14/15] hwspinlock: refactor provider.h from public header Date: Thu, 19 Mar 2026 11:59:36 +0100 Message-ID: <20260319105947.6237-15-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out the entries only needed for providers from the generic public header. This allows for a clean separation between providers and consumers. All providers are in the hwspinlock subsystem currently and are trivially converted here as well. Signed-off-by: Wolfram Sang Acked-by: Chen-Yu Tsai # for sun6i --- MAINTAINERS | 1 + drivers/hwspinlock/hwspinlock_core.c | 1 + drivers/hwspinlock/omap_hwspinlock.c | 2 +- drivers/hwspinlock/qcom_hwspinlock.c | 2 +- drivers/hwspinlock/sprd_hwspinlock.c | 2 +- drivers/hwspinlock/stm32_hwspinlock.c | 2 +- drivers/hwspinlock/sun6i_hwspinlock.c | 2 +- include/linux/hwspinlock.h | 44 -------------------- include/linux/hwspinlock/provider.h | 60 +++++++++++++++++++++++++++ 9 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 include/linux/hwspinlock/provider.h diff --git a/MAINTAINERS b/MAINTAINERS index 59bccd940fe0..117aa8d118b1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11211,6 +11211,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/gi= t/andersson/remoteproc.git hw F: Documentation/devicetree/bindings/hwlock/ F: Documentation/locking/hwspinlock.rst F: drivers/hwspinlock/ +F: include/linux/hwspinlock/ F: include/linux/hwspinlock.h =20 HARDWARE TRACING FACILITIES diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index adf6fefb382f..6c8a03deb00c 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 41a8812708ef..1be5c9d5091b 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include =20 diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 22cc6f9003df..7fdbb1e58b29 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -4,7 +4,7 @@ * Copyright (c) 2015, Sony Mobile Communications AB */ =20 -#include +#include #include #include #include diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0f4fc622e3cd..46b55d939ea8 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 8eafe1a74b1b..2620d722ee1d 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -6,7 +6,7 @@ =20 #include #include -#include +#include #include #include #include diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index 145d284c5ab5..24e60009fa76 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index 4f5b6932712e..4fe1c8831cd1 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -27,34 +27,6 @@ struct hwspinlock_ops; =20 #ifdef CONFIG_HWSPINLOCK =20 -/** - * struct hwspinlock_ops - platform-specific hwspinlock handlers - * - * @trylock: make a single attempt to take the lock. returns 0 on - * failure and true on success. may _not_ sleep. - * @unlock: release the lock. always succeed. may _not_ sleep. - * @bust: optional, platform-specific bust handler, called by hwspinlock - * core to bust a specific lock. - * @relax: optional, platform-specific relax handler, called by hwspinlock - * core while spinning on a lock, between two successive - * invocations of @trylock. may _not_ sleep. - * @init_priv: optional, callback used when registering the hwspinlock dev= ice. - * Its return value will be used to fill the per-lock 'priv' data. - */ -struct hwspinlock_ops { - int (*trylock)(struct hwspinlock *lock); - void (*unlock)(struct hwspinlock *lock); - int (*bust)(struct hwspinlock *lock, unsigned int id); - void (*relax)(struct hwspinlock *lock); - void *(*init_priv)(int local_id, void *init_data); -}; - -void *hwspin_lock_get_priv(struct hwspinlock *hwlock); -struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); -int hwlock_to_id(struct hwspinlock *hwlock); -struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data); -int hwspin_lock_unregister(struct hwspinlock_device *bank); struct hwspinlock *hwspin_lock_request_specific(unsigned int id); int hwspin_lock_free(struct hwspinlock *hwlock); int of_hwspin_lock_get_id(struct device_node *np, int index); @@ -67,18 +39,6 @@ int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned= int id); int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock); struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, unsigned int id); -int devm_hwspin_lock_unregister(struct device *dev, - struct hwspinlock_device *bank); -struct hwspinlock_device *devm_hwspin_lock_register(struct device *dev, co= nst struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data); - -static inline int devm_hwspin_lock_register_errno(struct device *dev, - const struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data) -{ - return PTR_ERR_OR_ZERO(devm_hwspin_lock_register(dev, ops, base_id, num_l= ocks, init_data)); -} - #else /* !CONFIG_HWSPINLOCK */ =20 /* @@ -87,10 +47,6 @@ static inline int devm_hwspin_lock_register_errno(struct= device *dev, * code path get compiled away. This way, if CONFIG_HWSPINLOCK is not * required on a given setup, users will still work. * - * The only exception is hwspin_lock_register/hwspin_lock_unregister, with= which - * we _do_ want users to fail (no point in registering hwspinlock instance= s if - * the framework is not available). - * * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-chec= king * users. Others, which care, can still check this with IS_ERR. */ diff --git a/include/linux/hwspinlock/provider.h b/include/linux/hwspinlock= /provider.h new file mode 100644 index 000000000000..73c7b0cb6735 --- /dev/null +++ b/include/linux/hwspinlock/provider.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Hardware spinlock public header for providers + * + * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2026 Sang Engineering + * Copyright (C) 2026 Renesas Solutions Corp. + */ + +#ifndef __LINUX_HWSPINLOCK_PROVIDER_H +#define __LINUX_HWSPINLOCK_PROVIDER_H + +#include + +struct device; +struct hwspinlock; +struct hwspinlock_device; + +/** + * struct hwspinlock_ops - platform-specific hwspinlock handlers + * + * @trylock: make a single attempt to take the lock. returns 0 on + * failure and true on success. may _not_ sleep. + * @unlock: release the lock. always succeed. may _not_ sleep. + * @bust: optional, platform-specific bust handler, called by hwspinlock + * core to bust a specific lock. + * @relax: optional, platform-specific relax handler, called by hwspinlock + * core while spinning on a lock, between two successive + * invocations of @trylock. may _not_ sleep. + * @init_priv: optional, callback used when registering the hwspinlock dev= ice. + * Its return value will be used to fill the per-lock 'priv' data. + */ +struct hwspinlock_ops { + int (*trylock)(struct hwspinlock *lock); + void (*unlock)(struct hwspinlock *lock); + int (*bust)(struct hwspinlock *lock, unsigned int id); + void (*relax)(struct hwspinlock *lock); + void *(*init_priv)(int local_id, void *init_data); +}; + +void *hwspin_lock_get_priv(struct hwspinlock *hwlock); +struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); +int hwlock_to_id(struct hwspinlock *hwlock); +struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data); +int hwspin_lock_unregister(struct hwspinlock_device *bank); + +struct hwspinlock_device *devm_hwspin_lock_register(struct device *dev, co= nst struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data); +int devm_hwspin_lock_unregister(struct device *dev, + struct hwspinlock_device *bank); + +static inline int devm_hwspin_lock_register_errno(struct device *dev, + const struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data) +{ + return PTR_ERR_OR_ZERO(devm_hwspin_lock_register(dev, ops, base_id, num_l= ocks, init_data)); +} + +#endif /* __LINUX_HWSPINLOCK_PROVIDER_H */ --=20 2.51.0 From nobody Mon Apr 6 11:23:55 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 94D813CC9FF for ; Thu, 19 Mar 2026 11:00:42 +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=1773918048; cv=none; b=XL3mCpf3B4+GPqcgzvkk70A0teCRVpZvv34FZuHbuBJmX9qpQzeOmZg0++2zHC3wVE377lcrtqavGRrkGOqq+5z5jGr8f3/ogFt/YSJUu3cEPTxiqhHIA4lHX8tjB9ZtV/2VYjMgKAvfg033ZYgkxJzhrX73Refs0lHIDLdWlrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918048; c=relaxed/simple; bh=xLRnabvgTKx4wYBVWJuaqvEwtn/R5RIfx0e3rV+lOBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGG0UdAEjr5d8USCsNfNylqmGYzPSNTWeLKnltY6BC1P6w/d5QzXp8gcmxFJKCW3DbhQlfNXo7tWufky/8Op93QRb4VLRfOAeRQ3fu1husjuIwLm6uhAp1NzMSkdYwi4KnGwhXk+Pn7wOH2TLJvk9OcG2r3pByZt2GaK1M9oYOc= 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=J19rHBG5; 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="J19rHBG5" 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=8P0L9KPwWoEYp1wqQDiVOeC14U3qRws47dAHCjsDfpU=; b=J19rHB G516Loa6KC6cjNGGFS6o39M4DvYSmlYx0QBMOCbXALpYnvDPX8PK0Ysde2dY5S/m CofMZy0XIPxcM/hMk+EKEbWc1QBaTNmwwQihV+wIdVVVGpQ+5Imfxm6mPl9dgqpU KYE604Us3WOi39pIr57P/EwQ43UUFvuSO2+W5Zh8UyOD1Dh3Hvv+QVJKWF6NS/Z6 kTCH3carn9FCIQJqEVunQCtXr+C5x7E3kfA09zY1FbZDPYDfTJZ7RLyOYoAZ0yJD onQsy/5KWEQU8kOpB97D8xHOYeql7xpruf4pyAPjoOul/oKpy0Z6v3NgySB6U4BA G7HDzcHC+BiIDsug== Received: (qmail 1100090 invoked from network); 19 Mar 2026 12:00:14 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 19 Mar 2026 12:00:14 +0100 X-UD-Smtp-Session: l3s3148p1@9ooZeV5N5K0gAwDPXzF+ANZpdrMKUeLI From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Mark Brown , Jonathan Cameron , Lee Jones , Greg Kroah-Hartman , Linus Walleij , Bjorn Andersson , Baolin Wang , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Jonathan Corbet , Shuah Khan , "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 , 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 v5 15/15] hwspinlock/treewide: refactor consumer.h from public header Date: Thu, 19 Mar 2026 11:59:37 +0100 Message-ID: <20260319105947.6237-16-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> References: <20260319105947.6237-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out the entries only needed for 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: Greg Kroah-Hartman 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 6cf1975b4291..ae2d2007a442 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 117aa8d118b1..dc14679bcc31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11212,7 +11212,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.51.0