~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/kunit/of.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/kunit/of.h (Architecture sparc) and /include/kunit/of.h (Architecture m68k)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _KUNIT_OF_H                                 2 #ifndef _KUNIT_OF_H
  3 #define _KUNIT_OF_H                                 3 #define _KUNIT_OF_H
  4                                                     4 
  5 #include <kunit/test.h>                             5 #include <kunit/test.h>
  6                                                     6 
  7 struct device_node;                                 7 struct device_node;
  8                                                     8 
  9 #ifdef CONFIG_OF                                    9 #ifdef CONFIG_OF
 10                                                    10 
 11 void of_node_put_kunit(struct kunit *test, str     11 void of_node_put_kunit(struct kunit *test, struct device_node *node);
 12                                                    12 
 13 #else                                              13 #else
 14                                                    14 
 15 static inline                                      15 static inline
 16 void of_node_put_kunit(struct kunit *test, str     16 void of_node_put_kunit(struct kunit *test, struct device_node *node)
 17 {                                                  17 {
 18         kunit_skip(test, "requires CONFIG_OF")     18         kunit_skip(test, "requires CONFIG_OF");
 19 }                                                  19 }
 20                                                    20 
 21 #endif /* !CONFIG_OF */                            21 #endif /* !CONFIG_OF */
 22                                                    22 
 23 #if defined(CONFIG_OF) && defined(CONFIG_OF_OV     23 #if defined(CONFIG_OF) && defined(CONFIG_OF_OVERLAY) && defined(CONFIG_OF_EARLY_FLATTREE)
 24                                                    24 
 25 int of_overlay_fdt_apply_kunit(struct kunit *t     25 int of_overlay_fdt_apply_kunit(struct kunit *test, void *overlay_fdt,
 26                                u32 overlay_fdt     26                                u32 overlay_fdt_size, int *ovcs_id);
 27 #else                                              27 #else
 28                                                    28 
 29 static inline int                                  29 static inline int
 30 of_overlay_fdt_apply_kunit(struct kunit *test,     30 of_overlay_fdt_apply_kunit(struct kunit *test, void *overlay_fdt,
 31                            u32 overlay_fdt_siz     31                            u32 overlay_fdt_size, int *ovcs_id)
 32 {                                                  32 {
 33         kunit_skip(test, "requires CONFIG_OF a     33         kunit_skip(test, "requires CONFIG_OF and CONFIG_OF_OVERLAY and CONFIG_OF_EARLY_FLATTREE for root node");
 34         return -EINVAL;                            34         return -EINVAL;
 35 }                                                  35 }
 36                                                    36 
 37 #endif                                             37 #endif
 38                                                    38 
 39 /**                                                39 /**
 40  * __of_overlay_apply_kunit() - Test managed o     40  * __of_overlay_apply_kunit() - Test managed of_overlay_fdt_apply() variant
 41  * @test: test context                             41  * @test: test context
 42  * @overlay_begin: start address of overlay to     42  * @overlay_begin: start address of overlay to apply
 43  * @overlay_end: end address of overlay to app     43  * @overlay_end: end address of overlay to apply
 44  *                                                 44  *
 45  * This is mostly internal API. See of_overlay     45  * This is mostly internal API. See of_overlay_apply_kunit() for the wrapper
 46  * that makes this easier to use.                  46  * that makes this easier to use.
 47  *                                                 47  *
 48  * Similar to of_overlay_fdt_apply(), except t     48  * Similar to of_overlay_fdt_apply(), except the overlay is managed by the test
 49  * case and is automatically removed with of_o     49  * case and is automatically removed with of_overlay_remove() after the test
 50  * case concludes.                                 50  * case concludes.
 51  *                                                 51  *
 52  * Return: 0 on success, negative errno on fai     52  * Return: 0 on success, negative errno on failure
 53  */                                                53  */
 54 static inline int __of_overlay_apply_kunit(str     54 static inline int __of_overlay_apply_kunit(struct kunit *test,
 55                                            u8      55                                            u8 *overlay_begin,
 56                                            con     56                                            const u8 *overlay_end)
 57 {                                                  57 {
 58         int unused;                                58         int unused;
 59                                                    59 
 60         return of_overlay_fdt_apply_kunit(test     60         return of_overlay_fdt_apply_kunit(test, overlay_begin,
 61                                           over     61                                           overlay_end - overlay_begin,
 62                                           &unu     62                                           &unused);
 63 }                                                  63 }
 64                                                    64 
 65 /**                                                65 /**
 66  * of_overlay_apply_kunit() - Test managed of_     66  * of_overlay_apply_kunit() - Test managed of_overlay_fdt_apply() for built-in overlays
 67  * @test: test context                             67  * @test: test context
 68  * @overlay_name: name of overlay to apply         68  * @overlay_name: name of overlay to apply
 69  *                                                 69  *
 70  * This macro is used to apply a device tree o     70  * This macro is used to apply a device tree overlay built with the
 71  * cmd_dt_S_dtbo rule in scripts/Makefile.lib      71  * cmd_dt_S_dtbo rule in scripts/Makefile.lib that has been compiled into the
 72  * kernel image or KUnit test module. The over     72  * kernel image or KUnit test module. The overlay is automatically removed when
 73  * the test is finished.                           73  * the test is finished.
 74  *                                                 74  *
 75  * Unit tests that need device tree nodes shou     75  * Unit tests that need device tree nodes should compile an overlay file with
 76  * @overlay_name\.dtbo.o in their Makefile alo     76  * @overlay_name\.dtbo.o in their Makefile along with their unit test and then
 77  * load the overlay during their test. The @ov     77  * load the overlay during their test. The @overlay_name matches the filename
 78  * of the overlay without the dtbo filename ex     78  * of the overlay without the dtbo filename extension. If CONFIG_OF_OVERLAY is
 79  * not enabled, the @test will be skipped.         79  * not enabled, the @test will be skipped.
 80  *                                                 80  *
 81  * In the Makefile                                 81  * In the Makefile
 82  *                                                 82  *
 83  * .. code-block:: none                            83  * .. code-block:: none
 84  *                                                 84  *
 85  *      obj-$(CONFIG_OF_OVERLAY_KUNIT_TEST) +=     85  *      obj-$(CONFIG_OF_OVERLAY_KUNIT_TEST) += overlay_test.o kunit_overlay_test.dtbo.o
 86  *                                                 86  *
 87  * In the test                                     87  * In the test
 88  *                                                 88  *
 89  * .. code-block:: c                               89  * .. code-block:: c
 90  *                                                 90  *
 91  *      static void of_overlay_kunit_of_overla     91  *      static void of_overlay_kunit_of_overlay_apply(struct kunit *test)
 92  *      {                                          92  *      {
 93  *              struct device_node *np;            93  *              struct device_node *np;
 94  *                                                 94  *
 95  *              KUNIT_ASSERT_EQ(test, 0,           95  *              KUNIT_ASSERT_EQ(test, 0,
 96  *                              of_overlay_app     96  *                              of_overlay_apply_kunit(test, kunit_overlay_test));
 97  *                                                 97  *
 98  *              np = of_find_node_by_name(NULL     98  *              np = of_find_node_by_name(NULL, "test-kunit");
 99  *              KUNIT_EXPECT_NOT_ERR_OR_NULL(t     99  *              KUNIT_EXPECT_NOT_ERR_OR_NULL(test, np);
100  *              of_node_put(np);                  100  *              of_node_put(np);
101  *      }                                         101  *      }
102  *                                                102  *
103  * Return: 0 on success, negative errno on fai    103  * Return: 0 on success, negative errno on failure.
104  */                                               104  */
105 #define of_overlay_apply_kunit(test, overlay_n    105 #define of_overlay_apply_kunit(test, overlay_name)              \
106 ({                                                106 ({                                                              \
107         extern uint8_t __dtbo_##overlay_name##    107         extern uint8_t __dtbo_##overlay_name##_begin[];         \
108         extern uint8_t __dtbo_##overlay_name##    108         extern uint8_t __dtbo_##overlay_name##_end[];           \
109                                                   109                                                                 \
110         __of_overlay_apply_kunit((test),          110         __of_overlay_apply_kunit((test),                        \
111                         __dtbo_##overlay_name#    111                         __dtbo_##overlay_name##_begin,          \
112                         __dtbo_##overlay_name#    112                         __dtbo_##overlay_name##_end);           \
113 })                                                113 })
114                                                   114 
115 #endif                                            115 #endif
116                                                   116 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php