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: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/be025ed0-204d-e957-4bc9-963e841fcb2c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Malcolm Priestley 2020-01-19 12:04:34 +00:00 committed by Greg Kroah-Hartman
parent 1ca9c73105
commit 747a64bd01
3 changed files with 4 additions and 14 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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);