This article provides the code for testing the other commonly used of functions that were not mentioned previously.
For related subjects, please refer to the SOC Table of Contents.
The functions we will be testing in chronological order in this section are:
- of_device_is_compatible
- of_get_adddress
- of_translate_address
- of_address_to_resource
- of_iomap
The code to be inserted into the corresponding section is as follows:
// of_device_is_compatible int test_odic; test_odic = of_device_is_compatible(of_find_node_by_name(NULL, "fii-dt-driver"), "fii,fii-dt-driver"); printk(KERN_ERR "Compatible was successfully found via of_device_is_compatible \r\n"); printk(KERN_ERR "Return value : %d\n", test_odic); printk(KERN_ERR "\r\n"); // of_get_address const __be32 *test_oga; u64 test_oga_size; test_oga = of_get_address(of_find_node_by_name(NULL, "fii-dt-driver"), 0, &test_oga_size,NULL); printk(KERN_ERR "Address was successfully found via of_get_address \r\n"); printk(KERN_ERR "Return value : 0x%08x\n", test_oga); printk(KERN_ERR "\r\n"); // of_translate_address u64 test_ota; test_ota = of_translate_address(of_find_node_by_name(NULL, "fii-dt-driver"), test_oga); printk(KERN_ERR "Address was successfully translated via of_translate_address \r\n"); printk(KERN_ERR "Return value : 0x%08x\n", test_ota); printk(KERN_ERR "\r\n"); // of_address_to_resource int test_oatr; struct resource res; test_oatr = of_address_to_resource(of_find_node_by_name(NULL, "fii-dt-driver"), 0, &res); printk(KERN_ERR "Resource was successfully transfered via of_address_to_resource \n"); printk(KERN_ERR "Return value: %d \nProperty value is: 0x%08x\n", test_oatr, res); printk(KERN_ERR "\r\n"); // of_iomap void __iomem *test_oi; test_oi = of_iomap(of_find_node_by_name(NULL, "fii-dt-driver"), 0); printk(KERN_ERR "Mapping was successful via of_iomap \n"); printk(KERN_ERR "Return value: 0x%08x\n", test_oi);