From f50607628192b7ad1828e811bba238993b9afd55 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 10 Feb 2025 14:19:30 +0800 Subject: [PATCH] [DM] Replace spinlock static init by RT_DEFINE_SPINLOCK Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/clk/clk.c | 2 +- components/drivers/core/bus.c | 2 +- components/drivers/core/dm.c | 2 +- components/drivers/dma/dma.c | 2 +- components/drivers/dma/dma_pool.c | 2 +- components/drivers/mailbox/mailbox.c | 2 +- components/drivers/mfd/mfd-syscon.c | 2 +- components/drivers/nvme/nvme.c | 2 +- components/drivers/ofw/base.c | 2 +- components/drivers/pci/endpoint/endpoint.c | 2 +- components/drivers/pci/msi/irq.c | 2 +- components/drivers/pic/pic-gic-common.c | 2 +- components/drivers/pic/pic-gicv2.c | 2 +- components/drivers/pic/pic-gicv3-its.c | 3 ++- components/drivers/pic/pic.c | 2 +- components/drivers/pin/dev_pin_dm.c | 2 +- components/drivers/regulator/regulator.c | 2 +- components/drivers/thermal/thermal.c | 2 +- 18 files changed, 19 insertions(+), 18 deletions(-) diff --git a/components/drivers/clk/clk.c b/components/drivers/clk/clk.c index 909130553e..ba87ad2914 100644 --- a/components/drivers/clk/clk.c +++ b/components/drivers/clk/clk.c @@ -26,7 +26,7 @@ #define DBG_LVL DBG_INFO #include -static struct rt_spinlock _clk_lock = { 0 }; +static RT_DEFINE_SPINLOCK(_clk_lock); static rt_list_t _clk_nodes = RT_LIST_OBJECT_INIT(_clk_nodes); static rt_list_t _clk_notifier_nodes = RT_LIST_OBJECT_INIT(_clk_notifier_nodes); diff --git a/components/drivers/core/bus.c b/components/drivers/core/bus.c index a1d6d7e7b5..72ff49628d 100644 --- a/components/drivers/core/bus.c +++ b/components/drivers/core/bus.c @@ -86,7 +86,7 @@ rt_err_t rt_device_bus_destroy(rt_device_t dev) #ifdef RT_USING_DM #include -static struct rt_spinlock bus_lock = {}; +static RT_DEFINE_SPINLOCK(bus_lock); static rt_list_t bus_nodes = RT_LIST_OBJECT_INIT(bus_nodes); static void _dm_bus_lock(struct rt_spinlock *spinlock) diff --git a/components/drivers/core/dm.c b/components/drivers/core/dm.c index 9d9f93f6ae..b11dd058e1 100644 --- a/components/drivers/core/dm.c +++ b/components/drivers/core/dm.c @@ -191,7 +191,7 @@ struct prefix_track int uid; const char *prefix; }; -static struct rt_spinlock _prefix_nodes_lock = { 0 }; +static RT_DEFINE_SPINLOCK(_prefix_nodes_lock); static rt_list_t _prefix_nodes = RT_LIST_OBJECT_INIT(_prefix_nodes); int rt_dm_dev_set_name_auto(rt_device_t dev, const char *prefix) diff --git a/components/drivers/dma/dma.c b/components/drivers/dma/dma.c index da2d80a866..36b6ffc50a 100644 --- a/components/drivers/dma/dma.c +++ b/components/drivers/dma/dma.c @@ -17,7 +17,7 @@ #include static rt_list_t dmac_nodes = RT_LIST_OBJECT_INIT(dmac_nodes); -static struct rt_spinlock dmac_nodes_lock = {}; +static RT_DEFINE_SPINLOCK(dmac_nodes_lock); rt_err_t rt_dma_controller_register(struct rt_dma_controller *ctrl) { diff --git a/components/drivers/dma/dma_pool.c b/components/drivers/dma/dma_pool.c index 8bd5291fc2..9f220d8c5a 100644 --- a/components/drivers/dma/dma_pool.c +++ b/components/drivers/dma/dma_pool.c @@ -19,7 +19,7 @@ #include #include -static struct rt_spinlock dma_pools_lock = {}; +static RT_DEFINE_SPINLOCK(dma_pools_lock); static rt_list_t dma_pool_nodes = RT_LIST_OBJECT_INIT(dma_pool_nodes); static struct rt_dma_pool *dma_pool_install(rt_region_t *region); diff --git a/components/drivers/mailbox/mailbox.c b/components/drivers/mailbox/mailbox.c index 5e94241f64..56fd435129 100644 --- a/components/drivers/mailbox/mailbox.c +++ b/components/drivers/mailbox/mailbox.c @@ -20,7 +20,7 @@ #include #include -static struct rt_spinlock mbox_ops_lock = {}; +static RT_DEFINE_SPINLOCK(mbox_ops_lock); static rt_list_t mbox_nodes = RT_LIST_OBJECT_INIT(mbox_nodes); static void mbox_chan_timeout(void *param); diff --git a/components/drivers/mfd/mfd-syscon.c b/components/drivers/mfd/mfd-syscon.c index 1778906383..d470e370ee 100644 --- a/components/drivers/mfd/mfd-syscon.c +++ b/components/drivers/mfd/mfd-syscon.c @@ -17,7 +17,7 @@ #include #include -static struct rt_spinlock _syscon_nodes_lock = { 0 }; +static RT_DEFINE_SPINLOCK(_syscon_nodes_lock); static rt_list_t _syscon_nodes = RT_LIST_OBJECT_INIT(_syscon_nodes); rt_err_t rt_syscon_read(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t *out_val) diff --git a/components/drivers/nvme/nvme.c b/components/drivers/nvme/nvme.c index dc007147e0..b3dc0c5c92 100644 --- a/components/drivers/nvme/nvme.c +++ b/components/drivers/nvme/nvme.c @@ -19,7 +19,7 @@ static struct rt_dm_ida nvme_controller_ida = RT_DM_IDA_INIT(CUSTOM); static struct rt_dm_ida nvme_ida = RT_DM_IDA_INIT(NVME); -static struct rt_spinlock nvme_lock = {}; +static RT_DEFINE_SPINLOCK(nvme_lock); static rt_list_t nvme_nodes = RT_LIST_OBJECT_INIT(nvme_nodes); rt_inline rt_uint32_t nvme_readl(struct rt_nvme_controller *nvme, int offset) diff --git a/components/drivers/ofw/base.c b/components/drivers/ofw/base.c index 78a2e9fc32..744cc96f41 100644 --- a/components/drivers/ofw/base.c +++ b/components/drivers/ofw/base.c @@ -84,7 +84,7 @@ rt_err_t ofw_phandle_hash_reset(rt_phandle min, rt_phandle max) static rt_phandle ofw_phandle_next(void) { rt_phandle next; - static struct rt_spinlock op_lock = {}; + static RT_DEFINE_SPINLOCK(op_lock); rt_hw_spin_lock(&op_lock.lock); diff --git a/components/drivers/pci/endpoint/endpoint.c b/components/drivers/pci/endpoint/endpoint.c index 3783f4e789..70dbe2ad27 100644 --- a/components/drivers/pci/endpoint/endpoint.c +++ b/components/drivers/pci/endpoint/endpoint.c @@ -15,7 +15,7 @@ #include static rt_list_t _ep_nodes = RT_LIST_OBJECT_INIT(_ep_nodes); -static struct rt_spinlock _ep_lock = { 0 }; +static RT_DEFINE_SPINLOCK(_ep_lock); rt_err_t rt_pci_ep_write_header(struct rt_pci_ep *ep, rt_uint8_t func_no, struct rt_pci_ep_header *hdr) diff --git a/components/drivers/pci/msi/irq.c b/components/drivers/pci/msi/irq.c index 8e81e5d672..dab8ee257a 100644 --- a/components/drivers/pci/msi/irq.c +++ b/components/drivers/pci/msi/irq.c @@ -14,7 +14,7 @@ #define DBG_LVL DBG_INFO #include -static struct rt_spinlock msi_irq_map_lock = {}; +static RT_DEFINE_SPINLOCK(msi_irq_map_lock); static RT_BITMAP_DECLARE(msi_irq_map, MAX_HANDLERS) = {}; rt_err_t rt_pci_msi_setup_irqs(struct rt_pci_device *pdev, int nvec, int type) diff --git a/components/drivers/pic/pic-gic-common.c b/components/drivers/pic/pic-gic-common.c index 5c6dc030cf..69ad804a2a 100644 --- a/components/drivers/pic/pic-gic-common.c +++ b/components/drivers/pic/pic-gic-common.c @@ -87,7 +87,7 @@ rt_err_t gic_common_configure_irq(void *base, int irq, rt_uint32_t mode, void (* rt_uint32_t val, oldval; rt_uint32_t confoff = (irq / 16) * 4; rt_uint32_t confmask = 0x2 << ((irq % 16) * 2); - static struct rt_spinlock ic_lock = { 0 }; + static RT_DEFINE_SPINLOCK(ic_lock); level = rt_spin_lock_irqsave(&ic_lock); diff --git a/components/drivers/pic/pic-gicv2.c b/components/drivers/pic/pic-gicv2.c index dbfd443f9c..87763ccbed 100644 --- a/components/drivers/pic/pic-gicv2.c +++ b/components/drivers/pic/pic-gicv2.c @@ -224,7 +224,7 @@ static rt_err_t gicv2_irq_set_affinity(struct rt_pic_irq *pirq, rt_bitmap_t *aff rt_uint32_t val; rt_ubase_t level; rt_ubase_t offset = (rt_ubase_t)io_addr & 3UL, shift = offset * 8; - static struct rt_spinlock rmw_lock = {}; + static RT_DEFINE_SPINLOCK(rmw_lock); level = rt_spin_lock_irqsave(&rmw_lock); diff --git a/components/drivers/pic/pic-gicv3-its.c b/components/drivers/pic/pic-gicv3-its.c index f0772d9171..33f033fefd 100755 --- a/components/drivers/pic/pic-gicv3-its.c +++ b/components/drivers/pic/pic-gicv3-its.c @@ -121,7 +121,8 @@ static rt_uint32_t lpi_id_bits; static void *lpi_table; static void *lpi_pending_table; static rt_bitmap_t *lpis_vectors = RT_NULL; -static struct rt_spinlock lpis_lock = {}, map_lock = {}; +static RT_DEFINE_SPINLOCK(lpis_lock); +static RT_DEFINE_SPINLOCK(map_lock); static rt_list_t its_nodes = RT_LIST_OBJECT_INIT(its_nodes); static rt_list_t map_nodes = RT_LIST_OBJECT_INIT(map_nodes); diff --git a/components/drivers/pic/pic.c b/components/drivers/pic/pic.c index 032c965d52..6a611ceab0 100644 --- a/components/drivers/pic/pic.c +++ b/components/drivers/pic/pic.c @@ -51,7 +51,7 @@ static struct rt_pic_irq _pirq_hash[MAX_HANDLERS] = } }; -static struct rt_spinlock _pic_lock = { }; +static RT_DEFINE_SPINLOCK(_pic_lock); static rt_size_t _pic_name_max = sizeof("PIC"); static rt_list_t _pic_nodes = RT_LIST_OBJECT_INIT(_pic_nodes); static rt_list_t _traps_nodes = RT_LIST_OBJECT_INIT(_traps_nodes); diff --git a/components/drivers/pin/dev_pin_dm.c b/components/drivers/pin/dev_pin_dm.c index 90cca94d22..31f12042ee 100644 --- a/components/drivers/pin/dev_pin_dm.c +++ b/components/drivers/pin/dev_pin_dm.c @@ -11,7 +11,7 @@ #include "dev_pin_dm.h" static rt_size_t pin_total_nr = 0; -static struct rt_spinlock pin_lock = {}; +static RT_DEFINE_SPINLOCK(pin_lock); static rt_list_t pin_nodes = RT_LIST_OBJECT_INIT(pin_nodes); static struct rt_device_pin *pin_device_find(rt_ubase_t pin) diff --git a/components/drivers/regulator/regulator.c b/components/drivers/regulator/regulator.c index 29071e9dc0..f9b19c3090 100644 --- a/components/drivers/regulator/regulator.c +++ b/components/drivers/regulator/regulator.c @@ -24,7 +24,7 @@ struct rt_regulator struct rt_regulator_node *reg_np; }; -static struct rt_spinlock _regulator_lock = { 0 }; +static RT_DEFINE_SPINLOCK(_regulator_lock); static rt_err_t regulator_enable(struct rt_regulator_node *reg_np); static rt_err_t regulator_disable(struct rt_regulator_node *reg_np); diff --git a/components/drivers/thermal/thermal.c b/components/drivers/thermal/thermal.c index e9765c8715..026957f00e 100644 --- a/components/drivers/thermal/thermal.c +++ b/components/drivers/thermal/thermal.c @@ -23,7 +23,7 @@ #define device_list(dev) (dev)->parent.parent.list #define device_foreach(dev, nodes) rt_list_for_each_entry(dev, nodes, parent.parent.list) -static struct rt_spinlock nodes_lock = {}; +static RT_DEFINE_SPINLOCK(nodes_lock); static rt_list_t thermal_zone_device_nodes = RT_LIST_OBJECT_INIT(thermal_zone_device_nodes); static rt_list_t thermal_cooling_device_nodes = RT_LIST_OBJECT_INIT(thermal_cooling_device_nodes); static rt_list_t thermal_cooling_governor_nodes = RT_LIST_OBJECT_INIT(thermal_cooling_governor_nodes);