diff options
author | Mika Kuoppala <mika.kuoppala@linux.intel.com> | 2013-06-06 08:18:41 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-07-01 13:38:20 -0400 |
commit | 4dc955f7f5241a92767e2b3ffd74f49a82938999 (patch) | |
tree | 280abceaf998fa9f4797102db5f897972150e969 /drivers/gpu/drm/i915/i915_debugfs.c | |
parent | 95d5bfb3ac4cf5d7311f496761506c676f6b6323 (diff) |
drm/i915: introduce i915_error_state_buf_init
Make function for struct i915_error_state_buf initialization
and export it, for sysfs and debugfs.
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_debugfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index eef4c01ab61a..3e36756d0439 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1028,38 +1028,48 @@ static int i915_error_state_release(struct inode *inode, struct file *file) | |||
1028 | return 0; | 1028 | return 0; |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, | 1031 | int i915_error_state_buf_init(struct drm_i915_error_state_buf *ebuf, |
1032 | size_t count, loff_t *pos) | 1032 | size_t count, loff_t pos) |
1033 | { | 1033 | { |
1034 | struct i915_error_state_file_priv *error_priv = file->private_data; | 1034 | memset(ebuf, 0, sizeof(*ebuf)); |
1035 | struct drm_i915_error_state_buf error_str; | ||
1036 | loff_t tmp_pos = 0; | ||
1037 | ssize_t ret_count = 0; | ||
1038 | int ret = 0; | ||
1039 | |||
1040 | memset(&error_str, 0, sizeof(error_str)); | ||
1041 | 1035 | ||
1042 | /* We need to have enough room to store any i915_error_state printf | 1036 | /* We need to have enough room to store any i915_error_state printf |
1043 | * so that we can move it to start position. | 1037 | * so that we can move it to start position. |
1044 | */ | 1038 | */ |
1045 | error_str.size = count + 1 > PAGE_SIZE ? count + 1 : PAGE_SIZE; | 1039 | ebuf->size = count + 1 > PAGE_SIZE ? count + 1 : PAGE_SIZE; |
1046 | error_str.buf = kmalloc(error_str.size, | 1040 | ebuf->buf = kmalloc(ebuf->size, |
1047 | GFP_TEMPORARY | __GFP_NORETRY | __GFP_NOWARN); | 1041 | GFP_TEMPORARY | __GFP_NORETRY | __GFP_NOWARN); |
1048 | 1042 | ||
1049 | if (error_str.buf == NULL) { | 1043 | if (ebuf->buf == NULL) { |
1050 | error_str.size = PAGE_SIZE; | 1044 | ebuf->size = PAGE_SIZE; |
1051 | error_str.buf = kmalloc(error_str.size, GFP_TEMPORARY); | 1045 | ebuf->buf = kmalloc(ebuf->size, GFP_TEMPORARY); |
1052 | } | 1046 | } |
1053 | 1047 | ||
1054 | if (error_str.buf == NULL) { | 1048 | if (ebuf->buf == NULL) { |
1055 | error_str.size = 128; | 1049 | ebuf->size = 128; |
1056 | error_str.buf = kmalloc(error_str.size, GFP_TEMPORARY); | 1050 | ebuf->buf = kmalloc(ebuf->size, GFP_TEMPORARY); |
1057 | } | 1051 | } |
1058 | 1052 | ||
1059 | if (error_str.buf == NULL) | 1053 | if (ebuf->buf == NULL) |
1060 | return -ENOMEM; | 1054 | return -ENOMEM; |
1061 | 1055 | ||
1062 | error_str.start = *pos; | 1056 | ebuf->start = pos; |
1057 | |||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, | ||
1062 | size_t count, loff_t *pos) | ||
1063 | { | ||
1064 | struct i915_error_state_file_priv *error_priv = file->private_data; | ||
1065 | struct drm_i915_error_state_buf error_str; | ||
1066 | loff_t tmp_pos = 0; | ||
1067 | ssize_t ret_count = 0; | ||
1068 | int ret; | ||
1069 | |||
1070 | ret = i915_error_state_buf_init(&error_str, count, *pos); | ||
1071 | if (ret) | ||
1072 | return ret; | ||
1063 | 1073 | ||
1064 | ret = i915_error_state_to_str(&error_str, error_priv); | 1074 | ret = i915_error_state_to_str(&error_str, error_priv); |
1065 | if (ret) | 1075 | if (ret) |
@@ -1074,7 +1084,7 @@ static ssize_t i915_error_state_read(struct file *file, char __user *userbuf, | |||
1074 | else | 1084 | else |
1075 | *pos = error_str.start + ret_count; | 1085 | *pos = error_str.start + ret_count; |
1076 | out: | 1086 | out: |
1077 | kfree(error_str.buf); | 1087 | i915_error_state_buf_release(&error_str); |
1078 | return ret ?: ret_count; | 1088 | return ret ?: ret_count; |
1079 | } | 1089 | } |
1080 | 1090 | ||