From nobody Thu Apr 9 17:59:31 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 12FD638424A for ; Tue, 3 Mar 2026 19:31:41 +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=1772566303; cv=none; b=AhtqowvuDSZHybauaFf9E7AbYuBi31AN+6Xqb5SzmSLREVyj6XNcN1QM3LoCbmelEulw3T+Stk1Sm7xMh71CjwECASflNzsOtrEwzGiSnCqlH0ZEWWlRJkaOmxnCC1R8I7R+jmuyvJuddrvSz1eZMEzdVo8WM2j3e1AWz4A4RR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566303; c=relaxed/simple; bh=bbTEIrPA/9F7YO0OqW1o7y3Bb6GqJjIhC+3APfap0ns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mSJpSEAquCLmooVRe+hZp7jDdBTmHYUdGou9sxIl6fz7VA/qCmv97mOJjjRlkXFn4+DtbsgPpam/ioyh+fCDUmk8PzYrNep8OiJWyFbYfU2NHRv/+NA+P60EwNv2GHBaVavXKuaBI3s5yaBlS9w8nGV1Uw6kgsa9wGyxUzChx08= 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=BjtmGWmo; 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="BjtmGWmo" 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=d8mowWUGwQZI94qRUsM4axKWw/MQur4ZvbwUz8sNQwE=; b=BjtmGW moY8DUlHgsyQC0xNhQJ6Q/LEKMw/BI/d5q+GiCfZi1dvFt091KH7rB7TGyzSJiFZ age0f/gug4jvWO1aUsHhWxBYNoNzMDSUiv81BaWIx7v36D0QS9gnCix9ad2aX4r1 +g46fE0YAzgENXRRbfe7siIGKQ6FdqpPzp2ecfRaHL0UDiSy+OBDmsHhlvi04d9Y J9A7H5LbTePGZCzBL3pL1FqgkkwOI12NSQfIlmenwQVqoTEq2CfV8qgPaele3mDv Phcpae8yhPkzDypI/1v9Q09DucdWRNJFAi+OwQcWjn1JgzkAIlO9bUdVZhfjCOJ8 TlMfPykR7vUVdvHg== Received: (qmail 430442 invoked from network); 3 Mar 2026 20:31:26 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:26 +0100 X-UD-Smtp-Session: l3s3148p1@HtvQvyNM7qcujnu+ 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 v3 01/15] hwspinlock: u8500: delete driver Date: Tue, 3 Mar 2026 20:25:53 +0100 Message-ID: <20260303192600.7224-18-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 61bf550fd37c..b4cb7a63e800 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3157,7 +3157,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 Thu Apr 9 17:59:31 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 75C8A38424E for ; Tue, 3 Mar 2026 19:31: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=1772566304; cv=none; b=C8PXUjbGRzsSdDHy7c3gVkpVmZwYHxjc+7FdMPbnB8MaM5teX1+3NwXNhZcvt63rZnYF5Uwi417E9/S0tZFhO9K5vCPy3aoEOkpMCBwGsEd7aAfBz4llcHzVbj776Oaz0YadvcNScPCAiv+57w2ZuP/krUUSRTjYUnoLzZ0LRIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566304; c=relaxed/simple; bh=s4yz1qknYsovhomq/cNB/wPtjPAk3MtjAzmSsKjp3rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=geGwqJPIT9VcDEG6ERK+VdQnUm+rtrg44mzbpRi7MUA36+M3l5sorb1iRdYjlB3cSTumnLhNYeLBIVzRQf3G9t97mHljNng/bUpym0V42CDu/0txzGxMjli4WgvJWxoR6hFlAoF4IXcUwnkCjrvgos3Wh8+F/J5/buljrdGnc0w= 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=C4VedzTg; 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="C4VedzTg" 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=C4Vedz TgnDCSnmKl5j4vr4rMs+Jgjf+wejQPMrfeThExRUCsQPPDKre63nC6b6UPkSbNTb ABuI0T6XBv5g9A5Q+fCQLovvBuSBfA5wZZRxeY10SdkgIXHTl7jhh+y5hevOmhoh n6i/vhUtATTsiqsAhigd1uaZCKtnFniF7FQbg6I5Y+hc70I9xF5uWrApUWiQ1nI8 SZlCiqFUjhQ3aZj7iAqkqKNV3y2LYhGrXa7QKhfaHMAdMlxKMuEoUxx+9stIKUYr eCEzbRVoPxS3cL/tFNpSI9P5JEIZnveyyQbbsDClpi/W6gV6RF3gNYbm7tt0qeF0 vwqvzIhgr+lEy9zg== Received: (qmail 430477 invoked from network); 3 Mar 2026 20:31:27 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:27 +0100 X-UD-Smtp-Session: l3s3148p1@zwDjvyNM9qcujnu+ From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Linus Walleij , Andy Shevchenko Subject: [PATCH v3 02/15] hwspinlock: remove now unused pdata from header file Date: Tue, 3 Mar 2026 20:25:54 +0100 Message-ID: <20260303192600.7224-19-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 Thu Apr 9 17:59:31 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 D1304384233 for ; Tue, 3 Mar 2026 19:31:43 +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=1772566306; cv=none; b=dHt96MfQk/GGoY0qKGRcAefPoRuZsEMXehtK2vy7rfroYjQNbi8VxWgm8Iskmqj/+EwyxixzGgY7jwJwzEeoW73DhlzJ8sdH3+EEAnc0J8XFlYcwreeptirwNVjhbd3jMfr05m46nnzuABkZfMnpsa6fyIvmYQyqpGNZjL8qzNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566306; c=relaxed/simple; bh=9Ocg3jq1rBVcFXg3EEoW7RleW9cSPA0dvHAGBYBfgfw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNpqs1pfdg6DS/qMWSQYgyiZNyV95v94iAwtavUhtV+9/SfpVGkf+m4ymiADQO3BUoDdaZu1slPJBbsUsVypBB2HjJdDqUPWb/UzDl8vJ/t7zk3wFr+jfAyT2g3/TfekUi4exafmPCcpbQCesZjJPgyoqB75+JFEcMY9Cf+uPhA= 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=jM7eyrc/; 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="jM7eyrc/" 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=bwdQ2TfNm0AqCHbct36CNSsYA2zZVoG3ZIXiKj6F9PM=; b=jM7eyr c/fVJ4b30d9GhRej6cO7Cet1ZetMH1diLBDiZQc7w6C/ntG+dnvktSvMvpdNy7ll TH/ghArjrp7cXf/prWeH2zIESjLjiKyKJFnqAqV/0btJVB2MMaue99oO8DNIdxCa uEX9K5igxCFbCJGiDXxPuHPHHIz4TbKEn9ELfw1eJW4B2E/WFWLz6KjQJq7l0mJU Tvsc/y/onmzHRBRZQwu038ku3EWFhJGDh5f/hlcpMmAYg+lelE85UZnamVND/gl8 hzoRuCfuZt25d0C5Apn/rRx7Jq0MtoGu4BgoqZGLWzOkcCmxm+tgJu2HHWhhPTjO A45nw//o0FewLXGA== Received: (qmail 430513 invoked from network); 3 Mar 2026 20:31:28 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:28 +0100 X-UD-Smtp-Session: l3s3148p1@/ln5vyNMRJEujnu+ 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 v3 03/15] hwspinlock: add helpers to retrieve core data Date: Tue, 3 Mar 2026 20:25:55 +0100 Message-ID: <20260303192600.7224-20-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 --- 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 Thu Apr 9 17:59:31 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 7BE22370D62 for ; Tue, 3 Mar 2026 19:31:46 +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=1772566308; cv=none; b=eRommToj70262azLuaIvuf1gE0sOYbuvOUFeF9+v5HesEDRB9H85Wx9KyniyIvgEABPt+A1hNKvN9/rIqIIlQpqAyx6xtSTwwWuD7AZNFSZAwL857yTTWDR2adrmQUXJqJxS3Ml/wU0ZYnqCb3nYjNbd2eFXABYvYnIIVmTMNVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566308; c=relaxed/simple; bh=QuiC6BSB/7Gy03GzXxtctdOw6WzDKbivEk8frKbh8W0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PrHAHLFiDFSxzf768C49e6sfysfUCoL/styopvqLMrg1Ti/iInWGIFUfrMNwHsNao+XQnitSjpDeDP8TWVOCX0m+Vum88Og8AM/lbiS+T6BC3lpwbzQHAh6BFRxSlU9If7ZVjX9ylUDQSOvRUllkDNY31l3cVJzt/aEAEaqsRC4= 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=O1nXkr/2; 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="O1nXkr/2" 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=cqjtqeIpdHNNBDc9taDJpLwkzk9sTDEUbMxHt7RfLTc=; b=O1nXkr /2CD+J0luvQsKu4sGLXPKpV2JQQZCHUDPq08OHddYQZisYwJ2cr8jIQXuxXWnPQ/ mdzZkekP/T215tfSc5TukKfNPO/HsZcnETsMshb8lDbv2iRrSwwxLsGceZ2B3xzl UbEGTMxJykh9qWeWmRVVWxkf/X+GRgV8Mza0x6LWYthNGheGBiBbcrBWLe8LuCpS RNliPCzEPvOxoUaD91o4OnZPx28ICBvw3fr4tGi5Izv8lgCjgq8AwMg7ihsiXlVZ Lv1xkndWRM+Zy/gWzFGdeWYmAQ5sIpEwfYYDLvTaGP/JaOf1wFz1V29G2xMnvrF8 btwsDtU8QVwu9/6A== Received: (qmail 430541 invoked from network); 3 Mar 2026 20:31:30 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:30 +0100 X-UD-Smtp-Session: l3s3148p1@V7wQwCNMSJEujnu+ 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 v3 04/15] hwspinlock: add callback to fill private data of a hwspinlock Date: Tue, 3 Mar 2026 20:25:56 +0100 Message-ID: <20260303192600.7224-21-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To hide internal core structures from providers, a callback is added to the ops which allows to set the 'priv' field of a hwspinlock. It is called when a hwspinlock device is registered and, thus, iterated over all locks. The register-functions are also extended to pass a data pointer to this callback, so it can do necessary calculations for the priv field of each hwspinlock. Providers are added only an empty placeholder and are converted separately because these changes need dedicated reviews. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 19 +++++++++++++++---- drivers/hwspinlock/hwspinlock_internal.h | 19 +++++++++++-------- drivers/hwspinlock/omap_hwspinlock.c | 2 +- drivers/hwspinlock/qcom_hwspinlock.c | 2 +- drivers/hwspinlock/sprd_hwspinlock.c | 2 +- drivers/hwspinlock/stm32_hwspinlock.c | 2 +- drivers/hwspinlock/sun6i_hwspinlock.c | 2 +- include/linux/hwspinlock.h | 4 ++-- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index 2c9eceba7fe8..afe1e7ce2829 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -507,6 +507,7 @@ static struct hwspinlock *hwspin_lock_unregister_single= (unsigned int id) * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device + * @init_data: additional data passed on to the init_priv callback * * This function should be called from the underlying platform-specific * implementation, to register a new hwspinlock device instance. @@ -516,10 +517,11 @@ static struct hwspinlock *hwspin_lock_unregister_sing= le(unsigned int id) * Returns: %0 on success, or an appropriate error code on failure */ int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks) + const struct hwspinlock_ops *ops, int base_id, int num_locks, + void *init_data) { struct hwspinlock *hwlock; - int ret =3D 0, i; + int ret, i; =20 if (!bank || !ops || !dev || !num_locks || !ops->trylock || !ops->unlock) { @@ -538,6 +540,14 @@ int hwspin_lock_register(struct hwspinlock_device *ban= k, struct device *dev, spin_lock_init(&hwlock->lock); hwlock->bank =3D bank; =20 + if (ops->init_priv) { + hwlock->priv =3D ops->init_priv(i, init_data); + if (IS_ERR(hwlock->priv)) { + ret =3D PTR_ERR(hwlock->priv); + goto reg_failed; + } + } + ret =3D hwspin_lock_register_single(hwlock, base_id + i); if (ret) goto reg_failed; @@ -633,6 +643,7 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device + * @init_data: additional data passed on to the init_priv callback * * This function should be called from the underlying platform-specific * implementation, to register a new hwspinlock device instance. @@ -644,7 +655,7 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); int devm_hwspin_lock_register(struct device *dev, struct hwspinlock_device *bank, const struct hwspinlock_ops *ops, - int base_id, int num_locks) + int base_id, int num_locks, void *init_data) { struct hwspinlock_device **ptr; int ret; @@ -653,7 +664,7 @@ int devm_hwspin_lock_register(struct device *dev, if (!ptr) return -ENOMEM; =20 - ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks); + ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks, init_dat= a); if (!ret) { *ptr =3D bank; devres_add(dev, ptr); diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/= hwspinlock_internal.h index f298fc0ee5ad..3c835d96bf86 100644 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ b/drivers/hwspinlock/hwspinlock_internal.h @@ -18,20 +18,23 @@ struct hwspinlock_device; /** * struct hwspinlock_ops - platform-specific hwspinlock handlers * - * @trylock: make a single attempt to take the lock. returns 0 on - * failure and true on success. may _not_ sleep. - * @unlock: release the lock. always succeed. may _not_ sleep. - * @bust: optional, platform-specific bust handler, called by hwspinlock - * core to bust a specific lock. - * @relax: optional, platform-specific relax handler, called by hwspinlo= ck - * core while spinning on a lock, between two successive - * invocations of @trylock. may _not_ sleep. + * @trylock: make a single attempt to take the lock. returns 0 on + * failure and true on success. may _not_ sleep. + * @unlock: release the lock. always succeed. may _not_ sleep. + * @bust: optional, platform-specific bust handler, called by hwspinlock + * core to bust a specific lock. + * @relax: optional, platform-specific relax handler, called by hwspinlock + * core while spinning on a lock, between two successive + * invocations of @trylock. may _not_ sleep. + * @init_priv: optional, callback used when registering the hwspinlock dev= ice. + * Its return value will be used to fill the per-lock 'priv' data. */ struct hwspinlock_ops { int (*trylock)(struct hwspinlock *lock); void (*unlock)(struct hwspinlock *lock); int (*bust)(struct hwspinlock *lock, unsigned int id); void (*relax)(struct hwspinlock *lock); + void *(*init_priv)(int local_id, void *init_data); }; =20 /** diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 5bf0061d3fd6..adff502bcbc4 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -120,7 +120,7 @@ static int omap_hwspinlock_probe(struct platform_device= *pdev) bank->lock[i].priv =3D io_base + LOCK_BASE_OFFSET + sizeof(u32) * i; =20 return devm_hwspin_lock_register(&pdev->dev, bank, &omap_hwspinlock_ops, - base_id, num_locks); + base_id, num_locks, NULL); } =20 static const struct of_device_id omap_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom= _hwspinlock.c index 7ff89c3e8c6b..7960a4972eab 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -236,7 +236,7 @@ static int qcom_hwspinlock_probe(struct platform_device= *pdev) } =20 return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops, - 0, QCOM_MUTEX_NUM_LOCKS); + 0, QCOM_MUTEX_NUM_LOCKS, NULL); } =20 static struct platform_driver qcom_hwspinlock_driver =3D { diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0d08efbdfb07..0b91bdd4303d 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -132,7 +132,7 @@ static int sprd_hwspinlock_probe(struct platform_device= *pdev) =20 return devm_hwspin_lock_register(&pdev->dev, &sprd_hwlock->bank, &sprd_hwspinlock_ops, 0, - SPRD_HWLOCKS_NUM); + SPRD_HWLOCKS_NUM, NULL); } =20 static const struct of_device_id sprd_hwspinlock_of_match[] =3D { diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 1d75dc03f4ad..51e8e533ac31 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -110,7 +110,7 @@ static int stm32_hwspinlock_probe(struct platform_devic= e *pdev) hw->bank.lock[i].priv =3D io_base + i * sizeof(u32); =20 ret =3D devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops, - 0, STM32_MUTEX_NUM_LOCKS); + 0, STM32_MUTEX_NUM_LOCKS, NULL); =20 if (ret) dev_err(dev, "Failed to register hwspinlock\n"); diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index 8ff81cb5880a..a0c76bba3f05 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -180,7 +180,7 @@ static int sun6i_hwspinlock_probe(struct platform_devic= e *pdev) platform_set_drvdata(pdev, priv); =20 return devm_hwspin_lock_register(&pdev->dev, priv->bank, &sun6i_hwspinloc= k_ops, - SPINLOCK_BASE_ID, priv->nlocks); + SPINLOCK_BASE_ID, priv->nlocks, NULL); =20 bank_fail: clk_disable_unprepare(priv->ahb_clk); diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h index dffa1dff7289..094a6d0d39d6 100644 --- a/include/linux/hwspinlock.h +++ b/include/linux/hwspinlock.h @@ -30,7 +30,7 @@ struct hwspinlock_ops; void *hwspin_lock_get_priv(struct hwspinlock *hwlock); struct device *hwspin_lock_get_dev(struct hwspinlock *hwlock); int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks); + const struct hwspinlock_ops *ops, int base_id, int num_locks, void *init= _data); int hwspin_lock_unregister(struct hwspinlock_device *bank); struct hwspinlock *hwspin_lock_request_specific(unsigned int id); int hwspin_lock_free(struct hwspinlock *hwlock); @@ -49,7 +49,7 @@ int devm_hwspin_lock_unregister(struct device *dev, int devm_hwspin_lock_register(struct device *dev, struct hwspinlock_device *bank, const struct hwspinlock_ops *ops, - int base_id, int num_locks); + int base_id, int num_locks, void *init_data); =20 #else /* !CONFIG_HWSPINLOCK */ =20 --=20 2.51.0 From nobody Thu Apr 9 17:59:31 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 8F545384257 for ; Tue, 3 Mar 2026 19:31:49 +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=1772566311; cv=none; b=kiMjBLRKXGOzMqHqkBkh3QSYVx4EPZkpsmIjjllZBCKABjTy6BJDLabGLOydeDQrVT7U9lKSibNDZJjzCqzEwGCRZCUe+SUli4WPtu3DHe5ngULF8aOIRZWHoax9yQUkEAGm/JmSzbEw5IgrkhzbW/his7/frnzaEs4INId86E4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566311; c=relaxed/simple; bh=NQhzFPnhvDT7H608lK0YkvhIe1Wnm9jDBN/Mog6YZ14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FAnlbpm5VgXAjI2VUx5DMN/1lV/wxb+WAV/sPK7fBwvz4dUmTxhXQpioZPBQcfLuORJu4ybdivEMIx2BtRiACVBROFyMt1pLNV4prQCO2kgE10RvKEjQ+bcw0RrJe0uQA5QKGbIiDuG2uMAd0cA6vKzxFH3fBMeYy/X9oL/Kecc= 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=QCmgyaIa; 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="QCmgyaIa" 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=wuaGGcGzaS2IaPKApvffnT5mOe0N/0OwbJ4Ny2ad2Jk=; b=QCmgya Ia7SPftQYeGZRtCywsLDZCStg0epZjfFPXHw22CYNiY8hE9JRwb66VlX90hyTnqt lREZiCC9SsBaZcWtdFlUqnKkTtkRqO4t8FUpA+EK/yPnc7RIMfqW1HZb4qRqBrzZ Mv/zWriCmKsfXDYrIndXHwzCstrEuR6M6YXWGVeQwdkVMQtTTWpEM++v7PzlYkMM /y0OLTgoz/HybGsgPLkpFQNaBMc0+migmvddco2fvxY8g+wlcTE0lX7lkmx7WDTf ygdbovs9Zui6044sQ0ZiDh6HhIqXo75lHOc/5hJz+k0cN8rYnYuQngS4CqJ+F13y 0HMSvkoM1N8f4m2g== Received: (qmail 430566 invoked from network); 3 Mar 2026 20:31:31 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:31 +0100 X-UD-Smtp-Session: l3s3148p1@zAMewCNMTpEujnu+ 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 v3 05/15] hwspinlock: omap: use new callback to initialize hwspinlock priv Date: Tue, 3 Mar 2026 20:25:57 +0100 Message-ID: <20260303192600.7224-22-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index adff502bcbc4..9a9cb3692348 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -66,10 +66,18 @@ static void omap_hwspinlock_relax(struct hwspinlock *lo= ck) ndelay(50); } =20 +static void *omap_hwspinlock_init_priv(int local_id, void *init_data) +{ + void __iomem *io_base_ofs =3D init_data; + + return io_base_ofs + 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 +124,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 Thu Apr 9 17:59:31 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 3502536C9EA for ; Tue, 3 Mar 2026 19:31:50 +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=1772566312; cv=none; b=GLHSQ+Fwjl2t0BklLx3Av6tonaayJ4wNVgLqlzxNFNtR7igts/hl2psr/4xrptliBOdoIkDZkWn3fWwuNJJrJDJqNEQ0EgdS7/3mnCILa/8Y7ilLyDhRQrcWmS94K0ZMcogKTY2Y1yUSRQY90kTyOrqLD4l/yZxFf2iIzq5mzWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566312; c=relaxed/simple; bh=/1cbgksQYnpQdqsuiaDN8CTqGmtGzHh2xs447+54z6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MEU9BCxt5sJ6MFwtHDdypYWHrBnobzg1LypmgDWyl+FWcU5fO8SxqvlCl6p7SJ4AQoWWQ/0Qc3iRSBBYmtsWQFTygIwSQtCsWwmdv9jo7GA8KDTaeMtXVSeyBj2kLxG6tmVRfMabcUgcw1CDDaKL1v9JKeWbUDSNjpFbLqBSQrI= 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=R+if6qCr; 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="R+if6qCr" 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=BkzS5MMTcRUoTLKVBHcqxBVibx16YDc4gVsxZLobojk=; b=R+if6q CrnQuj5/h6Wp3xxa5QgaO7d/8TM00nyMgAUaZ8eth16mBelf4GR9/LTioDwOhGo1 VaI+bkpg93+3ecthYGheqNak9SlCLTSDh9ZndX39N1alVGkyr+ZLh1g9+uft+sdj H2us7u99ZNlWsl9Pqr67TbqZEXx4VzEN809PIAh76LDLUBPiC3f90uvTcBrRP910 isIwlwC2g42Pmyw8T7+y9/sw57K2R8ttLoBUwq0W+P+ke8STcoGnNyrRVZXIDCKM WYE4qgEbtxj4lNo1FfVKJLRstfhTrYG4QV54wCt6COdEotBA3lFOGmHCUZRpnWk0 P5b1bPwf6FdziPNg== Received: (qmail 430583 invoked from network); 3 Mar 2026 20:31:32 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:32 +0100 X-UD-Smtp-Session: l3s3148p1@HvsqwCNMUpEujnu+ From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Bjorn Andersson , Baolin Wang , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org Subject: [PATCH v3 06/15] hwspinlock: qcom: use new callback to initialize hwspinlock priv Date: Tue, 3 Mar 2026 20:25:58 +0100 Message-ID: <20260303192600.7224-23-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 Thu Apr 9 17:59:31 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 D10A43890F1 for ; Tue, 3 Mar 2026 19:31:51 +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=1772566313; cv=none; b=d3nGeZyC0lSgAh+FouQ+0vnDNhvbMnVqQHC3aT+N3CCWp6GMeYee6VcyrylsI1dVfJdaJqv6fb17lhCFLRmI3kaZDKtbQeTtRV3MYpYlgvIOEM7e/ZlZlo0D9KyV4M4OS3BNjJQmLs5/Soqubegaq/Wpca8x5IMaZdJ9khiAepw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566313; c=relaxed/simple; bh=BOJUADIyKNQOmgmPGc3taoNmpZ8OTIDAPRRqTVBjSXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdPMR4sit3FhDfW65y0UOOdSzkEQrGHvsYDzBb3YXmularPdB3j0QVIeWGTJlnlAJ2qkDoTUPXwWxRkRpwPwsn5fEOKGmdoPxK+6L4+Q9+7U4Mc3EFK3N7mLVZYMYAFTLCxRHghHXZoj7wVqqoo40tJKmyr5K79R7xZFrOEDh/A= 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=KCtbvHhe; 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="KCtbvHhe" 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=zX4JfdCplWngZzhZKUpZWK0F/ozfzqmnLJfc+peLwlY=; b=KCtbvH heog8LKaSsbCXiEWtCEvVeJZ05+9LlMVbn76yt/wlQxA7utnWIReHDgGPWPH6yhD qJ7DX4hkQsG0ViC0hx0zzeUYSlazDjbfN+wjx+V81gts0oaEFIchmd+g42HdFLrB AwhOKLA3ikUvnATPlqAkYT0k7LvRd4q8IuAuehPAviTtTL9MH5QjviI03HDjCSju XDgcWJA1BJXObl8tEnd5LUGimc3zl8zBTJ09f1f7efod4xutep3NolyFyFBY6QKp hKHz4Ua2ZP1m7HqfO2AFb6aXag3LQ6dwCOQIImd7EtZ7Kv9YRHf4VMl9sCqNg445 aEZg7E6Tf2MRhLmQ== Received: (qmail 430606 invoked from network); 3 Mar 2026 20:31:32 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:32 +0100 X-UD-Smtp-Session: l3s3148p1@Hj82wCNMWJEujnu+ 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 v3 07/15] hwspinlock: sprd: use new callback to initialize hwspinlock priv Date: Tue, 3 Mar 2026 20:25:59 +0100 Message-ID: <20260303192600.7224-24-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd= _hwspinlock.c index 0b91bdd4303d..c19b680d5fdf 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -70,10 +70,18 @@ static void sprd_hwspinlock_relax(struct hwspinlock *lo= ck) ndelay(10); } =20 +static void *sprd_hwspinlock_init_priv(int local_id, void *init_data) +{ + void __iomem *base =3D init_data; + + return base + 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 +94,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 +130,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 Thu Apr 9 17:59:31 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 DC912389112 for ; Tue, 3 Mar 2026 19:31:52 +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=1772566314; cv=none; b=e+Mvnv1gzsGaQIkkxH0jcevuqqafEFoy8EoO4FpDBFkTO/mN+pbj1yq0bTPXZpLDiOXpIVWICnyGJaqSxdK49HIkRXolt0VuIFRAYpGT7COBtRfFJprZrn45wuqmP1HCz5fa7Ld68dObLUPluOMZA4x80XfgmdBFyKboj49M2EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566314; c=relaxed/simple; bh=OEH3l5ojWMA/OYyQO8879NCGmmk7Y1mf0kCu8Rq9dKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u1dhhKAooJyh1RRPDPD9ALH3YS+cWomHHlY0g97/W9UWpZMLxUmL8qv5qc4XIBVRy/OQoU4SsEAOYOdcD9GkEO4mpuYqVyMKa+Tnaww4BTrOzNJGm65Dzqux3U4mbmOYv8rwFw128kAj/+boScLJF+HLJqaVugoOxMBZ/SeXwlo= 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=GlweQzJj; 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="GlweQzJj" 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=cfGSgS8xrxtvLo0CzFzbdSrdEtwKeD6q3V5u52qRc1c=; b=GlweQz JjdFgbqgnM2YRaAN5ErA6fIuURTabWOa24CkwbYjc5tIRsY7dr/j6VhKtIgh/l7L 4aFrb4PMC1lii+YahXo6k1wGeqb1U9ljT0o05f2PsVHIq7ce3sWleRBCheM+Co94 rnIbjIijw9UEgrhW8XqFeE8eHKt+6sU7e8zYFoQMul9ymADPeUycXpB0rGt+vbU0 ng3wm+c1u4Vzu+5zu7D9nHyIoiOFOBCN6CMcIjpOgZFuk+Ce+q4d4AmvnmkR0PR/ QvymOOG3C7L18XqeSnR0bJQ1jS6hb7lmUcBYvsrgTeeJijAyT9PfYHlNfLd1nCBB IEkioe+nOrK7jSlQ== Received: (qmail 430629 invoked from network); 3 Mar 2026 20:31:33 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:33 +0100 X-UD-Smtp-Session: l3s3148p1@N2BFwCNMXpEujnu+ 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 v3 08/15] hwspinlock: stm32: use new callback to initialize hwspinlock priv Date: Tue, 3 Mar 2026 20:26:00 +0100 Message-ID: <20260303192600.7224-25-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm= 32_hwspinlock.c index 51e8e533ac31..02db950c9450 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -48,10 +48,18 @@ static void stm32_hwspinlock_relax(struct hwspinlock *l= ock) ndelay(50); } =20 +static void *stm32_hwspinlock_init_priv(int local_id, void *init_data) +{ + void __iomem *io_base =3D init_data; + + return io_base + 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 +81,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 +114,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 Thu Apr 9 17:59:31 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 95FDA38911A for ; Tue, 3 Mar 2026 19:31:53 +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=1772566315; cv=none; b=GHXOTLsASdlqMHnJQYni9f3BK9DQqBZ1+JcB+++XMbbF4oJTcW7sGe+ih30Cqlik1PL4T9/NaU4AiPDRH3/IF4GxpFIkUbh2sW33eLQdHiu9SWFd1j5kG+Jsqk0juweFSmtjde5KFNWG5BSLiZtTMgK2+kyBgHnTAMsrXk0rvt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566315; c=relaxed/simple; bh=vQS9LYcAzje+MMpRYEd6nRDdwiMOA9YItnDfriXH1aw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YKTOi+bvJhGxAim+YWNXtqwtXbtXrmhq5Yv5dHpCQ+c5GJ7MNWCTU2FyXyeU9xQ3N7hE3FpmavwrIJtlnEDrvAZGM5T3QflPDRyyRzSaKy72KKc3aXOm4fcGfargQNx6hxd8EHg4rFMonRBQfaYHaZMIxjgQtCqac2eVsRs+cO4= 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=B/ZGnjC3; 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="B/ZGnjC3" 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=E+W3aoDhRerxB8MlZR6L5l3+W5MIlzwxE6xhU7iwtJA=; b=B/ZGnj C3l+XhjK3COy5XM3TUIW+1V7TKWUYJg0j0Q3wBPwFk3gcPOe5YCdf8IG0pZuicUA lLjX4jsBDeAVsRX31fza3w11z3ZShkhatmIvnpPsSXtZHLlBs/xmB6jwjdMHo3Za BKIOAI8e2yw8j8a0P3r8WI1D+C1zfYnJF+vufTeLceqyBGwAx3UE3wXks+2Vim2g CgIU7dxNZjeSCO8Rk0eXHJvI5WvAm8inrmD1AX4BkM6Qh/iT9a6zH/OoOXOcFJ13 CHAWCkgtsuWssssgjoOAidleQMczZ/29pfpywgRZqoHOukMS9JjDovNXOMK3PnzQ brLl3yR5VJw54uqQ== Received: (qmail 430645 invoked from network); 3 Mar 2026 20:31:34 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:34 +0100 X-UD-Smtp-Session: l3s3148p1@DwhUwCNMZJEujnu+ From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Wilken Gottwalt , Bjorn Andersson , Baolin Wang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v3 09/15] hwspinlock: sun6i: use new callback to initialize hwspinlock priv Date: Tue, 3 Mar 2026 20:26:01 +0100 Message-ID: <20260303192600.7224-26-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun= 6i_hwspinlock.c index a0c76bba3f05..7d0c639c0e82 100644 --- a/drivers/hwspinlock/sun6i_hwspinlock.c +++ b/drivers/hwspinlock/sun6i_hwspinlock.c @@ -74,9 +74,17 @@ 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) +{ + void __iomem *io_base_ofs =3D init_data; + + return io_base_ofs + 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 +99,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 +168,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 +179,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 Thu Apr 9 17:59:31 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 58F3B3BA24D for ; Tue, 3 Mar 2026 19:31:55 +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=1772566317; cv=none; b=KtiNbuhXa3m1aGkwFqhyit64mLNtj91zGBDl0Pi0JuPISgWks1fOIB+jSuhYUzR9jaFQ6/YPqRzUJ2XWE2j6KJ/Hbvq+FH/NQ99ZUF7dLoMcQiVb/rR69qRExemtZwPEAifgJvtcJtSROY05xOItvzEXTXfpTpVQ5clWTYvWJPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566317; c=relaxed/simple; bh=M9jwiFFUyTVXmINlqXJUjONm52xyGmsK0AqCY77SlvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rXxIzkMsrKiA/w7eydNJTO5K8HdXFG5UjTRIJU5oK6H3WbpX7HBW6BhBfI1JZq0SqACUduC+Gaq+94Wq68woHtLvmikU8OtAT4MlUIMIPvWLuIvzDWL5cC0wn0zJxPRluEdV0dz+UPSdK4NRwdFGmVS3DlDgHfhXtltv9lvEWR8= 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=ZCRzfeAz; 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="ZCRzfeAz" 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=ebCf8IAGgl2B/372c2QLceVUsgeqo2XZMEmzfMHhLb4=; b=ZCRzfe Az7BcOskJ6h86VIh1046EhU39Q6BylqcF7SEkWEEJJ6CFJ6YGnLX2IqQkZ6qEswZ DKKeGO4oq9nFoVboml56z7f+JYDLktlvl4SpPxlo3m3Z8SI91Af0jx78CZiUGMT3 XhZSeojpBLgoJV8V0MJt/llzR73GNjwN3e5PUA7atk3HxZpGbLhKeK/gQs3CT2om P36tQsJYVCWL7f9t0onpDB/9kAhFSfZ3tf+l4T6obksXSYBvXEzmGPMBgh+1HyoG 814gsvHJByGHfIR1NX0gDzQ7r+RPoBM2VVfakGxbWmCHFWhGWGZQ1eQaELeuxAl4 XAAmhun4SUMm7IAA== Received: (qmail 430669 invoked from network); 3 Mar 2026 20:31:36 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:36 +0100 X-UD-Smtp-Session: l3s3148p1@LwdrwCNMbpEujnu+ 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 v3 10/15] hwspinlock: handle hwspinlock device allocation in the core Date: Tue, 3 Mar 2026 20:26:02 +0100 Message-ID: <20260303192600.7224-27-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Providers have been refactored to avoid using core internal structures. As a result, they do not need to allocate the hwspinlock device on their own anymore because they can access everything they need with helpers. So, the allocation is moved to the core. As a result, the registering functions now return a pointer to the (soon) opaque hwspinlock device which may be needed for unregistering only. Because the argument list of the registering functions is changed, all users are changed here as well. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 48 +++++++++++++++------------ drivers/hwspinlock/omap_hwspinlock.c | 10 ++---- drivers/hwspinlock/qcom_hwspinlock.c | 11 ++---- drivers/hwspinlock/sprd_hwspinlock.c | 17 ++++------ drivers/hwspinlock/stm32_hwspinlock.c | 7 ++-- drivers/hwspinlock/sun6i_hwspinlock.c | 12 ++----- include/linux/hwspinlock.h | 17 ++++++---- 7 files changed, 52 insertions(+), 70 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index afe1e7ce2829..a7610ba755b4 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include "hwspinlock_internal.h" =20 @@ -502,7 +503,6 @@ static struct hwspinlock *hwspin_lock_unregister_single= (unsigned int id) =20 /** * hwspin_lock_register() - register a new hw spinlock device - * @bank: the hwspinlock device, which usually provides numerous hw locks * @dev: the backing device * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank @@ -514,21 +514,25 @@ static struct hwspinlock *hwspin_lock_unregister_sing= le(unsigned int id) * * Should be called from a process context (might sleep) * - * Returns: %0 on success, or an appropriate error code on failure + * Returns: a pointer to the device (needed for unregistering), or an + * appropriate error pointer on failure */ -int hwspin_lock_register(struct hwspinlock_device *bank, struct device *de= v, - const struct hwspinlock_ops *ops, int base_id, int num_locks, - void *init_data) +struct hwspinlock_device *hwspin_lock_register(struct device *dev, const s= truct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data) { + struct hwspinlock_device *bank; struct hwspinlock *hwlock; int ret, i; =20 - if (!bank || !ops || !dev || !num_locks || !ops->trylock || - !ops->unlock) { + if (!ops || !dev || !num_locks || !ops->trylock || !ops->unlock) { pr_err("invalid parameters\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } =20 + bank =3D kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL); + if (!bank) + return ERR_PTR(-ENOMEM); + bank->dev =3D dev; bank->ops =3D ops; bank->base_id =3D base_id; @@ -553,12 +557,13 @@ int hwspin_lock_register(struct hwspinlock_device *ba= nk, struct device *dev, goto reg_failed; } =20 - return 0; + return bank; =20 reg_failed: while (--i >=3D 0) hwspin_lock_unregister_single(base_id + i); - return ret; + kfree(bank); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(hwspin_lock_register); =20 @@ -589,6 +594,8 @@ int hwspin_lock_unregister(struct hwspinlock_device *ba= nk) WARN_ON(tmp !=3D hwlock); } =20 + kfree(bank); + return 0; } EXPORT_SYMBOL_GPL(hwspin_lock_unregister); @@ -639,7 +646,6 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * devm_hwspin_lock_register() - register a new hw spinlock device for * a managed device * @dev: the backing device - * @bank: the hwspinlock device, which usually provides numerous hw locks * @ops: hwspinlock handlers for this device * @base_id: id of the first hardware spinlock in this bank * @num_locks: number of hwspinlocks provided by this device @@ -650,29 +656,27 @@ EXPORT_SYMBOL_GPL(devm_hwspin_lock_unregister); * * Should be called from a process context (might sleep) * - * Returns: %0 on success, or an appropriate error code on failure + * Returns: a pointer to the device (usable for unregistering), or an + * appropriate error pointer on failure */ -int devm_hwspin_lock_register(struct device *dev, - struct hwspinlock_device *bank, - const struct hwspinlock_ops *ops, - int base_id, int num_locks, void *init_data) +struct hwspinlock_device *devm_hwspin_lock_register(struct device *dev, co= nst struct hwspinlock_ops *ops, + int base_id, int num_locks, void *init_data) { - struct hwspinlock_device **ptr; - int ret; + struct hwspinlock_device **ptr, *bank; =20 ptr =3D devres_alloc(devm_hwspin_lock_unreg, sizeof(*ptr), GFP_KERNEL); if (!ptr) - return -ENOMEM; + return ERR_PTR(-ENOMEM); =20 - ret =3D hwspin_lock_register(bank, dev, ops, base_id, num_locks, init_dat= a); - if (!ret) { + bank =3D hwspin_lock_register(dev, ops, base_id, num_locks, init_data); + if (!IS_ERR(bank)) { *ptr =3D bank; devres_add(dev, ptr); } else { devres_free(ptr); } =20 - return ret; + return bank; } EXPORT_SYMBOL_GPL(devm_hwspin_lock_register); =20 diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index 9a9cb3692348..f1ff6406db46 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -82,7 +82,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 */ @@ -119,13 +118,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 c19b680d5fdf..95b254e9b6a0 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; } @@ -99,9 +97,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 @@ -132,9 +128,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 02db950c9450..a966e967dcdb 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) @@ -87,7 +86,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 @@ -114,8 +113,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 7d0c639c0e82..8e17deb503c7 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; @@ -161,13 +160,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)) @@ -179,8 +171,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 Thu Apr 9 17:59:31 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 A70E348A2A4 for ; Tue, 3 Mar 2026 19:31:57 +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=1772566320; cv=none; b=lRubz8IOyQhLQrnCKsdchO7RJTRBoBTDSYhdSA4HQbuh8pk9FdSR3iRloRDQKLu2yhce3EPFtwpc0dzGrmLapKrHEh41eWZECPL608Xi1WKvUwcGsN4gyVy0lpr3XUjp5QjtkkbqqUstC43B7bXWIhomI8tj5pxJoaKlrP73aHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566320; c=relaxed/simple; bh=uzc3fyoi8FSR6bwgllT3vuutQc1YoByfPGRM76QKxto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iYE00KDef3r+u7dn/zagpWqANIks8KL7JVOyeC6m+dXVoB7TYibUb2IJDBWrU08zCBSL46HOMQhk5/89i0N9HGPAidhsTKWpMQyyE1TDaoOKY6v8+QudP89p3tNeFlEvSTpBZvwC0SGv4eotsyav14z/3oF3zdHix2FOc/d3JaE= 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=AgMxdyKn; 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="AgMxdyKn" 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=huat1Y/wJ/zb768/t+yGa5XgKV25MRf5vTJTHiQcbnY=; b=AgMxdy KnDr6M+97zchJTQOZmBtEyKGpf5Kwm/4G1kAzt3yez5fujjTuGyc8mCPpmJDOOuv uHkdw3H0FNHIvVuEBk3EWKlStqQbVdi2w9rjOiVTD5N7S3S5tFsDH5i0zW6u075I J7/DBeBNqJoWAvuoV5KvVYImcWcmuA0AkEY6gLzaeaw0QncLREXWMoQVib84PKm5 aPnvhDw6Gj05D2vshFEhXKnCfoumEF/1Ar1yrUXUbipqKXY83RpJ50HLJ/dylQrM 02ktwynLlcTysaGvvOfZN9iUfxgp7BjH7XHP6XDLAfS8DpPm/jddxV5ic/zUJSgw NtYnip+yGb8exfBw== Received: (qmail 430691 invoked from network); 3 Mar 2026 20:31:37 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:37 +0100 X-UD-Smtp-Session: l3s3148p1@V9eCwCNMJKgujnu+ 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 v3 11/15] hwspinlock: move entries from internal to public header Date: Tue, 3 Mar 2026 20:26:03 +0100 Message-ID: <20260303192600.7224-28-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Providers need the ops-structure and the hwlock_to_id-function. Move these entries to the public header. With this change, all providers are also updated to use the public header only. The internal header is now used by the core only. Signed-off-by: Wolfram Sang --- drivers/hwspinlock/hwspinlock_core.c | 8 +++++++ drivers/hwspinlock/hwspinlock_internal.h | 29 ------------------------ drivers/hwspinlock/omap_hwspinlock.c | 2 -- drivers/hwspinlock/qcom_hwspinlock.c | 2 -- drivers/hwspinlock/sprd_hwspinlock.c | 2 -- drivers/hwspinlock/stm32_hwspinlock.c | 2 -- drivers/hwspinlock/sun6i_hwspinlock.c | 2 -- include/linux/hwspinlock.h | 23 +++++++++++++++++++ 8 files changed, 31 insertions(+), 39 deletions(-) diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwsp= inlock_core.c index a7610ba755b4..e0227d027cf2 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -915,5 +915,13 @@ struct device *hwspin_lock_get_dev(struct hwspinlock *= hwlock) } EXPORT_SYMBOL_GPL(hwspin_lock_get_dev); =20 +int hwlock_to_id(struct hwspinlock *hwlock) +{ + int local_id =3D hwlock - &hwlock->bank->lock[0]; + + return hwlock->bank->base_id + local_id; +} +EXPORT_SYMBOL_GPL(hwlock_to_id); + MODULE_DESCRIPTION("Hardware spinlock interface"); MODULE_AUTHOR("Ohad Ben-Cohen "); diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/= hwspinlock_internal.h index 3c835d96bf86..20ae531fc389 100644 --- a/drivers/hwspinlock/hwspinlock_internal.h +++ b/drivers/hwspinlock/hwspinlock_internal.h @@ -15,28 +15,6 @@ =20 struct hwspinlock_device; =20 -/** - * struct hwspinlock_ops - platform-specific hwspinlock handlers - * - * @trylock: make a single attempt to take the lock. returns 0 on - * failure and true on success. may _not_ sleep. - * @unlock: release the lock. always succeed. may _not_ sleep. - * @bust: optional, platform-specific bust handler, called by hwspinlock - * core to bust a specific lock. - * @relax: optional, platform-specific relax handler, called by hwspinlock - * core while spinning on a lock, between two successive - * invocations of @trylock. may _not_ sleep. - * @init_priv: optional, callback used when registering the hwspinlock dev= ice. - * Its return value will be used to fill the per-lock 'priv' data. - */ -struct hwspinlock_ops { - int (*trylock)(struct hwspinlock *lock); - void (*unlock)(struct hwspinlock *lock); - int (*bust)(struct hwspinlock *lock, unsigned int id); - void (*relax)(struct hwspinlock *lock); - void *(*init_priv)(int local_id, void *init_data); -}; - /** * struct hwspinlock - this struct represents a single hwspinlock instance * @bank: the hwspinlock_device structure which owns this lock @@ -65,11 +43,4 @@ struct hwspinlock_device { struct hwspinlock lock[]; }; =20 -static inline int hwlock_to_id(struct hwspinlock *hwlock) -{ - int local_id =3D hwlock - &hwlock->bank->lock[0]; - - return hwlock->bank->base_id + local_id; -} - #endif /* __HWSPINLOCK_HWSPINLOCK_H */ diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap= _hwspinlock.c index f1ff6406db46..96fdc35ef642 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 95b254e9b6a0..d2aa4714e2ea 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 a966e967dcdb..08762cd96cee 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 8e17deb503c7..5c6d20eb24b5 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 Thu Apr 9 17:59:31 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 5510F4E378A for ; Tue, 3 Mar 2026 19:32:00 +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=1772566322; cv=none; b=JCZuDR2Bl2a4NCRysiBlhQkMbfwpmN3tc3UlFUjCHY0VKsR5zfdqNZcnCnyKI8N0SIWABwJU7OGAQOz6dc8LA/sQ5KMbvOEGCRGNhBXmm/3gSPAD+uzv0Ougre9PoZgLRe0aghhUJMtI+5nFayl2EbkksWlddZC3E8cL2bm9B0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566322; c=relaxed/simple; bh=2qHwj1Hj7wC4HlI3asFHikIH7wRdg857kdR/tWd/T/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jfqO38SYC/bZUpfOgLj8gsI35iZNH3RWb7eH+RchALTTgFllgeex5cZPPMjpk+qpoNT0ft0c1efceGcfugSEYMB8hdz7HPQQpBz+VpYg83JPgr4sM9zgBLVzuEBkVubasaQlUuuHxsxckSfOajaLu4lU4Hv6dRz6LtWEnv5e6H0= 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=HPRAyBY5; 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="HPRAyBY5" 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=HPRAyB Y5knlcukRBTxPmP55OQGFjqv9Szw1o5uyVZAi1EaD0AwbM0JvUe0Nb3HBYKiiYm1 RZuGNNZzn83iwAu0nWTd3vb/eBwRfFttSPw3r9pQ+p2LqmQF9EV4tqSpiJECCDl3 DPSZstDrL5nQAdW2LMlgcdL0FgmI8v0F9jA7mb9sv/+t0tv6J+wpGw6qhPQVI2z8 jUZQpZvcA3VmahBaaSWvrJVydkhAeNVii927d9N2xOl9c1tvXznvesxhmnmoPpL6 BFNzLjqvn0KVlnSmLjlS+n/McaYBBIDCBlC01ZWmJ3G5meh/U91TZg8YP8Sf7+uS XlDbPGBAFKsVGDWg== Received: (qmail 430709 invoked from network); 3 Mar 2026 20:31:38 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:38 +0100 X-UD-Smtp-Session: l3s3148p1@fjSSwCNMMKgujnu+ 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 v3 12/15] hwspinlock: remove internal header Date: Tue, 3 Mar 2026 20:26:04 +0100 Message-ID: <20260303192600.7224-29-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 Thu Apr 9 17:59:31 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 02DC64F7981 for ; Tue, 3 Mar 2026 19:32:00 +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=1772566322; cv=none; b=dvSyoGgwupvEbctjIkeZw0NsIodfOUyYghx7orWOyzbnA6VAsfsMdMkXfqZUSAiZwwcmplil14VYugSvAJwjteerf1pMMvXCYB8/ApBAY/RQfiT/Bgg6hSS7plKJ5oZ37YReN/D3loUFjyOT8GSpUya9LXqUR4Hs7my+zQy6WRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566322; c=relaxed/simple; bh=cGbDtwydlJZBcEqlFjz378ZiockJrW9wvEor5EyRyG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NfnPM5Gfmvakl8bEBzC95ofpVhShPpCgBJFWJBeBqTp/wANILB30TBtmzxnRRHd9t8F9dUQXUWs4b/92Kn6lk970NzWabX4i9BIvwoigjDg8yM3pLPhZkcgg6WJQDzzCRrtdGpcyu1TmxkQXglye3+TIyfnF1KeNoDKkOUQ25no= 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=A4hk2ueJ; 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="A4hk2ueJ" 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=A4hk2u eJNs/5lrPPTqohOJOkFBK0Klr5nmh16C4bWwhqYA5Awmqn0+wmfI08B2GcK9RxiD Fzga4KgU3LsAZxaC7tY28EJ2jte7T0YUa5rSM6oaij34RrZ6URllRaMKLEqhwvbS OMtkWFbmKPB+3eaF6paVZmRkQQdYtsTdJ3PN3Gzu1Bu1SJAjdcAyUTwUSd9ibYuG VOMLsVDPR7d9Y724VuKimxIBw6Nw76aZdilkdIGi04FxTg5pOpQ+dTNLE7SiN5d2 457pdW7deHGjHsrRMO8A4j3vDpusrSz8ODH68WlXp09ZKfqDw3poucni6jdUcf+C MW4Nc+MgCfp9wNLQ== Received: (qmail 430756 invoked from network); 3 Mar 2026 20:31:39 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:39 +0100 X-UD-Smtp-Session: l3s3148p1@37udwCNMPqgujnu+ 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 v3 13/15] hwspinlock: sort include and update copyright Date: Tue, 3 Mar 2026 20:26:05 +0100 Message-ID: <20260303192600.7224-30-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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 Thu Apr 9 17:59:31 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 B92AF397F8C for ; Tue, 3 Mar 2026 19:32:01 +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=1772566324; cv=none; b=BCN4cswEsimVPU6BN7ep+H7YCpygDDyfu9QlRM13XofB66r4i56z44JYCDWoJCxAjsXOzZog5Y3mESSDEuNGq/cgrbvNq/bO/5xCukCcCaHv3TbFXJ8yaXzdja0jq9d+J436FQZFVPoL55fAeV+FC/LpJq7uhOIUaFnj4UaQebA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566324; c=relaxed/simple; bh=CMEMA/jUchVe1HBb8fOTDUiDC+B6BR4ggGFWb5lwEgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CHF/2WAP6TDxYzTE9Gwp90KpCvnWEMkDJLaG2ujyVaCQDBUo7T4QCLWaDcBZhR3Z0xDSQFiM2zJhEwOrUZ6rm+GY4dWDBaiXzPgrJ0JOxzIVzeolMN1uQjIfR8JHoLfqw5YaCK26VKuvmGiv+TxqcefNOrv57yDTClxKDcTKdN0= 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=ZHoHeDLa; 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="ZHoHeDLa" 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=eZSTpzKDUIc2vRfE3Wkr3hk5q7loVov9yTUGLtbVCIE=; b=ZHoHeD LaNFIEPzgUNb7jPaYhPLxLZ8z3Kv3IHmL6E2nMPE6gfl4RoSUobYEcEfGy6GErxW JG/bm6oMWHGbGwfXxsKJdcqlWutQwccwhGo1Dulman9zT0wbNt66ofswJrVs6Eki pGqiNnEVGAakMhcKcRZ9aqDq2Y42Q6tCNqeSHIKpjgZHpM2B7J7p2MpAgYqGTe6F hGnuGZEARs2R+sjsO1xy/BqzRfiILXhNpdR80+YWDKFRZLdGaSlvlknPe5iO2zBL UsiBiMCkD0U3wh3ka4U4+LWb2cK1+lXEm5H8sjLcnqYYU0cZ9TgHj9rapvlrERdC 1ozFnV2lzVFyygCw== Received: (qmail 430845 invoked from network); 3 Mar 2026 20:31:41 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:41 +0100 X-UD-Smtp-Session: l3s3148p1@Y364wCNMTqgujnu+ 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 v3 14/15] hwspinlock: refactor provider.h from public header Date: Tue, 3 Mar 2026 20:26:06 +0100 Message-ID: <20260303192600.7224-31-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Factor out the entries only needed for providers from the generic public header. This allows for a clean separation between providers and consumers. All providers are in the hwspinlock subsystem currently and are trivially converted here as well. Signed-off-by: Wolfram Sang --- MAINTAINERS | 1 + drivers/hwspinlock/hwspinlock_core.c | 1 + drivers/hwspinlock/omap_hwspinlock.c | 2 +- drivers/hwspinlock/qcom_hwspinlock.c | 2 +- drivers/hwspinlock/sprd_hwspinlock.c | 2 +- drivers/hwspinlock/stm32_hwspinlock.c | 2 +- drivers/hwspinlock/sun6i_hwspinlock.c | 2 +- include/linux/hwspinlock.h | 44 -------------------- include/linux/hwspinlock/provider.h | 60 +++++++++++++++++++++++++++ 9 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 include/linux/hwspinlock/provider.h diff --git a/MAINTAINERS b/MAINTAINERS index b4cb7a63e800..4e95cbb48dd8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11215,6 +11215,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 96fdc35ef642..338ae9fa89f0 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 d2aa4714e2ea..f6014b314432 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 08762cd96cee..a22ebabe1921 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 5c6d20eb24b5..4dab91800745 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 Thu Apr 9 17:59:31 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 770713BA24D for ; Tue, 3 Mar 2026 19:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566326; cv=none; b=oPl1IxkvMWZyn07cOPMI/zqcTb63MZBrrBiQQD0SRqS9v57NVHUMjr4Gv1BVrbr2YvlUiFtDCnE5yKCtqYz/yTXYADxh9TXQo2YG8LdBeHI1Z2uQPr2VvSatSUP/qtwXBbT955iZNUdWHhgDOaSXci2rwgNGqcTfWDcFBp5amcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772566326; c=relaxed/simple; bh=Gf5eeNAe7Cr11h709c9BHil3kb9/QlMdiA0MqCeCitE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kJIvDv7KXVek8JlJjfrpPMnmM9jG3lBjuhsJftXgOA47TXEJJjbS226hOZq1bl3ynie9B+WD/LXvjlngYP3+D7KUH1R75t2sUhHiqDnI49FDj66dtIzI/7MO8RhBa9LOvbFxrkCaKw/VQDQ16FoyBl4WDh2Oc5GQeNouRPto88U= 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=cw10SYVS; 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="cw10SYVS" 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=j/Bo7yrFMAchCRfI3p9FgYu/8TRsrIClVI/vqJrM62s=; b=cw10SY VSDDBIMncjsw9I85vcm2bgHLq7GMJJRqXG4XOCLpKthxayrGp0paHslau+AHGd1s dR41SlnooKWBRS8WQoeERXhsFMeKBFnUJHbpmo0xuvwX11+tn20s+k0HMLsgSdLY xjO7f7YY6NifLL67g3Pa2rMyTfIz/05/F4/m0Sa53CMoMzd260GMPJQiALXfCYOb aTFMxQa0XV8IO7FniitASuMiiUYnduYueiKjggYfTq83Ux53lIZcymTfSxrbz1bO Rk6viyJBLq9nz++IZTB+sXzV85siip/fIdJy0H5nZjq5esig8X24Hlkx9QtEe41R eAsC59fy2I51GD0A== Received: (qmail 430895 invoked from network); 3 Mar 2026 20:31:43 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Mar 2026 20:31:43 +0100 X-UD-Smtp-Session: l3s3148p1@/BzYwCNMXKgujnu+ From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wolfram Sang , Mark Brown , Jonathan Cameron , Bjorn Andersson , Baolin Wang , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Jonathan Corbet , Shuah Khan , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Orson Zhai , Chunyan Zhang , Thomas Gleixner , Maxime Coquelin , Alexandre Torgue , Lee Jones , Arnd Bergmann , Srinivas Kandagatla , Antonio Borneo , Linus Walleij , Konrad Dybcio , linux-remoteproc@vger.kernel.org, linux-doc@vger.kernel.org, driver-core@lists.linux.dev, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH v3 15/15] hwspinlock/treewide: refactor consumer.h from public header Date: Tue, 3 Mar 2026 20:26:07 +0100 Message-ID: <20260303192600.7224-32-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260303192600.7224-17-wsa+renesas@sang-engineering.com> References: <20260303192600.7224-17-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: Greg Kroah-Hartman Acked-by: Lee Jones --- Documentation/locking/hwspinlock.rst | 2 +- MAINTAINERS | 1 - drivers/base/regmap/regmap.c | 2 +- drivers/hwspinlock/hwspinlock_core.c | 2 +- drivers/iio/adc/sc27xx_adc.c | 2 +- drivers/irqchip/irq-stm32mp-exti.c | 2 +- drivers/mfd/syscon.c | 2 +- drivers/nvmem/sc27xx-efuse.c | 2 +- drivers/nvmem/sprd-efuse.c | 2 +- drivers/pinctrl/stm32/pinctrl-stm32.c | 2 +- drivers/soc/qcom/smem.c | 2 +- drivers/spi/spi-sprd-adi.c | 2 +- .../linux/{hwspinlock.h =3D> hwspinlock/consumer.h} | 15 ++++++--------- 13 files changed, 17 insertions(+), 21 deletions(-) rename include/linux/{hwspinlock.h =3D> hwspinlock/consumer.h} (98%) diff --git a/Documentation/locking/hwspinlock.rst b/Documentation/locking/h= wspinlock.rst index a737c702a7d1..001bcab86690 100644 --- a/Documentation/locking/hwspinlock.rst +++ b/Documentation/locking/hwspinlock.rst @@ -306,7 +306,7 @@ Typical usage =20 :: =20 - #include + #include #include =20 int hwspinlock_example(void) diff --git a/MAINTAINERS b/MAINTAINERS index 4e95cbb48dd8..e1acfc1d6656 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11216,7 +11216,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