static int dsi_panel_set_backlight_external(int value){ int ret = 0; ret = kthread_run(lcd_bl_set_led_brightness, (void *)value, "lcd_bl_set_led_brightness"); if (ret < 0) { pr_err("Failed to create lcd_bl_set_led_brightness thread\n"); } ret = kthread_run(lcd_bias_set_led_brightness, (void *)value, "lcd_bias_set_led_brightness"); if (ret < 0) { pr_err("Failed to create lcd_bias_set_led_brightness thread\n"); } return ret;}这个代码会有kernel/msm-4.19/techpack/display/msm/dsi/dsi_panel.c:761:47: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast] error, forbidden warning: dsi_panel.c:761这个报错,该怎么解决
时间: 2024-03-09 16:44:16 浏览: 177
inet_dsi_panel20200703_BOE_FHD_8279_A55_
这个编译警告的原因是函数 `kthread_run()` 的第二个参数需要传入 `void*` 类型的指针,而在这个代码中,value 是一个整型变量,需要转换成 `void*` 类型的指针。你可以使用 `intptr_t` 类型来完成这个转换,它可以安全地将一个整型变量转换成指针类型。修改后的代码如下:
```
static int dsi_panel_set_backlight_external(int value)
{
int ret = 0;
ret = kthread_run(lcd_bl_set_led_brightness, (void *)(intptr_t)value, "lcd_bl_set_led_brightness");
if (ret < 0) {
pr_err("Failed to create lcd_bl_set_led_brightness thread\n");
}
ret = kthread_run(lcd_bias_set_led_brightness, (void *)(intptr_t)value, "lcd_bias_set_led_brightness");
if (ret < 0) {
pr_err("Failed to create lcd_bias_set_led_brightness thread\n");
}
return ret;
}
```
这个修改会把整型变量 value 转换成一个 intptr_t 类型的指针,然后再传给 `kthread_run()` 函数。这样就可以消除这个编译警告了。
阅读全文