Commit e54d081d authored by Devin Heitmueller's avatar Devin Heitmueller Committed by Mauro Carvalho Chehab

[media] staging: as102: Fix CodingStyle errors in file as102_fw.c

Fix Linux kernel coding style (whitespace and indentation) errors
in file as102_fw.c. No functional changes.
Signed-off-by: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: default avatarPiotr Chmura <chmooreck@poczta.onet.pl>
Signed-off-by: default avatarSylwester Nawrocki <snjw23@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c6ccdca9
/* /*
* Abilis Systems Single DVB-T Receiver * Abilis Systems Single DVB-T Receiver
* Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com> * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
* Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,15 +32,16 @@ char as102_st_fw2[] = "as102_data2_st.hex"; ...@@ -31,15 +32,16 @@ char as102_st_fw2[] = "as102_data2_st.hex";
char as102_dt_fw1[] = "as102_data1_dt.hex"; char as102_dt_fw1[] = "as102_data1_dt.hex";
char as102_dt_fw2[] = "as102_data2_dt.hex"; char as102_dt_fw2[] = "as102_data2_dt.hex";
static unsigned char atohx(unsigned char *dst, char *src) { static unsigned char atohx(unsigned char *dst, char *src)
{
unsigned char value = 0; unsigned char value = 0;
char msb = tolower(*src) - '0'; char msb = tolower(*src) - '0';
char lsb = tolower(*(src +1)) - '0'; char lsb = tolower(*(src + 1)) - '0';
if (msb > 9 ) if (msb > 9)
msb -= 7; msb -= 7;
if (lsb > 9 ) if (lsb > 9)
lsb -= 7; lsb -= 7;
*dst = value = ((msb & 0xF) << 4) | (lsb & 0xF); *dst = value = ((msb & 0xF) << 4) | (lsb & 0xF);
...@@ -62,43 +64,42 @@ static int parse_hex_line(unsigned char *fw_data, unsigned char *addr, ...@@ -62,43 +64,42 @@ static int parse_hex_line(unsigned char *fw_data, unsigned char *addr,
} }
/* locate end of line */ /* locate end of line */
for (src=fw_data; *src != '\n'; src += 2) { for (src = fw_data; *src != '\n'; src += 2) {
atohx(&dst, src); atohx(&dst, src);
/* parse line to split addr / data */ /* parse line to split addr / data */
switch (count) { switch (count) {
case 0: case 0:
*dataLength = dst; *dataLength = dst;
break; break;
case 1: case 1:
addr[2] = dst; addr[2] = dst;
break; break;
case 2: case 2:
addr[3] = dst; addr[3] = dst;
break; break;
case 3: case 3:
/* check if data is an address */ /* check if data is an address */
if (dst == 0x04) if (dst == 0x04)
*addr_has_changed = 1; *addr_has_changed = 1;
else else
*addr_has_changed = 0; *addr_has_changed = 0;
break; break;
case 4: case 4:
case 5: case 5:
if (*addr_has_changed) { if (*addr_has_changed)
addr[(count - 4)] = dst; addr[(count - 4)] = dst;
} else { else
data[(count - 4)] = dst;
}
break;
default:
data[(count - 4)] = dst; data[(count - 4)] = dst;
break; break;
default:
data[(count - 4)] = dst;
break;
} }
count++; count++;
} }
/* return read value + ':' + '\n' */ /* return read value + ':' + '\n' */
return ((count * 2) + 2); return (count * 2) + 2;
} }
static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap, static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap,
...@@ -122,17 +123,20 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap, ...@@ -122,17 +123,20 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap,
&data_len, &data_len,
&addr_has_changed); &addr_has_changed);
if (read_bytes <= 0) { if (read_bytes <= 0)
goto error; goto error;
}
/* detect the end of file */ /* detect the end of file */
if ((total_read_bytes += read_bytes) == firmware->size) { total_read_bytes += read_bytes;
if (total_read_bytes == firmware->size) {
fw_pkt.u.request[0] = 0x00; fw_pkt.u.request[0] = 0x00;
fw_pkt.u.request[1] = 0x03; fw_pkt.u.request[1] = 0x03;
/* send EOF command */ /* send EOF command */
if ((errno = bus_adap->ops->upload_fw_pkt(bus_adap,(uint8_t *) &fw_pkt, 2, 0)) < 0) errno = bus_adap->ops->upload_fw_pkt(bus_adap,
(uint8_t *)
&fw_pkt, 2, 0);
if (errno < 0)
goto error; goto error;
} else { } else {
if (!addr_has_changed) { if (!addr_has_changed) {
...@@ -144,7 +148,12 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap, ...@@ -144,7 +148,12 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap,
data_len += sizeof(fw_pkt.raw.address); data_len += sizeof(fw_pkt.raw.address);
/* send cmd to device */ /* send cmd to device */
if ((errno = bus_adap->ops->upload_fw_pkt(bus_adap, (uint8_t *) &fw_pkt, data_len, 0)) < 0) errno = bus_adap->ops->upload_fw_pkt(bus_adap,
(uint8_t *)
&fw_pkt,
data_len,
0);
if (errno < 0)
goto error; goto error;
} }
} }
...@@ -154,7 +163,8 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap, ...@@ -154,7 +163,8 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap,
return (errno == 0) ? total_read_bytes : errno; return (errno == 0) ? total_read_bytes : errno;
} }
int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) { int as102_fw_upload(struct as102_bus_adapter_t *bus_adap)
{
int errno = -EFAULT; int errno = -EFAULT;
const struct firmware *firmware; const struct firmware *firmware;
unsigned char *cmd_buf = NULL; unsigned char *cmd_buf = NULL;
...@@ -179,20 +189,23 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) { ...@@ -179,20 +189,23 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) {
#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
/* allocate buffer to store firmware upload command and data */ /* allocate buffer to store firmware upload command and data */
if ((cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL)) == NULL) { cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL);
if (cmd_buf == NULL) {
errno = -ENOMEM; errno = -ENOMEM;
goto error; goto error;
} }
/* request kernel to locate firmware file: part1 */ /* request kernel to locate firmware file: part1 */
if ((errno = request_firmware(&firmware, fw1, &dev->dev)) < 0) { errno = request_firmware(&firmware, fw1, &dev->dev);
if (errno < 0) {
printk(KERN_ERR "%s: unable to locate firmware file: %s\n", printk(KERN_ERR "%s: unable to locate firmware file: %s\n",
DRIVER_NAME, fw1); DRIVER_NAME, fw1);
goto error; goto error;
} }
/* initiate firmware upload */ /* initiate firmware upload */
if ((errno = as102_firmware_upload(bus_adap, cmd_buf, firmware)) < 0) { errno = as102_firmware_upload(bus_adap, cmd_buf, firmware);
if (errno < 0) {
printk(KERN_ERR "%s: error during firmware upload part1\n", printk(KERN_ERR "%s: error during firmware upload part1\n",
DRIVER_NAME); DRIVER_NAME);
goto error; goto error;
...@@ -206,14 +219,16 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) { ...@@ -206,14 +219,16 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) {
mdelay(100); mdelay(100);
/* request kernel to locate firmware file: part2 */ /* request kernel to locate firmware file: part2 */
if ((errno = request_firmware(&firmware, fw2, &dev->dev)) < 0) { errno = request_firmware(&firmware, fw2, &dev->dev);
if (errno < 0) {
printk(KERN_ERR "%s: unable to locate firmware file: %s\n", printk(KERN_ERR "%s: unable to locate firmware file: %s\n",
DRIVER_NAME, fw2); DRIVER_NAME, fw2);
goto error; goto error;
} }
/* initiate firmware upload */ /* initiate firmware upload */
if ((errno = as102_firmware_upload(bus_adap, cmd_buf, firmware)) < 0) { errno = as102_firmware_upload(bus_adap, cmd_buf, firmware);
if (errno < 0) {
printk(KERN_ERR "%s: error during firmware upload part2\n", printk(KERN_ERR "%s: error during firmware upload part2\n",
DRIVER_NAME); DRIVER_NAME);
goto error; goto error;
......
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