Skip to content

Commit

Permalink
os/drivers/lcd/lcd_dev.c: Declare LCD HAL layer instance locally insi…
Browse files Browse the repository at this point in the history
…de lcddev_register function

Replaced the global LCD HAL layer instance with a local declaration within the lcddev_register function
and passed this instance to LCD_FLUSH_THREAD by converting its address to a string using atoi() function.
  • Loading branch information
abhinav-s235 committed Dec 24, 2024
1 parent 93030a3 commit 3d5064e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions os/drivers/lcd/lcd_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ struct lcd_s {
bool do_wait;
#endif
};
static struct lcd_s *lcd_info;
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
Expand Down Expand Up @@ -376,10 +375,12 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}

#if defined(CONFIG_LCD_FLUSH_THREAD)
static void lcd_flushing_thread(void)
static void lcd_flushing_thread(int argc, char **argv)
{
int ret;
DEBUGASSERT(argc == 2);
FAR struct lcddev_area_s *lcd_area;
struct lcd_s *lcd_info = (struct lcd_s *)strtoul(argv[1], NULL, 16);
lcd_area = &(lcd_info->lcd_area);
while (true) {
while (sem_wait(&lcd_info->flushing_sem) != 0) {
Expand Down Expand Up @@ -423,13 +424,15 @@ int lcddev_register(struct lcd_dev_s *dev)
{
char devname[16] = { 0, };
int ret;
char *parm[2];
char parm_buf[9]; /* for storing 32 bit address */

if (!dev) {
return -EINVAL;
}

/* Allocate a new lcd_dev driver instance */
lcd_info = (struct lcd_s *)kmm_zalloc(sizeof(struct lcd_s));
struct lcd_s *lcd_info = (struct lcd_s *)kmm_zalloc(sizeof(struct lcd_s));
if (!lcd_info) {
return -ENOMEM;
}
Expand All @@ -444,8 +447,10 @@ int lcddev_register(struct lcd_dev_s *dev)
lcddbg("ERROR: Failed to allocate memory for LCD flush swap buffer\n");
return -ENOMEM;
}

int pid = kernel_thread("LCD Frame flusing", 204, 8192, lcd_flushing_thread, NULL);
itoa((int)lcd_info, parm_buf, 16);
parm[0] = parm_buf;
parm[1] = NULL;
int pid = kernel_thread("LCD Frame flusing", 204, 8192, lcd_flushing_thread, (FAR char *const *)parm);
if (pid < 0) {
lcddbg("ERROR: Failed to start LCD Frame Flusing thread\n");
return -ENOMEM;
Expand Down

0 comments on commit 3d5064e

Please sign in to comment.