mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
fbdev: defio: Move variable state into struct fb_deferred_io_state
Move variable fields from struct fb_deferred_io into struct fb_deferred_io_state. These fields are internal to the defio code and should not be exposed to drivers. At some later point, struct fb_defered_io might become const in all defio code. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
parent
d460a54fd3
commit
648bfb62da
|
|
@ -25,6 +25,8 @@
|
|||
#include <linux/rmap.h>
|
||||
#include <linux/pagemap.h>
|
||||
|
||||
struct address_space;
|
||||
|
||||
/*
|
||||
* struct fb_deferred_io_state
|
||||
*/
|
||||
|
|
@ -32,9 +34,13 @@
|
|||
struct fb_deferred_io_state {
|
||||
struct kref ref;
|
||||
|
||||
int open_count; /* number of opened files; protected by fb_info lock */
|
||||
struct address_space *mapping; /* page cache object for fb device */
|
||||
|
||||
struct mutex lock; /* mutex that protects the pageref list */
|
||||
/* fields protected by lock */
|
||||
struct fb_info *info;
|
||||
struct list_head pagereflist; /* list of pagerefs for touched pages */
|
||||
};
|
||||
|
||||
static struct fb_deferred_io_state *fb_deferred_io_state_alloc(void)
|
||||
|
|
@ -48,11 +54,14 @@ static struct fb_deferred_io_state *fb_deferred_io_state_alloc(void)
|
|||
kref_init(&fbdefio_state->ref);
|
||||
mutex_init(&fbdefio_state->lock);
|
||||
|
||||
INIT_LIST_HEAD(&fbdefio_state->pagereflist);
|
||||
|
||||
return fbdefio_state;
|
||||
}
|
||||
|
||||
static void fb_deferred_io_state_release(struct fb_deferred_io_state *fbdefio_state)
|
||||
{
|
||||
WARN_ON(!list_empty(&fbdefio_state->pagereflist));
|
||||
mutex_destroy(&fbdefio_state->lock);
|
||||
|
||||
kfree(fbdefio_state);
|
||||
|
|
@ -147,7 +156,8 @@ static struct fb_deferred_io_pageref *fb_deferred_io_pageref_get(struct fb_info
|
|||
struct page *page)
|
||||
{
|
||||
struct fb_deferred_io *fbdefio = info->fbdefio;
|
||||
struct list_head *pos = &fbdefio->pagereflist;
|
||||
struct fb_deferred_io_state *fbdefio_state = info->fbdefio_state;
|
||||
struct list_head *pos = &fbdefio_state->pagereflist;
|
||||
struct fb_deferred_io_pageref *pageref, *cur;
|
||||
|
||||
pageref = fb_deferred_io_pageref_lookup(info, offset, page);
|
||||
|
|
@ -171,7 +181,7 @@ static struct fb_deferred_io_pageref *fb_deferred_io_pageref_get(struct fb_info
|
|||
* pages. If possible, drivers should try to work with
|
||||
* unsorted page lists instead.
|
||||
*/
|
||||
list_for_each_entry(cur, &fbdefio->pagereflist, list) {
|
||||
list_for_each_entry(cur, &fbdefio_state->pagereflist, list) {
|
||||
if (cur->offset > pageref->offset)
|
||||
break;
|
||||
}
|
||||
|
|
@ -222,7 +232,7 @@ static vm_fault_t fb_deferred_io_fault(struct vm_fault *vmf)
|
|||
if (!vmf->vma->vm_file)
|
||||
fb_err(info, "no mapping available\n");
|
||||
|
||||
BUG_ON(!info->fbdefio->mapping);
|
||||
fb_WARN_ON_ONCE(info, !fbdefio_state->mapping);
|
||||
|
||||
mutex_unlock(&fbdefio_state->lock);
|
||||
|
||||
|
|
@ -364,20 +374,20 @@ static void fb_deferred_io_work(struct work_struct *work)
|
|||
/* here we wrprotect the page's mappings, then do all deferred IO. */
|
||||
mutex_lock(&fbdefio_state->lock);
|
||||
#ifdef CONFIG_MMU
|
||||
list_for_each_entry(pageref, &fbdefio->pagereflist, list) {
|
||||
list_for_each_entry(pageref, &fbdefio_state->pagereflist, list) {
|
||||
struct page *page = pageref->page;
|
||||
pgoff_t pgoff = pageref->offset >> PAGE_SHIFT;
|
||||
|
||||
mapping_wrprotect_range(fbdefio->mapping, pgoff,
|
||||
mapping_wrprotect_range(fbdefio_state->mapping, pgoff,
|
||||
page_to_pfn(page), 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* driver's callback with pagereflist */
|
||||
fbdefio->deferred_io(info, &fbdefio->pagereflist);
|
||||
fbdefio->deferred_io(info, &fbdefio_state->pagereflist);
|
||||
|
||||
/* clear the list */
|
||||
list_for_each_entry_safe(pageref, next, &fbdefio->pagereflist, list)
|
||||
list_for_each_entry_safe(pageref, next, &fbdefio_state->pagereflist, list)
|
||||
fb_deferred_io_pageref_put(pageref, info);
|
||||
|
||||
mutex_unlock(&fbdefio_state->lock);
|
||||
|
|
@ -402,7 +412,6 @@ int fb_deferred_io_init(struct fb_info *info)
|
|||
fbdefio_state->info = info;
|
||||
|
||||
INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
|
||||
INIT_LIST_HEAD(&fbdefio->pagereflist);
|
||||
if (fbdefio->delay == 0) /* set a default of 1 s */
|
||||
fbdefio->delay = HZ;
|
||||
|
||||
|
|
@ -431,11 +440,11 @@ void fb_deferred_io_open(struct fb_info *info,
|
|||
struct inode *inode,
|
||||
struct file *file)
|
||||
{
|
||||
struct fb_deferred_io *fbdefio = info->fbdefio;
|
||||
struct fb_deferred_io_state *fbdefio_state = info->fbdefio_state;
|
||||
|
||||
fbdefio->mapping = file->f_mapping;
|
||||
fbdefio_state->mapping = file->f_mapping;
|
||||
file->f_mapping->a_ops = &fb_deferred_io_aops;
|
||||
fbdefio->open_count++;
|
||||
fbdefio_state->open_count++;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fb_deferred_io_open);
|
||||
|
||||
|
|
@ -446,16 +455,15 @@ static void fb_deferred_io_lastclose(struct fb_info *info)
|
|||
|
||||
void fb_deferred_io_release(struct fb_info *info)
|
||||
{
|
||||
struct fb_deferred_io *fbdefio = info->fbdefio;
|
||||
struct fb_deferred_io_state *fbdefio_state = info->fbdefio_state;
|
||||
|
||||
if (!--fbdefio->open_count)
|
||||
if (!--fbdefio_state->open_count)
|
||||
fb_deferred_io_lastclose(info);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fb_deferred_io_release);
|
||||
|
||||
void fb_deferred_io_cleanup(struct fb_info *info)
|
||||
{
|
||||
struct fb_deferred_io *fbdefio = info->fbdefio;
|
||||
struct fb_deferred_io_state *fbdefio_state = info->fbdefio_state;
|
||||
|
||||
fb_deferred_io_lastclose(info);
|
||||
|
|
@ -469,6 +477,5 @@ void fb_deferred_io_cleanup(struct fb_info *info)
|
|||
fb_deferred_io_state_put(fbdefio_state);
|
||||
|
||||
kvfree(info->pagerefs);
|
||||
fbdefio->mapping = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
|
||||
|
|
|
|||
|
|
@ -217,9 +217,6 @@ struct fb_deferred_io {
|
|||
/* delay between mkwrite and deferred handler */
|
||||
unsigned long delay;
|
||||
bool sort_pagereflist; /* sort pagelist by offset */
|
||||
int open_count; /* number of opened files; protected by fb_info lock */
|
||||
struct list_head pagereflist; /* list of pagerefs for touched pages */
|
||||
struct address_space *mapping; /* page cache object for fb device */
|
||||
/* callback */
|
||||
struct page *(*get_page)(struct fb_info *info, unsigned long offset);
|
||||
void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user