From ceb37e7072964e6295b2b2bb8bd86eeeaa09bae9 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Wed, 18 Dec 2024 11:03:43 +0800 Subject: [PATCH 1/7] [AARCH64] Update kernel's boot link for ARM64 Signed-off-by: GuEe-GUI <2991707448@qq.com> --- libcpu/aarch64/cortex-a/entry_point.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpu/aarch64/cortex-a/entry_point.S b/libcpu/aarch64/cortex-a/entry_point.S index c0acacb2ca2..896bb68012f 100644 --- a/libcpu/aarch64/cortex-a/entry_point.S +++ b/libcpu/aarch64/cortex-a/entry_point.S @@ -57,7 +57,7 @@ /* * Our goal is to boot the rt-thread as possible without modifying the * bootloader's config, so we use the kernel's boot header for ARM64: - * https://www.kernel.org/doc/html/latest/arm64/booting.html#call-the-kernel-image + * https://www.kernel.org/doc/html/latest/arch/arm64/booting.html#call-the-kernel-image */ _head: b _start /* Executable code */ From c189222a77d740231a8688554dc4d03aefb6aca0 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Fri, 20 Dec 2024 14:45:08 +0800 Subject: [PATCH 2/7] [DM/CORE] Add IDA init in runtime Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/include/drivers/core/dm.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/drivers/include/drivers/core/dm.h b/components/drivers/include/drivers/core/dm.h index 1a3723a6507..4c110ca7eb1 100644 --- a/components/drivers/include/drivers/core/dm.h +++ b/components/drivers/include/drivers/core/dm.h @@ -40,6 +40,11 @@ struct rt_dm_ida }; #define RT_DM_IDA_INIT(id) { .master_id = MASTER_ID_##id } +#define rt_dm_ida_init(ida, id) \ +do { \ + (ida)->master_id = MASTER_ID_##id; \ + rt_spin_lock_init(&(ida)->lock); \ +} while (0) int rt_dm_ida_alloc(struct rt_dm_ida *ida); rt_bool_t rt_dm_ida_take(struct rt_dm_ida *ida, int id); From 546a251436069bca17b1fef6d1072205c18f0770 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 30 Dec 2024 11:41:13 +0800 Subject: [PATCH 3/7] [DM/PIN] Reset the value of PIN_NONE PIN_NONE is '-1', is similar to '-RT_ERROR', '-RT_EEMPTY' is better. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/include/drivers/dev_pin.h | 2 +- components/drivers/regulator/regulator-gpio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/include/drivers/dev_pin.h b/components/drivers/include/drivers/dev_pin.h index b1705ae6ddd..0cb15c3af97 100644 --- a/components/drivers/include/drivers/dev_pin.h +++ b/components/drivers/include/drivers/dev_pin.h @@ -111,7 +111,7 @@ struct rt_device_pin const struct rt_pin_ops *ops; }; -#define PIN_NONE (-1) +#define PIN_NONE (-RT_EEMPTY) #define PIN_LOW 0x00 /*!< low level */ #define PIN_HIGH 0x01 /*!< high level */ diff --git a/components/drivers/regulator/regulator-gpio.c b/components/drivers/regulator/regulator-gpio.c index 069831835fd..0ba9b9534cc 100644 --- a/components/drivers/regulator/regulator-gpio.c +++ b/components/drivers/regulator/regulator-gpio.c @@ -193,7 +193,7 @@ static rt_err_t regulator_gpio_probe(struct rt_platform_device *pdev) /* GPIO flags are ignored, we check by enable-active-high */ rg->enable_pin = rt_pin_get_named_pin(dev, "enable", 0, RT_NULL, RT_NULL); - if (rg->enable_pin < 0 && rg->enable_pin != -RT_EEMPTY) + if (rg->enable_pin < 0 && rg->enable_pin != PIN_NONE) { err = rg->enable_pin; goto _fail; From c448870de03a4aa048ec35004fa51c564ce58d0c Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 10 Feb 2025 14:14:48 +0800 Subject: [PATCH 4/7] [DFS/ISO9660] Remove warning for ops Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c b/components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c index 612b68c40ae..2358280a799 100644 --- a/components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c +++ b/components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c @@ -391,7 +391,7 @@ static int dfs_iso9660_close(struct dfs_file *fd) return 0; } -static int dfs_iso9660_read(struct dfs_file *fd, void *buf, size_t count) +static ssize_t dfs_iso9660_read(struct dfs_file *fd, void *buf, size_t count) { rt_uint32_t pos; void *buf_ptr; From da656401f8820e74c0b71543f6bcbd3a045c526c Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 10 Feb 2025 14:19:30 +0800 Subject: [PATCH 5/7] [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 2bb45f8d68d..30e7e5c5655 100644 --- a/components/drivers/clk/clk.c +++ b/components/drivers/clk/clk.c @@ -16,7 +16,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 a1d6d7e7b5e..72ff49628df 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 9d9f93f6ae3..b11dd058e15 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 da2d80a8660..36b6ffc50ab 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 8bd5291fc2f..9f220d8c5ae 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 5e94241f64b..56fd435129a 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 1778906383d..d470e370eeb 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 dc007147e0b..b3dc0c5c92a 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 78a2e9fc329..744cc96f41b 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 3783f4e7890..70dbe2ad27e 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 8e81e5d6722..dab8ee257a7 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 5c6dc030cfb..69ad804a2af 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 dbfd443f9cf..87763ccbed0 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 f0772d91710..33f033fefd9 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 032c965d528..6a611ceab0f 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 90cca94d226..31f12042ee7 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 29071e9dc03..f9b19c3090f 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 e9765c8715b..026957f00e1 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); From 614d6c0cc27f8340baa599eebe2ebe0facfd7cbb Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Mon, 10 Feb 2025 14:20:34 +0800 Subject: [PATCH 6/7] [DM/LED] Rename LED register/unregister rt_hw_* is use for DM and not DM, but LED only use in DM. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/include/drivers/led.h | 4 ++-- components/drivers/led/led-gpio.c | 6 +++--- components/drivers/led/led.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/drivers/include/drivers/led.h b/components/drivers/include/drivers/led.h index aeb80a6d64f..4f6d39e0131 100644 --- a/components/drivers/include/drivers/led.h +++ b/components/drivers/include/drivers/led.h @@ -46,8 +46,8 @@ struct rt_led_ops rt_err_t (*set_brightness)(struct rt_led_device *led, rt_uint32_t brightness); }; -rt_err_t rt_hw_led_register(struct rt_led_device *led); -rt_err_t rt_hw_led_unregister(struct rt_led_device *led); +rt_err_t rt_led_register(struct rt_led_device *led); +rt_err_t rt_led_unregister(struct rt_led_device *led); rt_err_t rt_led_set_state(struct rt_led_device *led, enum rt_led_state state); rt_err_t rt_led_get_state(struct rt_led_device *led, enum rt_led_state *out_state); diff --git a/components/drivers/led/led-gpio.c b/components/drivers/led/led-gpio.c index 0b6bd6875ee..fb60f32fbee 100644 --- a/components/drivers/led/led-gpio.c +++ b/components/drivers/led/led-gpio.c @@ -23,7 +23,7 @@ struct gpio_led rt_uint8_t active_val; }; -#define raw_to_gpio_led(raw) rt_container_of(raw, struct gpio_led, parent); +#define raw_to_gpio_led(raw) rt_container_of(raw, struct gpio_led, parent) static rt_err_t gpio_led_set_state(struct rt_led_device *led, enum rt_led_state state) { @@ -108,7 +108,7 @@ static rt_err_t ofw_append_gpio_led(struct rt_ofw_node *np) gled->parent.ops = &gpio_led_ops; - if ((err = rt_hw_led_register(&gled->parent))) + if ((err = rt_led_register(&gled->parent))) { goto _fail; } @@ -203,7 +203,7 @@ static rt_err_t gpio_led_remove(struct rt_platform_device *pdev) rt_ofw_data(led_np) = RT_NULL; - rt_hw_led_unregister(&gled->parent); + rt_led_unregister(&gled->parent); rt_free(gled); } diff --git a/components/drivers/led/led.c b/components/drivers/led/led.c index 611a16de939..f041148cd3a 100644 --- a/components/drivers/led/led.c +++ b/components/drivers/led/led.c @@ -119,7 +119,7 @@ static void _led_blink_timerout(void *param) btimer->toggle = !btimer->toggle; } -rt_err_t rt_hw_led_register(struct rt_led_device *led) +rt_err_t rt_led_register(struct rt_led_device *led) { rt_err_t err; int device_id; @@ -193,7 +193,7 @@ rt_err_t rt_hw_led_register(struct rt_led_device *led) return err; } -rt_err_t rt_hw_led_unregister(struct rt_led_device *led) +rt_err_t rt_led_unregister(struct rt_led_device *led) { if (!led) { From dad2f3b8b230b9435b880374351b92b68b58f503 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Tue, 11 Feb 2025 13:54:26 +0800 Subject: [PATCH 7/7] [DM/THERMAL] Remove unused code in update poll Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/thermal/thermal.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/drivers/thermal/thermal.c b/components/drivers/thermal/thermal.c index 026957f00e1..9343fe137a0 100644 --- a/components/drivers/thermal/thermal.c +++ b/components/drivers/thermal/thermal.c @@ -638,10 +638,6 @@ void rt_thermal_zone_device_update(struct rt_thermal_zone_device *zdev, rt_ubase int trip_low; rt_bool_t low_set = RT_FALSE; - if (i >= zdev->trips_nr) - { - goto _call_notifier; - } rt_memcpy(&trip, &zdev->trips[i], sizeof(trip)); trip_low = trip.temperature - trip.hysteresis;