Skip to content

Commit

Permalink
drm: omapdrm: gem: Remove forward declarations
Browse files Browse the repository at this point in the history
Reorder functions to get rid of forward declarations

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
  • Loading branch information
Laurent Pinchart authored and Tomi Valkeinen committed Dec 31, 2015
1 parent 6405e41 commit b902f8f
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions drivers/gpu/drm/omapdrm/omap_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ struct omap_gem_object {
} *sync;
};

static int get_pages(struct drm_gem_object *obj, struct page ***pages);
static uint64_t mmap_offset(struct drm_gem_object *obj);

/* To deal with userspace mmap'ings of 2d tiled buffers, which (a) are
* not necessarily pinned in TILER all the time, and (b) when they are
Expand Down Expand Up @@ -144,6 +142,30 @@ static struct {
int last; /* index of last used entry */
} *usergart;

/* -----------------------------------------------------------------------------
* Helpers
*/

/** get mmap offset */
static uint64_t mmap_offset(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
int ret;
size_t size;

WARN_ON(!mutex_is_locked(&dev->struct_mutex));

/* Make it mmapable */
size = omap_gem_mmap_size(obj);
ret = drm_gem_create_mmap_offset_size(obj, size);
if (ret) {
dev_err(dev->dev, "could not allocate mmap offset\n");
return 0;
}

return drm_vma_node_offset_addr(&obj->vma_node);
}

static void evict_entry(struct drm_gem_object *obj,
enum tiler_fmt fmt, struct usergart_entry *entry)
{
Expand Down Expand Up @@ -266,6 +288,28 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
return ret;
}

/* acquire pages when needed (for example, for DMA where physically
* contiguous buffer is not required
*/
static int get_pages(struct drm_gem_object *obj, struct page ***pages)
{
struct omap_gem_object *omap_obj = to_omap_bo(obj);
int ret = 0;

if (is_shmem(obj) && !omap_obj->pages) {
ret = omap_gem_attach_pages(obj);
if (ret) {
dev_err(obj->dev->dev, "could not attach pages\n");
return ret;
}
}

/* TODO: even phys-contig.. we should have a list of pages? */
*pages = omap_obj->pages;

return 0;
}

/** release backing pages */
static void omap_gem_detach_pages(struct drm_gem_object *obj)
{
Expand Down Expand Up @@ -295,26 +339,6 @@ uint32_t omap_gem_flags(struct drm_gem_object *obj)
return to_omap_bo(obj)->flags;
}

/** get mmap offset */
static uint64_t mmap_offset(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
int ret;
size_t size;

WARN_ON(!mutex_is_locked(&dev->struct_mutex));

/* Make it mmapable */
size = omap_gem_mmap_size(obj);
ret = drm_gem_create_mmap_offset_size(obj, size);
if (ret) {
dev_err(dev->dev, "could not allocate mmap offset\n");
return 0;
}

return drm_vma_node_offset_addr(&obj->vma_node);
}

uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj)
{
uint64_t offset;
Expand Down Expand Up @@ -861,28 +885,6 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient)
return ret;
}

/* acquire pages when needed (for example, for DMA where physically
* contiguous buffer is not required
*/
static int get_pages(struct drm_gem_object *obj, struct page ***pages)
{
struct omap_gem_object *omap_obj = to_omap_bo(obj);
int ret = 0;

if (is_shmem(obj) && !omap_obj->pages) {
ret = omap_gem_attach_pages(obj);
if (ret) {
dev_err(obj->dev->dev, "could not attach pages\n");
return ret;
}
}

/* TODO: even phys-contig.. we should have a list of pages? */
*pages = omap_obj->pages;

return 0;
}

/* if !remap, and we don't have pages backing, then fail, rather than
* increasing the pin count (which we don't really do yet anyways,
* because we don't support swapping pages back out). And 'remap'
Expand Down

0 comments on commit b902f8f

Please sign in to comment.