Commit 3bf3f452 authored by Ben Widawsky's avatar Ben Widawsky Committed by Daniel Vetter

drm/i915: [sparse] don't use variable size arrays

Sparse doesn't like:
"error: bad constant expression"
Signed-off-by: default avatarBen Widawsky <benjamin.widawsky@intel.com>
[danvet: apply s/drm_malloc_ab/kcalloc bikeshed. If it's small enough
for the stack, it's small enough for kmalloc.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent c43b5634
...@@ -443,9 +443,17 @@ static const char *cmd_status_names[] = { ...@@ -443,9 +443,17 @@ static const char *cmd_status_names[] = {
static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd, static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd,
const void *args, int args_len) const void *args, int args_len)
{ {
u8 buf[args_len*2 + 2], status; u8 *buf, status;
struct i2c_msg msgs[args_len + 3]; struct i2c_msg *msgs;
int i, ret; int i, ret = true;
buf = (u8 *)kzalloc(args_len * 2 + 2, GFP_KERNEL);
if (!buf)
return false;
msgs = kcalloc(args_len + 3, sizeof(*msgs), GFP_KERNEL);
if (!msgs)
return false;
intel_sdvo_debug_write(intel_sdvo, cmd, args, args_len); intel_sdvo_debug_write(intel_sdvo, cmd, args, args_len);
...@@ -479,15 +487,19 @@ static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd, ...@@ -479,15 +487,19 @@ static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd,
ret = i2c_transfer(intel_sdvo->i2c, msgs, i+3); ret = i2c_transfer(intel_sdvo->i2c, msgs, i+3);
if (ret < 0) { if (ret < 0) {
DRM_DEBUG_KMS("I2c transfer returned %d\n", ret); DRM_DEBUG_KMS("I2c transfer returned %d\n", ret);
return false; ret = false;
goto out;
} }
if (ret != i+3) { if (ret != i+3) {
/* failure in I2C transfer */ /* failure in I2C transfer */
DRM_DEBUG_KMS("I2c transfer returned %d/%d\n", ret, i+3); DRM_DEBUG_KMS("I2c transfer returned %d/%d\n", ret, i+3);
return false; ret = false;
} }
return true; out:
kfree(msgs);
kfree(buf);
return ret;
} }
static bool intel_sdvo_read_response(struct intel_sdvo *intel_sdvo, static bool intel_sdvo_read_response(struct intel_sdvo *intel_sdvo,
......
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