This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 112e67f863 driver/1wire: update pm callback use container_of
112e67f863 is described below

commit 112e67f8631d3ca915a4473e01060b541e9a4146
Author: buxiasen <[email protected]>
AuthorDate: Fri May 31 21:03:07 2024 +0800

    driver/1wire: update pm callback use container_of
    
    pretty the code using container_of inside nuttx.h
    
    Signed-off-by: buxiasen <[email protected]>
---
 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 <nuttx/config.h>
+#include <nuttx/nuttx.h>
 
 #include <assert.h>
 #include <errno.h>
@@ -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. */
 

Reply via email to