Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/esp32_himemcdev: Replace file descriptor with node #15885

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions arch/xtensa/src/esp32/esp32_himem_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static size_t g_ram_offset; /* used by himem map/unmap */

static void *g_himem_ptr; /* mapped himem pointer */

static struct file *g_mapped_filep; /* for multi device */
static struct inode *g_mapped_inode; /* for multi device */

/****************************************************************************
* Priavte Functions
Expand Down Expand Up @@ -120,7 +120,8 @@ static int himem_chardev_read_write(int is_write, struct file *filep,
length, dev->size);
goto err;
}
if ((mmap_offset != g_ram_offset) || (g_mapped_filep != filep))
if ((mmap_offset != g_ram_offset) || \
(g_mapped_inode != filep->f_inode))
{
if (g_ram_offset != HIMEM_UNMAPPED)
{
Expand All @@ -134,7 +135,7 @@ static int himem_chardev_read_write(int is_write, struct file *filep,
goto err;
}
g_ram_offset = HIMEM_UNMAPPED;
g_mapped_filep = NULL;
g_mapped_inode = NULL;
}
ret = esp_himem_map(dev->mem_handle, g_range_handle,
mmap_offset * ESP_HIMEM_BLKSZ,
Expand All @@ -145,7 +146,7 @@ static int himem_chardev_read_write(int is_write, struct file *filep,
goto err;
}
g_ram_offset = mmap_offset;
g_mapped_filep = filep;
g_mapped_inode = filep->f_inode;
}
himem_ptr = g_himem_ptr + priv->offset % ESP_HIMEM_BLKSZ;
copy_range = ESP_HIMEM_BLKSZ - priv->offset % ESP_HIMEM_BLKSZ;
Expand Down Expand Up @@ -273,7 +274,7 @@ int himem_chardev_init(void)
}

g_ram_offset = HIMEM_UNMAPPED;
g_mapped_filep = NULL;
g_mapped_inode = NULL;
return ret;
}

Expand Down Expand Up @@ -382,7 +383,7 @@ int himem_chardev_unregister(char *name)
}

g_ram_offset = HIMEM_UNMAPPED;
g_mapped_filep = NULL;
g_mapped_inode = NULL;
}

ret = esp_himem_free(dev->mem_handle);
Expand Down