aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorDevin Heitmueller <dheitmueller@kernellabs.com>2011-10-31 11:24:41 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-03 05:43:00 -0400
commite54d081dacdcdee7d10c1f87bacce89044519c5c (patch)
tree038d5c5ac3015325d132725c5feb79e56a6b8b0a /drivers/staging
parentc6ccdca9801604e9e2797677f1a78c2c534b2f1f (diff)
[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: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Piotr Chmura <chmooreck@poczta.onet.pl> Signed-off-by: Sylwester Nawrocki <snjw23@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/as102/as102_fw.c101
1 files changed, 58 insertions, 43 deletions
diff --git a/drivers/staging/media/as102/as102_fw.c b/drivers/staging/media/as102/as102_fw.c
index d921a6fd695..c019df933cc 100644
--- a/drivers/staging/media/as102/as102_fw.c
+++ b/drivers/staging/media/as102/as102_fw.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Abilis Systems Single DVB-T Receiver 2 * Abilis Systems Single DVB-T Receiver
3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com> 3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
4 * Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.com>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 7 * 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";
31char as102_dt_fw1[] = "as102_data1_dt.hex"; 32char as102_dt_fw1[] = "as102_data1_dt.hex";
32char as102_dt_fw2[] = "as102_data2_dt.hex"; 33char as102_dt_fw2[] = "as102_data2_dt.hex";
33 34
34static unsigned char atohx(unsigned char *dst, char *src) { 35static unsigned char atohx(unsigned char *dst, char *src)
36{
35 unsigned char value = 0; 37 unsigned char value = 0;
36 38
37 char msb = tolower(*src) - '0'; 39 char msb = tolower(*src) - '0';
38 char lsb = tolower(*(src +1)) - '0'; 40 char lsb = tolower(*(src + 1)) - '0';
39 41
40 if (msb > 9 ) 42 if (msb > 9)
41 msb -= 7; 43 msb -= 7;
42 if (lsb > 9 ) 44 if (lsb > 9)
43 lsb -= 7; 45 lsb -= 7;
44 46
45 *dst = value = ((msb & 0xF) << 4) | (lsb & 0xF); 47 *dst = value = ((msb & 0xF) << 4) | (lsb & 0xF);
@@ -62,43 +64,42 @@ static int parse_hex_line(unsigned char *fw_data, unsigned char *addr,
62 } 64 }
63 65
64 /* locate end of line */ 66 /* locate end of line */
65 for (src=fw_data; *src != '\n'; src += 2) { 67 for (src = fw_data; *src != '\n'; src += 2) {
66 atohx(&dst, src); 68 atohx(&dst, src);
67 /* parse line to split addr / data */ 69 /* parse line to split addr / data */
68 switch (count) { 70 switch (count) {
69 case 0: 71 case 0:
70 *dataLength = dst; 72 *dataLength = dst;
71 break; 73 break;
72 case 1: 74 case 1:
73 addr[2] = dst; 75 addr[2] = dst;
74 break; 76 break;
75 case 2: 77 case 2:
76 addr[3] = dst; 78 addr[3] = dst;
77 break; 79 break;
78 case 3: 80 case 3:
79 /* check if data is an address */ 81 /* check if data is an address */
80 if (dst == 0x04) 82 if (dst == 0x04)
81 *addr_has_changed = 1; 83 *addr_has_changed = 1;
82 else 84 else
83 *addr_has_changed = 0; 85 *addr_has_changed = 0;
84 break; 86 break;
85 case 4: 87 case 4:
86 case 5: 88 case 5:
87 if (*addr_has_changed) { 89 if (*addr_has_changed)
88 addr[(count - 4)] = dst; 90 addr[(count - 4)] = dst;
89 } else { 91 else
90 data[(count - 4)] = dst;
91 }
92 break;
93 default:
94 data[(count - 4)] = dst; 92 data[(count - 4)] = dst;
95 break; 93 break;
94 default:
95 data[(count - 4)] = dst;
96 break;
96 } 97 }
97 count++; 98 count++;
98 } 99 }
99 100
100 /* return read value + ':' + '\n' */ 101 /* return read value + ':' + '\n' */
101 return ((count * 2) + 2); 102 return (count * 2) + 2;
102} 103}
103 104
104static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap, 105static 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 &data_len, 123 &data_len,
123 &addr_has_changed); 124 &addr_has_changed);
124 125
125 if (read_bytes <= 0) { 126 if (read_bytes <= 0)
126 goto error; 127 goto error;
127 }
128 128
129 /* detect the end of file */ 129 /* detect the end of file */
130 if ((total_read_bytes += read_bytes) == firmware->size) { 130 total_read_bytes += read_bytes;
131 if (total_read_bytes == firmware->size) {
131 fw_pkt.u.request[0] = 0x00; 132 fw_pkt.u.request[0] = 0x00;
132 fw_pkt.u.request[1] = 0x03; 133 fw_pkt.u.request[1] = 0x03;
133 134
134 /* send EOF command */ 135 /* send EOF command */
135 if ((errno = bus_adap->ops->upload_fw_pkt(bus_adap,(uint8_t *) &fw_pkt, 2, 0)) < 0) 136 errno = bus_adap->ops->upload_fw_pkt(bus_adap,
137 (uint8_t *)
138 &fw_pkt, 2, 0);
139 if (errno < 0)
136 goto error; 140 goto error;
137 } else { 141 } else {
138 if (!addr_has_changed) { 142 if (!addr_has_changed) {
@@ -144,7 +148,12 @@ static int as102_firmware_upload(struct as102_bus_adapter_t *bus_adap,
144 data_len += sizeof(fw_pkt.raw.address); 148 data_len += sizeof(fw_pkt.raw.address);
145 149
146 /* send cmd to device */ 150 /* send cmd to device */
147 if ((errno = bus_adap->ops->upload_fw_pkt(bus_adap, (uint8_t *) &fw_pkt, data_len, 0)) < 0) 151 errno = bus_adap->ops->upload_fw_pkt(bus_adap,
152 (uint8_t *)
153 &fw_pkt,
154 data_len,
155 0);
156 if (errno < 0)
148 goto error; 157 goto error;
149 } 158 }
150 } 159 }
@@ -154,7 +163,8 @@ error:
154 return (errno == 0) ? total_read_bytes : errno; 163 return (errno == 0) ? total_read_bytes : errno;
155} 164}
156 165
157int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) { 166int as102_fw_upload(struct as102_bus_adapter_t *bus_adap)
167{
158 int errno = -EFAULT; 168 int errno = -EFAULT;
159 const struct firmware *firmware; 169 const struct firmware *firmware;
160 unsigned char *cmd_buf = NULL; 170 unsigned char *cmd_buf = NULL;
@@ -179,20 +189,23 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) {
179 189
180#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) 190#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
181 /* allocate buffer to store firmware upload command and data */ 191 /* allocate buffer to store firmware upload command and data */
182 if ((cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL)) == NULL) { 192 cmd_buf = kzalloc(MAX_FW_PKT_SIZE, GFP_KERNEL);
193 if (cmd_buf == NULL) {
183 errno = -ENOMEM; 194 errno = -ENOMEM;
184 goto error; 195 goto error;
185 } 196 }
186 197
187 /* request kernel to locate firmware file: part1 */ 198 /* request kernel to locate firmware file: part1 */
188 if ((errno = request_firmware(&firmware, fw1, &dev->dev)) < 0) { 199 errno = request_firmware(&firmware, fw1, &dev->dev);
200 if (errno < 0) {
189 printk(KERN_ERR "%s: unable to locate firmware file: %s\n", 201 printk(KERN_ERR "%s: unable to locate firmware file: %s\n",
190 DRIVER_NAME, fw1); 202 DRIVER_NAME, fw1);
191 goto error; 203 goto error;
192 } 204 }
193 205
194 /* initiate firmware upload */ 206 /* initiate firmware upload */
195 if ((errno = as102_firmware_upload(bus_adap, cmd_buf, firmware)) < 0) { 207 errno = as102_firmware_upload(bus_adap, cmd_buf, firmware);
208 if (errno < 0) {
196 printk(KERN_ERR "%s: error during firmware upload part1\n", 209 printk(KERN_ERR "%s: error during firmware upload part1\n",
197 DRIVER_NAME); 210 DRIVER_NAME);
198 goto error; 211 goto error;
@@ -206,14 +219,16 @@ int as102_fw_upload(struct as102_bus_adapter_t *bus_adap) {
206 mdelay(100); 219 mdelay(100);
207 220
208 /* request kernel to locate firmware file: part2 */ 221 /* request kernel to locate firmware file: part2 */
209 if ((errno = request_firmware(&firmware, fw2, &dev->dev)) < 0) { 222 errno = request_firmware(&firmware, fw2, &dev->dev);
223 if (errno < 0) {
210 printk(KERN_ERR "%s: unable to locate firmware file: %s\n", 224 printk(KERN_ERR "%s: unable to locate firmware file: %s\n",
211 DRIVER_NAME, fw2); 225 DRIVER_NAME, fw2);
212 goto error; 226 goto error;
213 } 227 }
214 228
215 /* initiate firmware upload */ 229 /* initiate firmware upload */
216 if ((errno = as102_firmware_upload(bus_adap, cmd_buf, firmware)) < 0) { 230 errno = as102_firmware_upload(bus_adap, cmd_buf, firmware);
231 if (errno < 0) {
217 printk(KERN_ERR "%s: error during firmware upload part2\n", 232 printk(KERN_ERR "%s: error during firmware upload part2\n",
218 DRIVER_NAME); 233 DRIVER_NAME);
219 goto error; 234 goto error;