Commit 45b186f1 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm: Constify the drm_mm API

Mark up the pointers as constant through the API where appropriate.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161216074718.32500-5-chris@chris-wilson.co.uk
parent ad579002
...@@ -174,9 +174,9 @@ INTERVAL_TREE_DEFINE(struct drm_mm_node, rb, ...@@ -174,9 +174,9 @@ INTERVAL_TREE_DEFINE(struct drm_mm_node, rb,
START, LAST, static inline, drm_mm_interval_tree) START, LAST, static inline, drm_mm_interval_tree)
struct drm_mm_node * struct drm_mm_node *
__drm_mm_interval_first(struct drm_mm *mm, u64 start, u64 last) __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last)
{ {
return drm_mm_interval_tree_iter_first(&mm->interval_tree, return drm_mm_interval_tree_iter_first((struct rb_root *)&mm->interval_tree,
start, last); start, last);
} }
EXPORT_SYMBOL(__drm_mm_interval_first); EXPORT_SYMBOL(__drm_mm_interval_first);
...@@ -881,9 +881,9 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block); ...@@ -881,9 +881,9 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);
* True if the allocator is completely free, false if there's still a node * True if the allocator is completely free, false if there's still a node
* allocated in it. * allocated in it.
*/ */
bool drm_mm_clean(struct drm_mm * mm) bool drm_mm_clean(const struct drm_mm *mm)
{ {
struct list_head *head = __drm_mm_nodes(mm); const struct list_head *head = __drm_mm_nodes(mm);
return (head->next->next == head); return (head->next->next == head);
} }
...@@ -897,7 +897,7 @@ EXPORT_SYMBOL(drm_mm_clean); ...@@ -897,7 +897,7 @@ EXPORT_SYMBOL(drm_mm_clean);
* *
* Note that @mm must be cleared to 0 before calling this function. * Note that @mm must be cleared to 0 before calling this function.
*/ */
void drm_mm_init(struct drm_mm * mm, u64 start, u64 size) void drm_mm_init(struct drm_mm *mm, u64 start, u64 size)
{ {
INIT_LIST_HEAD(&mm->hole_stack); INIT_LIST_HEAD(&mm->hole_stack);
mm->scanned_blocks = 0; mm->scanned_blocks = 0;
...@@ -936,8 +936,8 @@ void drm_mm_takedown(struct drm_mm *mm) ...@@ -936,8 +936,8 @@ void drm_mm_takedown(struct drm_mm *mm)
} }
EXPORT_SYMBOL(drm_mm_takedown); EXPORT_SYMBOL(drm_mm_takedown);
static u64 drm_mm_debug_hole(struct drm_mm_node *entry, static u64 drm_mm_debug_hole(const struct drm_mm_node *entry,
const char *prefix) const char *prefix)
{ {
u64 hole_start, hole_end, hole_size; u64 hole_start, hole_end, hole_size;
...@@ -958,9 +958,9 @@ static u64 drm_mm_debug_hole(struct drm_mm_node *entry, ...@@ -958,9 +958,9 @@ static u64 drm_mm_debug_hole(struct drm_mm_node *entry,
* @mm: drm_mm allocator to dump * @mm: drm_mm allocator to dump
* @prefix: prefix to use for dumping to dmesg * @prefix: prefix to use for dumping to dmesg
*/ */
void drm_mm_debug_table(struct drm_mm *mm, const char *prefix) void drm_mm_debug_table(const struct drm_mm *mm, const char *prefix)
{ {
struct drm_mm_node *entry; const struct drm_mm_node *entry;
u64 total_used = 0, total_free = 0, total = 0; u64 total_used = 0, total_free = 0, total = 0;
total_free += drm_mm_debug_hole(&mm->head_node, prefix); total_free += drm_mm_debug_hole(&mm->head_node, prefix);
...@@ -979,7 +979,7 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix) ...@@ -979,7 +979,7 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)
EXPORT_SYMBOL(drm_mm_debug_table); EXPORT_SYMBOL(drm_mm_debug_table);
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
static u64 drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry) static u64 drm_mm_dump_hole(struct seq_file *m, const struct drm_mm_node *entry)
{ {
u64 hole_start, hole_end, hole_size; u64 hole_start, hole_end, hole_size;
...@@ -1000,9 +1000,9 @@ static u64 drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry) ...@@ -1000,9 +1000,9 @@ static u64 drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)
* @m: seq_file to dump to * @m: seq_file to dump to
* @mm: drm_mm allocator to dump * @mm: drm_mm allocator to dump
*/ */
int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) int drm_mm_dump_table(struct seq_file *m, const struct drm_mm *mm)
{ {
struct drm_mm_node *entry; const struct drm_mm_node *entry;
u64 total_used = 0, total_free = 0, total = 0; u64 total_used = 0, total_free = 0, total = 0;
total_free += drm_mm_dump_hole(m, &mm->head_node); total_free += drm_mm_dump_hole(m, &mm->head_node);
......
...@@ -2721,7 +2721,7 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj, ...@@ -2721,7 +2721,7 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
dma_unmap_sg(kdev, pages->sgl, pages->nents, PCI_DMA_BIDIRECTIONAL); dma_unmap_sg(kdev, pages->sgl, pages->nents, PCI_DMA_BIDIRECTIONAL);
} }
static void i915_gtt_color_adjust(struct drm_mm_node *node, static void i915_gtt_color_adjust(const struct drm_mm_node *node,
unsigned long color, unsigned long color,
u64 *start, u64 *start,
u64 *end) u64 *end)
......
...@@ -102,7 +102,8 @@ struct drm_mm { ...@@ -102,7 +102,8 @@ struct drm_mm {
u64 scan_end; u64 scan_end;
struct drm_mm_node *prev_scanned_node; struct drm_mm_node *prev_scanned_node;
void (*color_adjust)(struct drm_mm_node *node, unsigned long color, void (*color_adjust)(const struct drm_mm_node *node,
unsigned long color,
u64 *start, u64 *end); u64 *start, u64 *end);
}; };
...@@ -116,7 +117,7 @@ struct drm_mm { ...@@ -116,7 +117,7 @@ struct drm_mm {
* Returns: * Returns:
* True if the @node is allocated. * True if the @node is allocated.
*/ */
static inline bool drm_mm_node_allocated(struct drm_mm_node *node) static inline bool drm_mm_node_allocated(const struct drm_mm_node *node)
{ {
return node->allocated; return node->allocated;
} }
...@@ -131,12 +132,12 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node) ...@@ -131,12 +132,12 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
* Returns: * Returns:
* True if the @mm is initialized. * True if the @mm is initialized.
*/ */
static inline bool drm_mm_initialized(struct drm_mm *mm) static inline bool drm_mm_initialized(const struct drm_mm *mm)
{ {
return mm->hole_stack.next; return mm->hole_stack.next;
} }
static inline u64 __drm_mm_hole_node_start(struct drm_mm_node *hole_node) static inline u64 __drm_mm_hole_node_start(const struct drm_mm_node *hole_node)
{ {
return hole_node->start + hole_node->size; return hole_node->start + hole_node->size;
} }
...@@ -152,13 +153,13 @@ static inline u64 __drm_mm_hole_node_start(struct drm_mm_node *hole_node) ...@@ -152,13 +153,13 @@ static inline u64 __drm_mm_hole_node_start(struct drm_mm_node *hole_node)
* Returns: * Returns:
* Start of the subsequent hole. * Start of the subsequent hole.
*/ */
static inline u64 drm_mm_hole_node_start(struct drm_mm_node *hole_node) static inline u64 drm_mm_hole_node_start(const struct drm_mm_node *hole_node)
{ {
BUG_ON(!hole_node->hole_follows); BUG_ON(!hole_node->hole_follows);
return __drm_mm_hole_node_start(hole_node); return __drm_mm_hole_node_start(hole_node);
} }
static inline u64 __drm_mm_hole_node_end(struct drm_mm_node *hole_node) static inline u64 __drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
{ {
return list_next_entry(hole_node, node_list)->start; return list_next_entry(hole_node, node_list)->start;
} }
...@@ -174,7 +175,7 @@ static inline u64 __drm_mm_hole_node_end(struct drm_mm_node *hole_node) ...@@ -174,7 +175,7 @@ static inline u64 __drm_mm_hole_node_end(struct drm_mm_node *hole_node)
* Returns: * Returns:
* End of the subsequent hole. * End of the subsequent hole.
*/ */
static inline u64 drm_mm_hole_node_end(struct drm_mm_node *hole_node) static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
{ {
return __drm_mm_hole_node_end(hole_node); return __drm_mm_hole_node_end(hole_node);
} }
...@@ -314,14 +315,12 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm, ...@@ -314,14 +315,12 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,
void drm_mm_remove_node(struct drm_mm_node *node); void drm_mm_remove_node(struct drm_mm_node *node);
void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new); void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
void drm_mm_init(struct drm_mm *mm, void drm_mm_init(struct drm_mm *mm, u64 start, u64 size);
u64 start,
u64 size);
void drm_mm_takedown(struct drm_mm *mm); void drm_mm_takedown(struct drm_mm *mm);
bool drm_mm_clean(struct drm_mm *mm); bool drm_mm_clean(const struct drm_mm *mm);
struct drm_mm_node * struct drm_mm_node *
__drm_mm_interval_first(struct drm_mm *mm, u64 start, u64 last); __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);
/** /**
* drm_mm_for_each_node_in_range - iterator to walk over a range of * drm_mm_for_each_node_in_range - iterator to walk over a range of
...@@ -355,9 +354,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm, ...@@ -355,9 +354,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm,
bool drm_mm_scan_add_block(struct drm_mm_node *node); bool drm_mm_scan_add_block(struct drm_mm_node *node);
bool drm_mm_scan_remove_block(struct drm_mm_node *node); bool drm_mm_scan_remove_block(struct drm_mm_node *node);
void drm_mm_debug_table(struct drm_mm *mm, const char *prefix); void drm_mm_debug_table(const struct drm_mm *mm, const char *prefix);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm); int drm_mm_dump_table(struct seq_file *m, const struct drm_mm *mm);
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment