From 112e67f8631d3ca915a4473e01060b541e9a4146 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 31 May 2024 21:03:07 +0800 Subject: [PATCH] driver/1wire: update pm callback use container_of pretty the code using container_of inside nuttx.h Signed-off-by: buxiasen --- drivers/1wire/1wire.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/1wire/1wire.c b/drivers/1wire/1wire.c index 200b4eb385..599f351a9f 100644 --- a/drivers/1wire/1wire.c +++ b/drivers/1wire/1wire.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include #include @@ -135,9 +136,8 @@ static inline uint32_t onewire_leuint32(uint32_t x) static int onewire_pm_prepare(FAR struct pm_callback_s *cb, int domain, enum pm_state_e pmstate) { - struct onewire_master_s *master = - (struct onewire_master_s *)((char *)cb - - offsetof(struct onewire_master_s, pm_cb)); + struct onewire_master_s *master; + master = container_of(cb, struct onewire_master_s, pm_cb); /* Logic to prepare for a reduced power state goes here. */