Commit 747a64bd authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman

staging: vt6656: Remove memory buffer from vnt_download_firmware.

The memory buffer is being done twice here as vnt_control_out passes
it straight to kmemdup.

Remove buffer and add const to the variable in vnt_control_out to pass
the pointer to it.
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/be025ed0-204d-e957-4bc9-963e841fcb2c@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1ca9c731
......@@ -30,7 +30,6 @@ int vnt_download_firmware(struct vnt_private *priv)
{
struct device *dev = &priv->usb->dev;
const struct firmware *fw;
void *buffer = NULL;
u16 length;
int ii;
int ret = 0;
......@@ -44,26 +43,17 @@ int vnt_download_firmware(struct vnt_private *priv)
goto end;
}
buffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
if (!buffer) {
ret = -ENOMEM;
goto free_fw;
}
for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
memcpy(buffer, fw->data + ii, length);
ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length,
buffer);
fw->data + ii);
if (ret)
goto free_buffer;
goto free_fw;
dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
}
free_buffer:
kfree(buffer);
free_fw:
release_firmware(fw);
end:
......
......@@ -34,7 +34,7 @@
#define USB_CTL_WAIT 500 /* ms */
int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer)
u16 index, u16 length, const u8 *buffer)
{
int ret = 0;
u8 *usb_buffer;
......
......@@ -21,7 +21,7 @@
#define VNT_REG_BLOCK_SIZE 64
int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer);
u16 index, u16 length, const u8 *buffer);
int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer);
......
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