From 1dc3a2e216d99adc2df022ab37eab32f61d80e0e Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 8 May 2023 19:26:48 +0200 Subject: [PATCH] layerscape: 6.1: fix compilation warning for fsl ppfe driver Rework some desc dump and dummy pkt function to fix compilation warning. Fix compilation warning: drivers/staging/fsl_ppfe/pfe_hif.c: In function 'send_dummy_pkt_to_hif': drivers/staging/fsl_ppfe/pfe_hif.c:118:19: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 118 | ddr_ptr = (void *)((u64)readl(BMU2_BASE_ADDR + BMU_ALLOC_CTRL)); | ^ drivers/staging/fsl_ppfe/pfe_hif.c:122:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 122 | lmem_ptr = (void *)((u64)readl(BMU1_BASE_ADDR + BMU_ALLOC_CTRL)); | ^ drivers/staging/fsl_ppfe/pfe_hif.c: In function 'pfe_hif_desc_dump': drivers/staging/fsl_ppfe/pfe_hif.c:195:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 195 | desc_p = (u32)((u64)desc - (u64)hif->descr_baseaddr_v + | ^ drivers/staging/fsl_ppfe/pfe_hif.c:195:36: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 195 | desc_p = (u32)((u64)desc - (u64)hif->descr_baseaddr_v + | ^ drivers/staging/fsl_ppfe/pfe_hif.c:207:19: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 207 | desc_p = ((u64)desc - (u64)hif->descr_baseaddr_v + | ^ drivers/staging/fsl_ppfe/pfe_hif.c:207:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 207 | desc_p = ((u64)desc - (u64)hif->descr_baseaddr_v + | ^ cc1: all warnings being treated as errors In file included from ./include/linux/kernel.h:19, from ./include/linux/list.h:9, from ./include/linux/wait.h:7, from ./include/linux/eventfd.h:13, from drivers/staging/fsl_ppfe/pfe_cdev.c:11: drivers/staging/fsl_ppfe/pfe_cdev.c: In function 'pfe_cdev_read': ./include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Werror=format=] 5 | #define KERN_SOH "\001" /* ASCII Start Of Header */ | ^~~~~~ ./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap' 422 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~ ./include/linux/printk.h:132:17: note: in expansion of macro 'printk' 132 | printk(fmt, ##__VA_ARGS__); \ | ^~~~~~ ./include/linux/printk.h:580:9: note: in expansion of macro 'no_printk' 580 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~ ./include/linux/kern_levels.h:15:25: note: in expansion of macro 'KERN_SOH' 15 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */ | ^~~~~~~~ ./include/linux/printk.h:580:19: note: in expansion of macro 'KERN_DEBUG' 580 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~ drivers/staging/fsl_ppfe/pfe_cdev.c:42:17: note: in expansion of macro 'pr_debug' 42 | pr_debug("%u %lu", link_states[ret].phy_id, | ^~~~~~~~ ./include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=] 5 | #define KERN_SOH "\001" /* ASCII Start Of Header */ | ^~~~~~ ./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap' 422 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~ ./include/linux/printk.h:493:9: note: in expansion of macro 'printk' 493 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~ ./include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH' 11 | #define KERN_ERR KERN_SOH "3" /* error conditions */ | ^~~~~~~~ ./include/linux/printk.h:493:16: note: in expansion of macro 'KERN_ERR' 493 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~ drivers/staging/fsl_ppfe/pfe_cdev.c:50:17: note: in expansion of macro 'pr_err' 50 | pr_err("Failed to send (%d)bytes of (%lu) requested.\n", | ^~~~~~ ./include/linux/kern_levels.h:5:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'unsigned int' [-Werror=format=] 5 | #define KERN_SOH "\001" /* ASCII Start Of Header */ | ^~~~~~ ./include/linux/printk.h:422:25: note: in definition of macro 'printk_index_wrap' 422 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~ ./include/linux/printk.h:132:17: note: in expansion of macro 'printk' 132 | printk(fmt, ##__VA_ARGS__); \ | ^~~~~~ ./include/linux/printk.h:580:9: note: in expansion of macro 'no_printk' 580 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~ ./include/linux/kern_levels.h:15:25: note: in expansion of macro 'KERN_SOH' 15 | #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */ | ^~~~~~~~ ./include/linux/printk.h:580:19: note: in expansion of macro 'KERN_DEBUG' 580 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~ drivers/staging/fsl_ppfe/pfe_cdev.c:57:9: note: in expansion of macro 'pr_debug' 57 | pr_debug("Read of (%lu) bytes performed.\n", sizeof(link_states)); | ^~~~~~~~ cc1: all warnings being treated as errors In file included from ./include/uapi/linux/posix_types.h:5, from ./include/uapi/linux/types.h:14, from ./include/linux/types.h:6, from ./include/linux/list.h:5, from ./include/linux/module.h:12, from drivers/staging/fsl_ppfe/pfe_sysfs.c:7: drivers/staging/fsl_ppfe/pfe_sysfs.c: In function 'pfe_set_util': ./include/linux/stddef.h:8:14: error: passing argument 2 of 'kstrtoul' makes integer from pointer without a cast [-Werror=int-conversion] 8 | #define NULL ((void *)0) | ^~~~~~~~~~~ | | | void * drivers/staging/fsl_ppfe/pfe_sysfs.c:538:39: note: in expansion of macro 'NULL' 538 | util_do_clear = kstrtoul(buf, NULL, 0); | ^~~~ In file included from ./include/linux/kernel.h:13, from ./include/linux/list.h:9: ./include/linux/kstrtox.h:30:69: note: expected 'unsigned int' but argument is of type 'void *' 30 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) | ~~~~~~~~~~~~~^~~~ cc1: all warnings being treated as errors With UTIL compiled on, fix compilation warning: drivers/staging/fsl_ppfe/pfe_hal.c: In function 'pe_load_ddr_section': drivers/staging/fsl_ppfe/pfe_hal.c:617:19: error: 'else' without a previous 'if' 617 | } else { | ^~~~ drivers/staging/fsl_ppfe/pfe_hal.c:622:17: error: break statement not within loop or switch 622 | break; | ^~~~~ drivers/staging/fsl_ppfe/pfe_hal.c:624:9: error: case label not within a switch statement 624 | case SHT_NOBITS: | ^~~~ drivers/staging/fsl_ppfe/pfe_hal.c:627:17: error: break statement not within loop or switch 627 | break; | ^~~~~ drivers/staging/fsl_ppfe/pfe_hal.c:629:9: error: 'default' label not within a switch statement 629 | default: | ^~~~~~~ drivers/staging/fsl_ppfe/pfe_hal.c: At top level: drivers/staging/fsl_ppfe/pfe_hal.c:635:9: error: expected identifier or '(' before 'return' 635 | return 0; | ^~~~~~ drivers/staging/fsl_ppfe/pfe_hal.c:636:1: error: expected identifier or '(' before '}' token 636 | } Signed-off-by: Christian Marangi Signed-off-by: Pawel Dembicki --- drivers/staging/fsl_ppfe/pfe_cdev.c | 6 +++--- drivers/staging/fsl_ppfe/pfe_hif.c | 14 +++++++------- drivers/staging/fsl_ppfe/pfe_sysfs.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/fsl_ppfe/pfe_cdev.c b/drivers/staging/fsl_ppfe/pfe_cdev.c index f19a1821af42..e0b3af0892ac 100644 --- a/drivers/staging/fsl_ppfe/pfe_cdev.c +++ b/drivers/staging/fsl_ppfe/pfe_cdev.c @@ -34,7 +34,7 @@ static ssize_t pfe_cdev_read(struct file *fp, char *buf, { int ret = 0; - pr_info("PFE CDEV attempt copying (%lu) size of user.\n", + pr_info("PFE CDEV attempt copying (%zu) size of user.\n", sizeof(link_states)); pr_debug("Dump link_state on screen before copy_to_user\n"); @@ -47,14 +47,14 @@ static ssize_t pfe_cdev_read(struct file *fp, char *buf, /* Copy to user the value in buffer sized len */ ret = copy_to_user(buf, &link_states, sizeof(link_states)); if (ret != 0) { - pr_err("Failed to send (%d)bytes of (%lu) requested.\n", + pr_err("Failed to send (%d)bytes of (%zu) requested.\n", ret, len); return -EFAULT; } /* offset set back to 0 as there is contextual reading offset */ *off = 0; - pr_debug("Read of (%lu) bytes performed.\n", sizeof(link_states)); + pr_debug("Read of (%zu) bytes performed.\n", sizeof(link_states)); return sizeof(link_states); } diff --git a/drivers/staging/fsl_ppfe/pfe_hif.c b/drivers/staging/fsl_ppfe/pfe_hif.c index dcc3f7f1e9ef..5347401f92c0 100644 --- a/drivers/staging/fsl_ppfe/pfe_hif.c +++ b/drivers/staging/fsl_ppfe/pfe_hif.c @@ -115,11 +115,11 @@ static void send_dummy_pkt_to_hif(void) 0x33221100, 0xa8c05544, 0x00000301, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xbe86c51f }; - ddr_ptr = (void *)((u64)readl(BMU2_BASE_ADDR + BMU_ALLOC_CTRL)); + ddr_ptr = (void *)((uintptr_t)readl(BMU2_BASE_ADDR + BMU_ALLOC_CTRL)); if (!ddr_ptr) return; - lmem_ptr = (void *)((u64)readl(BMU1_BASE_ADDR + BMU_ALLOC_CTRL)); + lmem_ptr = (void *)((uintptr_t)readl(BMU1_BASE_ADDR + BMU_ALLOC_CTRL)); if (!lmem_ptr) return; @@ -186,16 +186,16 @@ static void pfe_hif_free_descr(struct pfe_hif *hif) void pfe_hif_desc_dump(struct pfe_hif *hif) { struct hif_desc *desc; - unsigned long desc_p; + u64 desc_p; int ii = 0; pr_info("%s\n", __func__); desc = hif->rx_base; - desc_p = (u32)((u64)desc - (u64)hif->descr_baseaddr_v + + desc_p = ((void *)desc - hif->descr_baseaddr_v + hif->descr_baseaddr_p); - pr_info("HIF Rx desc base %p physical %x\n", desc, (u32)desc_p); + pr_info("HIF Rx desc base %p physical %llx\n", desc, desc_p); for (ii = 0; ii < hif->rx_ring_size; ii++) { pr_info("status: %08x, ctrl: %08x, data: %08x, next: %x\n", readl(&desc->status), readl(&desc->ctrl), @@ -204,10 +204,10 @@ void pfe_hif_desc_dump(struct pfe_hif *hif) } desc = hif->tx_base; - desc_p = ((u64)desc - (u64)hif->descr_baseaddr_v + + desc_p = ((void *)desc - hif->descr_baseaddr_v + hif->descr_baseaddr_p); - pr_info("HIF Tx desc base %p physical %x\n", desc, (u32)desc_p); + pr_info("HIF Tx desc base %p physical %llx\n", desc, desc_p); for (ii = 0; ii < hif->tx_ring_size; ii++) { pr_info("status: %08x, ctrl: %08x, data: %08x, next: %x\n", readl(&desc->status), readl(&desc->ctrl), diff --git a/drivers/staging/fsl_ppfe/pfe_sysfs.c b/drivers/staging/fsl_ppfe/pfe_sysfs.c index 1792e88140d1..ede651be51bf 100644 --- a/drivers/staging/fsl_ppfe/pfe_sysfs.c +++ b/drivers/staging/fsl_ppfe/pfe_sysfs.c @@ -535,7 +535,7 @@ static ssize_t pfe_show_tmu3_queues(struct device *dev, struct device_attribute static ssize_t pfe_set_util(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - util_do_clear = kstrtoul(buf, NULL, 0); + util_do_clear = kstrtoul(buf, 0, 0); return count; } -- 2.25.1