Module Name: src Committed By: riastradh Date: Mon Mar 28 19:59:26 UTC 2022
Modified Files: src/sys/arch/arm/apple: apple_intc.c Log Message: arm/apple: Use container_of, not bespoke offsetof arithmetic. Better type-safety this way. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/apple/apple_intc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/apple/apple_intc.c diff -u src/sys/arch/arm/apple/apple_intc.c:1.6 src/sys/arch/arm/apple/apple_intc.c:1.7 --- src/sys/arch/arm/apple/apple_intc.c:1.6 Fri Nov 26 19:39:58 2021 +++ src/sys/arch/arm/apple/apple_intc.c Mon Mar 28 19:59:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $ */ +/* $NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $ */ /*- * Copyright (c) 2021 Jared McNeill <jmcne...@invisible.ca> @@ -32,7 +32,7 @@ #define _INTR_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.6 2021/11/26 19:39:58 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apple_intc.c,v 1.7 2022/03/28 19:59:26 riastradh Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -112,10 +112,8 @@ struct apple_intc_softc { static struct apple_intc_softc *intc_softc; -#define PICTOSOFTC(pic) \ - ((void *)((uintptr_t)(pic) - offsetof(struct apple_intc_softc, sc_pic))) -#define PICTOPERCPU(pic) \ - ((void *)((uintptr_t)(pic) - offsetof(struct apple_intc_percpu, pc_pic))) +#define PICTOSOFTC(pic) container_of(pic, struct apple_intc_softc, sc_pic) +#define PICTOPERCPU(pic) container_of(pic, struct apple_intc_percpu, pc_pic) #define AIC_READ(sc, reg) \ bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))