aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c243
-rw-r--r--drivers/media/dvb/siano/smscoreapi.h299
-rw-r--r--drivers/media/dvb/siano/smsdvb.c70
-rw-r--r--drivers/media/dvb/siano/smsusb.c62
4 files changed, 256 insertions, 418 deletions
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index d82aafacfb1a..e3c6d9cb5621 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -50,33 +50,27 @@
50#define PWARNING(fmt, args...) 50#define PWARNING(fmt, args...)
51#endif 51#endif
52 52
53typedef struct _smscore_device_notifyee 53struct smscore_device_notifyee_t {
54{
55 struct list_head entry; 54 struct list_head entry;
56 hotplug_t hotplug; 55 hotplug_t hotplug;
57} smscore_device_notifyee_t; 56};
58 57
59typedef struct _smscore_subclient 58struct smscore_idlist_t {
60{
61 struct list_head entry; 59 struct list_head entry;
62 int id; 60 int id;
63 int data_type; 61 int data_type;
64} smscore_idlist_t; 62};
65 63
66typedef struct _smscore_client 64struct smscore_client_t {
67{
68 struct list_head entry; 65 struct list_head entry;
69 smscore_device_t *coredev; 66 struct smscore_device_t *coredev;
70 void *context; 67 void *context;
71 struct list_head idlist; 68 struct list_head idlist;
72 onresponse_t onresponse_handler; 69 onresponse_t onresponse_handler;
73 onremove_t onremove_handler; 70 onremove_t onremove_handler;
74} *psmscore_client_t; 71};
75
76
77 72
78typedef struct _smscore_device 73struct smscore_device_t {
79{
80 struct list_head entry; 74 struct list_head entry;
81 75
82 struct list_head clients; 76 struct list_head clients;
@@ -107,15 +101,14 @@ typedef struct _smscore_device
107 101
108 struct completion version_ex_done, data_download_done, trigger_done; 102 struct completion version_ex_done, data_download_done, trigger_done;
109 struct completion init_device_done, reload_start_done, resume_done; 103 struct completion init_device_done, reload_start_done, resume_done;
110} *psmscore_device_t; 104};
111 105
112typedef struct _smscore_registry_entry 106struct smscore_registry_entry_t {
113{
114 struct list_head entry; 107 struct list_head entry;
115 char devpath[32]; 108 char devpath[32];
116 int mode; 109 int mode;
117 sms_device_type_st type; 110 enum sms_device_type_st type;
118} smscore_registry_entry_t; 111};
119 112
120struct list_head g_smscore_notifyees; 113struct list_head g_smscore_notifyees;
121struct list_head g_smscore_devices; 114struct list_head g_smscore_devices;
@@ -129,23 +122,24 @@ static int default_mode = 1;
129module_param(default_mode, int, 0644); 122module_param(default_mode, int, 0644);
130MODULE_PARM_DESC(default_mode, "default firmware id (device mode)"); 123MODULE_PARM_DESC(default_mode, "default firmware id (device mode)");
131 124
132static smscore_registry_entry_t *smscore_find_registry(char *devpath) 125static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
133{ 126{
134 smscore_registry_entry_t *entry; 127 struct smscore_registry_entry_t *entry;
135 struct list_head *next; 128 struct list_head *next;
136 129
137 kmutex_lock(&g_smscore_registrylock); 130 kmutex_lock(&g_smscore_registrylock);
138 for (next = g_smscore_registry.next; 131 for (next = g_smscore_registry.next;
139 next != &g_smscore_registry; 132 next != &g_smscore_registry;
140 next = next->next) { 133 next = next->next) {
141 entry = (smscore_registry_entry_t *) next; 134 entry = (struct smscore_registry_entry_t *) next;
142 if (!strcmp(entry->devpath, devpath)) { 135 if (!strcmp(entry->devpath, devpath)) {
143 kmutex_unlock(&g_smscore_registrylock); 136 kmutex_unlock(&g_smscore_registrylock);
144 return entry; 137 return entry;
145 } 138 }
146 } 139 }
147 entry = (smscore_registry_entry_t *) 140 entry = (struct smscore_registry_entry_t *)
148 kmalloc(sizeof(smscore_registry_entry_t), GFP_KERNEL); 141 kmalloc(sizeof(struct smscore_registry_entry_t),
142 GFP_KERNEL);
149 if (entry) { 143 if (entry) {
150 entry->mode = default_mode; 144 entry->mode = default_mode;
151 strcpy(entry->devpath, devpath); 145 strcpy(entry->devpath, devpath);
@@ -159,7 +153,7 @@ static smscore_registry_entry_t *smscore_find_registry(char *devpath)
159 153
160int smscore_registry_getmode(char *devpath) 154int smscore_registry_getmode(char *devpath)
161{ 155{
162 smscore_registry_entry_t *entry; 156 struct smscore_registry_entry_t *entry;
163 157
164 entry = smscore_find_registry(devpath); 158 entry = smscore_find_registry(devpath);
165 if (entry) 159 if (entry)
@@ -170,9 +164,9 @@ int smscore_registry_getmode(char *devpath)
170 return default_mode; 164 return default_mode;
171} 165}
172 166
173sms_device_type_st smscore_registry_gettype(char *devpath) 167enum sms_device_type_st smscore_registry_gettype(char *devpath)
174{ 168{
175 smscore_registry_entry_t *entry; 169 struct smscore_registry_entry_t *entry;
176 170
177 entry = smscore_find_registry(devpath); 171 entry = smscore_find_registry(devpath);
178 if (entry) 172 if (entry)
@@ -185,7 +179,7 @@ sms_device_type_st smscore_registry_gettype(char *devpath)
185 179
186void smscore_registry_setmode(char *devpath, int mode) 180void smscore_registry_setmode(char *devpath, int mode)
187{ 181{
188 smscore_registry_entry_t *entry; 182 struct smscore_registry_entry_t *entry;
189 183
190 entry = smscore_find_registry(devpath); 184 entry = smscore_find_registry(devpath);
191 if (entry) 185 if (entry)
@@ -194,9 +188,9 @@ void smscore_registry_setmode(char *devpath, int mode)
194 printk(KERN_ERR "%s No registry found.\n", __func__); 188 printk(KERN_ERR "%s No registry found.\n", __func__);
195} 189}
196 190
197void smscore_registry_settype(char *devpath, sms_device_type_st type) 191void smscore_registry_settype(char *devpath, enum sms_device_type_st type)
198{ 192{
199 smscore_registry_entry_t *entry; 193 struct smscore_registry_entry_t *entry;
200 194
201 entry = smscore_find_registry(devpath); 195 entry = smscore_find_registry(devpath);
202 if (entry) 196 if (entry)
@@ -229,20 +223,22 @@ void list_add_locked(struct list_head *new, struct list_head *head,
229 */ 223 */
230int smscore_register_hotplug(hotplug_t hotplug) 224int smscore_register_hotplug(hotplug_t hotplug)
231{ 225{
232 smscore_device_notifyee_t *notifyee; 226 struct smscore_device_notifyee_t *notifyee;
233 struct list_head *next, *first; 227 struct list_head *next, *first;
234 int rc = 0; 228 int rc = 0;
235 229
236 kmutex_lock(&g_smscore_deviceslock); 230 kmutex_lock(&g_smscore_deviceslock);
237 231
238 notifyee = kmalloc(sizeof(smscore_device_notifyee_t), GFP_KERNEL); 232 notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
233 GFP_KERNEL);
239 if (notifyee) { 234 if (notifyee) {
240 /* now notify callback about existing devices */ 235 /* now notify callback about existing devices */
241 first = &g_smscore_devices; 236 first = &g_smscore_devices;
242 for (next = first->next; 237 for (next = first->next;
243 next != first && !rc; 238 next != first && !rc;
244 next = next->next) { 239 next = next->next) {
245 smscore_device_t *coredev = (smscore_device_t *) next; 240 struct smscore_device_t *coredev =
241 (struct smscore_device_t *) next;
246 rc = hotplug(coredev, coredev->device, 1); 242 rc = hotplug(coredev, coredev->device, 1);
247 } 243 }
248 244
@@ -274,8 +270,8 @@ void smscore_unregister_hotplug(hotplug_t hotplug)
274 first = &g_smscore_notifyees; 270 first = &g_smscore_notifyees;
275 271
276 for (next = first->next; next != first;) { 272 for (next = first->next; next != first;) {
277 smscore_device_notifyee_t *notifyee = 273 struct smscore_device_notifyee_t *notifyee =
278 (smscore_device_notifyee_t *) next; 274 (struct smscore_device_notifyee_t *) next;
279 next = next->next; 275 next = next->next;
280 276
281 if (notifyee->hotplug == hotplug) { 277 if (notifyee->hotplug == hotplug) {
@@ -287,19 +283,19 @@ void smscore_unregister_hotplug(hotplug_t hotplug)
287 kmutex_unlock(&g_smscore_deviceslock); 283 kmutex_unlock(&g_smscore_deviceslock);
288} 284}
289 285
290void smscore_notify_clients(smscore_device_t *coredev) 286void smscore_notify_clients(struct smscore_device_t *coredev)
291{ 287{
292 smscore_client_t *client; 288 struct smscore_client_t *client;
293 289
294 /* the client must call smscore_unregister_client from remove handler */ 290 /* the client must call smscore_unregister_client from remove handler */
295 while (!list_empty(&coredev->clients)) { 291 while (!list_empty(&coredev->clients)) {
296 client = (smscore_client_t *) coredev->clients.next; 292 client = (struct smscore_client_t *) coredev->clients.next;
297 client->onremove_handler(client->context); 293 client->onremove_handler(client->context);
298 } 294 }
299} 295}
300 296
301int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device, 297int smscore_notify_callbacks(struct smscore_device_t *coredev,
302 int arrival) 298 struct device *device, int arrival)
303{ 299{
304 struct list_head *next, *first; 300 struct list_head *next, *first;
305 int rc = 0; 301 int rc = 0;
@@ -309,7 +305,7 @@ int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device,
309 first = &g_smscore_notifyees; 305 first = &g_smscore_notifyees;
310 306
311 for (next = first->next; next != first; next = next->next) { 307 for (next = first->next; next != first; next = next->next) {
312 rc = ((smscore_device_notifyee_t *) next)-> 308 rc = ((struct smscore_device_notifyee_t *) next)->
313 hotplug(coredev, device, arrival); 309 hotplug(coredev, device, arrival);
314 if (rc < 0) 310 if (rc < 0)
315 break; 311 break;
@@ -318,10 +314,11 @@ int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device,
318 return rc; 314 return rc;
319} 315}
320 316
321smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, 317struct smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
322 dma_addr_t common_buffer_phys) 318 dma_addr_t common_buffer_phys)
323{ 319{
324 smscore_buffer_t *cb = kmalloc(sizeof(smscore_buffer_t), GFP_KERNEL); 320 struct smscore_buffer_t *cb =
321 kmalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
325 if (!cb) { 322 if (!cb) {
326 printk(KERN_INFO "%s kmalloc(...) failed\n", __func__); 323 printk(KERN_INFO "%s kmalloc(...) failed\n", __func__);
327 return NULL; 324 return NULL;
@@ -344,13 +341,13 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
344 * 341 *
345 * @return 0 on success, <0 on error. 342 * @return 0 on success, <0 on error.
346 */ 343 */
347int smscore_register_device(smsdevice_params_t *params, 344int smscore_register_device(struct smsdevice_params_t *params,
348 smscore_device_t **coredev) 345 struct smscore_device_t **coredev)
349{ 346{
350 smscore_device_t *dev; 347 struct smscore_device_t *dev;
351 u8 *buffer; 348 u8 *buffer;
352 349
353 dev = kzalloc(sizeof(smscore_device_t), GFP_KERNEL); 350 dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL);
354 if (!dev) { 351 if (!dev) {
355 printk(KERN_INFO "%s kzalloc(...) failed\n", __func__); 352 printk(KERN_INFO "%s kzalloc(...) failed\n", __func__);
356 return -ENOMEM; 353 return -ENOMEM;
@@ -389,7 +386,7 @@ int smscore_register_device(smsdevice_params_t *params,
389 for (buffer = dev->common_buffer; 386 for (buffer = dev->common_buffer;
390 dev->num_buffers < params->num_buffers; 387 dev->num_buffers < params->num_buffers;
391 dev->num_buffers++, buffer += params->buffer_size) { 388 dev->num_buffers++, buffer += params->buffer_size) {
392 smscore_buffer_t *cb = 389 struct smscore_buffer_t *cb =
393 smscore_createbuffer(buffer, dev->common_buffer, 390 smscore_createbuffer(buffer, dev->common_buffer,
394 dev->common_buffer_phys); 391 dev->common_buffer_phys);
395 if (!cb) { 392 if (!cb) {
@@ -437,7 +434,7 @@ int smscore_register_device(smsdevice_params_t *params,
437 * 434 *
438 * @return 0 on success, <0 on error. 435 * @return 0 on success, <0 on error.
439 */ 436 */
440int smscore_start_device(smscore_device_t *coredev) 437int smscore_start_device(struct smscore_device_t *coredev)
441{ 438{
442 int rc = smscore_set_device_mode( 439 int rc = smscore_set_device_mode(
443 coredev, smscore_registry_getmode(coredev->devpath)); 440 coredev, smscore_registry_getmode(coredev->devpath));
@@ -459,7 +456,7 @@ int smscore_start_device(smscore_device_t *coredev)
459 return rc; 456 return rc;
460} 457}
461 458
462int smscore_sendrequest_and_wait(smscore_device_t *coredev, void *buffer, 459int smscore_sendrequest_and_wait(struct smscore_device_t *coredev, void *buffer,
463 size_t size, struct completion *completion) 460 size_t size, struct completion *completion)
464{ 461{
465 int rc = coredev->sendrequest_handler(coredev->context, buffer, size); 462 int rc = coredev->sendrequest_handler(coredev->context, buffer, size);
@@ -474,11 +471,11 @@ int smscore_sendrequest_and_wait(smscore_device_t *coredev, void *buffer,
474 0 : -ETIME; 471 0 : -ETIME;
475} 472}
476 473
477int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, 474int smscore_load_firmware_family2(struct smscore_device_t *coredev,
478 size_t size) 475 void *buffer, size_t size)
479{ 476{
480 SmsFirmware_ST *firmware = (SmsFirmware_ST *) buffer; 477 struct SmsFirmware_ST *firmware = (struct SmsFirmware_ST *) buffer;
481 SmsMsgHdr_ST *msg; 478 struct SmsMsgHdr_ST *msg;
482 u32 mem_address = firmware->StartAddress; 479 u32 mem_address = firmware->StartAddress;
483 u8 *payload = firmware->Payload; 480 u8 *payload = firmware->Payload;
484 int rc = 0; 481 int rc = 0;
@@ -492,14 +489,14 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
492 } 489 }
493 490
494 /* PAGE_SIZE buffer shall be enough and dma aligned */ 491 /* PAGE_SIZE buffer shall be enough and dma aligned */
495 msg = (SmsMsgHdr_ST *) kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA); 492 msg = (struct SmsMsgHdr_ST *) kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
496 if (!msg) 493 if (!msg)
497 return -ENOMEM; 494 return -ENOMEM;
498 495
499 if (coredev->mode != DEVICE_MODE_NONE) { 496 if (coredev->mode != DEVICE_MODE_NONE) {
500 PDEBUG("Sending reload command\n"); 497 PDEBUG("Sending reload command\n");
501 SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ, 498 SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ,
502 sizeof(SmsMsgHdr_ST)); 499 sizeof(struct SmsMsgHdr_ST));
503 rc = smscore_sendrequest_and_wait(coredev, msg, 500 rc = smscore_sendrequest_and_wait(coredev, msg,
504 msg->msgLength, 501 msg->msgLength,
505 &coredev->reload_start_done); 502 &coredev->reload_start_done);
@@ -507,11 +504,12 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
507 } 504 }
508 505
509 while (size && rc >= 0) { 506 while (size && rc >= 0) {
510 SmsDataDownload_ST *DataMsg = (SmsDataDownload_ST *) msg; 507 struct SmsDataDownload_ST *DataMsg =
508 (struct SmsDataDownload_ST *) msg;
511 int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE); 509 int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE);
512 510
513 SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ, 511 SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ,
514 (u16)(sizeof(SmsMsgHdr_ST) + 512 (u16)(sizeof(struct SmsMsgHdr_ST) +
515 sizeof(u32) + payload_size)); 513 sizeof(u32) + payload_size));
516 514
517 DataMsg->MemAddr = mem_address; 515 DataMsg->MemAddr = mem_address;
@@ -535,10 +533,11 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
535 533
536 if (rc >= 0) { 534 if (rc >= 0) {
537 if (coredev->mode == DEVICE_MODE_NONE) { 535 if (coredev->mode == DEVICE_MODE_NONE) {
538 SmsMsgData_ST *TriggerMsg = (SmsMsgData_ST *) msg; 536 struct SmsMsgData_ST *TriggerMsg =
537 (struct SmsMsgData_ST *) msg;
539 538
540 SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ, 539 SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
541 sizeof(SmsMsgHdr_ST) + 540 sizeof(struct SmsMsgHdr_ST) +
542 sizeof(u32) * 5); 541 sizeof(u32) * 5);
543 542
544 TriggerMsg->msgData[0] = firmware->StartAddress; 543 TriggerMsg->msgData[0] = firmware->StartAddress;
@@ -560,7 +559,7 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
560 &coredev->trigger_done); 559 &coredev->trigger_done);
561 } else { 560 } else {
562 SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ, 561 SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ,
563 sizeof(SmsMsgHdr_ST)); 562 sizeof(struct SmsMsgHdr_ST));
564 563
565 rc = coredev->sendrequest_handler(coredev->context, 564 rc = coredev->sendrequest_handler(coredev->context,
566 msg, msg->msgLength); 565 msg, msg->msgLength);
@@ -588,7 +587,8 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
588 * 587 *
589 * @return 0 on success, <0 on error. 588 * @return 0 on success, <0 on error.
590 */ 589 */
591int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, 590int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
591 char *filename,
592 loadfirmware_t loadfirmware_handler) 592 loadfirmware_t loadfirmware_handler)
593{ 593{
594 int rc = -ENOENT; 594 int rc = -ENOENT;
@@ -632,8 +632,8 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename,
632 return rc; 632 return rc;
633} 633}
634 634
635int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer, 635int smscore_load_firmware_from_buffer(struct smscore_device_t *coredev,
636 int size, int new_mode) 636 u8 *buffer, int size, int new_mode)
637{ 637{
638 PERROR("Feature not implemented yet\n"); 638 PERROR("Feature not implemented yet\n");
639 return -EFAULT; 639 return -EFAULT;
@@ -648,9 +648,9 @@ int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer,
648 * 648 *
649 * @return 0 on success, <0 on error. 649 * @return 0 on success, <0 on error.
650 */ 650 */
651void smscore_unregister_device(smscore_device_t *coredev) 651void smscore_unregister_device(struct smscore_device_t *coredev)
652{ 652{
653 smscore_buffer_t *cb; 653 struct smscore_buffer_t *cb;
654 int num_buffers = 0; 654 int num_buffers = 0;
655 int retry = 0; 655 int retry = 0;
656 656
@@ -695,17 +695,19 @@ void smscore_unregister_device(smscore_device_t *coredev)
695 printk(KERN_INFO "%s device %p destroyed\n", __func__, coredev); 695 printk(KERN_INFO "%s device %p destroyed\n", __func__, coredev);
696} 696}
697 697
698int smscore_detect_mode(smscore_device_t *coredev) 698int smscore_detect_mode(struct smscore_device_t *coredev)
699{ 699{
700 void *buffer = kmalloc(sizeof(SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT, 700 void *buffer = kmalloc(sizeof(struct SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT,
701 GFP_KERNEL | GFP_DMA); 701 GFP_KERNEL | GFP_DMA);
702 SmsMsgHdr_ST *msg = (SmsMsgHdr_ST *) SMS_ALIGN_ADDRESS(buffer); 702 struct SmsMsgHdr_ST *msg =
703 (struct SmsMsgHdr_ST *) SMS_ALIGN_ADDRESS(buffer);
703 int rc; 704 int rc;
704 705
705 if (!buffer) 706 if (!buffer)
706 return -ENOMEM; 707 return -ENOMEM;
707 708
708 SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ, sizeof(SmsMsgHdr_ST)); 709 SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ,
710 sizeof(struct SmsMsgHdr_ST));
709 711
710 rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, 712 rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength,
711 &coredev->version_ex_done); 713 &coredev->version_ex_done);
@@ -754,11 +756,11 @@ char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
754 * 756 *
755 * @return 0 on success, <0 on error. 757 * @return 0 on success, <0 on error.
756 */ 758 */
757int smscore_set_device_mode(smscore_device_t *coredev, int mode) 759int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
758{ 760{
759 void *buffer; 761 void *buffer;
760 int rc = 0; 762 int rc = 0;
761 sms_device_type_st type; 763 enum sms_device_type_st type;
762 764
763 PDEBUG("set device mode to %d\n", mode); 765 PDEBUG("set device mode to %d\n", mode);
764 if (coredev->device_flags & SMS_DEVICE_FAMILY2) { 766 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
@@ -798,14 +800,15 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode)
798 printk(KERN_INFO "%s mode %d supported by running " 800 printk(KERN_INFO "%s mode %d supported by running "
799 "firmware\n", __func__, mode); 801 "firmware\n", __func__, mode);
800 802
801 buffer = kmalloc(sizeof(SmsMsgData_ST) + SMS_DMA_ALIGNMENT, 803 buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
802 GFP_KERNEL | GFP_DMA); 804 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
803 if (buffer) { 805 if (buffer) {
804 SmsMsgData_ST *msg = 806 struct SmsMsgData_ST *msg =
805 (SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer); 807 (struct SmsMsgData_ST *)
808 SMS_ALIGN_ADDRESS(buffer);
806 809
807 SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, 810 SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ,
808 sizeof(SmsMsgData_ST)); 811 sizeof(struct SmsMsgData_ST));
809 msg->msgData[0] = mode; 812 msg->msgData[0] = mode;
810 813
811 rc = smscore_sendrequest_and_wait( 814 rc = smscore_sendrequest_and_wait(
@@ -853,7 +856,7 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode)
853 * 856 *
854 * @return current mode 857 * @return current mode
855 */ 858 */
856int smscore_get_device_mode(smscore_device_t *coredev) 859int smscore_get_device_mode(struct smscore_device_t *coredev)
857{ 860{
858 return coredev->mode; 861 return coredev->mode;
859} 862}
@@ -868,10 +871,10 @@ int smscore_get_device_mode(smscore_device_t *coredev)
868 * @param id client id (SMS_DONT_CARE for all id) 871 * @param id client id (SMS_DONT_CARE for all id)
869 * 872 *
870 */ 873 */
871smscore_client_t *smscore_find_client(smscore_device_t *coredev, 874struct smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
872 int data_type, int id) 875 int data_type, int id)
873{ 876{
874 smscore_client_t *client = NULL; 877 struct smscore_client_t *client = NULL;
875 struct list_head *next, *first; 878 struct list_head *next, *first;
876 unsigned long flags; 879 unsigned long flags;
877 struct list_head *firstid, *nextid; 880 struct list_head *firstid, *nextid;
@@ -882,14 +885,14 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev,
882 for (next = first->next; 885 for (next = first->next;
883 (next != first) && !client; 886 (next != first) && !client;
884 next = next->next) { 887 next = next->next) {
885 firstid = &((smscore_client_t *)next)->idlist; 888 firstid = &((struct smscore_client_t *)next)->idlist;
886 for (nextid = firstid->next; 889 for (nextid = firstid->next;
887 nextid != firstid; 890 nextid != firstid;
888 nextid = nextid->next) { 891 nextid = nextid->next) {
889 if ((((smscore_idlist_t *)nextid)->id == id) && 892 if ((((struct smscore_idlist_t *)nextid)->id == id) &&
890 (((smscore_idlist_t *)nextid)->data_type == data_type || 893 (((struct smscore_idlist_t *)nextid)->data_type == data_type ||
891 (((smscore_idlist_t *)nextid)->data_type == 0))) { 894 (((struct smscore_idlist_t *)nextid)->data_type == 0))) {
892 client = (smscore_client_t *) next; 895 client = (struct smscore_client_t *) next;
893 break; 896 break;
894 } 897 }
895 } 898 }
@@ -907,10 +910,12 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev,
907 * @param cb pointer to response buffer descriptor 910 * @param cb pointer to response buffer descriptor
908 * 911 *
909 */ 912 */
910void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) 913void smscore_onresponse(struct smscore_device_t *coredev,
914 struct smscore_buffer_t *cb)
911{ 915{
912 SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset); 916 struct SmsMsgHdr_ST *phdr =
913 smscore_client_t *client = 917 (struct SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset);
918 struct smscore_client_t *client =
914 smscore_find_client(coredev, phdr->msgType, phdr->msgDstId); 919 smscore_find_client(coredev, phdr->msgType, phdr->msgDstId);
915 int rc = -EBUSY; 920 int rc = -EBUSY;
916 921
@@ -940,7 +945,8 @@ void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb)
940 switch (phdr->msgType) { 945 switch (phdr->msgType) {
941 case MSG_SMS_GET_VERSION_EX_RES: 946 case MSG_SMS_GET_VERSION_EX_RES:
942 { 947 {
943 SmsVersionRes_ST *ver = (SmsVersionRes_ST *) phdr; 948 struct SmsVersionRes_ST *ver =
949 (struct SmsVersionRes_ST *) phdr;
944 printk(KERN_DEBUG "%s: MSG_SMS_GET_VERSION_EX_RES " 950 printk(KERN_DEBUG "%s: MSG_SMS_GET_VERSION_EX_RES "
945 "id %d prots 0x%x ver %d.%d\n", __func__, 951 "id %d prots 0x%x ver %d.%d\n", __func__,
946 ver->FirmwareId, ver->SupportedProtocols, 952 ver->FirmwareId, ver->SupportedProtocols,
@@ -994,15 +1000,15 @@ void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb)
994 * 1000 *
995 * @return pointer to descriptor on success, NULL on error. 1001 * @return pointer to descriptor on success, NULL on error.
996 */ 1002 */
997smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev) 1003struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev)
998{ 1004{
999 smscore_buffer_t *cb = NULL; 1005 struct smscore_buffer_t *cb = NULL;
1000 unsigned long flags; 1006 unsigned long flags;
1001 1007
1002 spin_lock_irqsave(&coredev->bufferslock, flags); 1008 spin_lock_irqsave(&coredev->bufferslock, flags);
1003 1009
1004 if (!list_empty(&coredev->buffers)) { 1010 if (!list_empty(&coredev->buffers)) {
1005 cb = (smscore_buffer_t *) coredev->buffers.next; 1011 cb = (struct smscore_buffer_t *) coredev->buffers.next;
1006 list_del(&cb->entry); 1012 list_del(&cb->entry);
1007 } 1013 }
1008 1014
@@ -1019,16 +1025,18 @@ smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev)
1019 * @param cb pointer buffer descriptor 1025 * @param cb pointer buffer descriptor
1020 * 1026 *
1021 */ 1027 */
1022void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb) 1028void smscore_putbuffer(struct smscore_device_t *coredev,
1029 struct smscore_buffer_t *cb)
1023{ 1030{
1024 list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock); 1031 list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock);
1025} 1032}
1026 1033
1027int smscore_validate_client(smscore_device_t *coredev, 1034int smscore_validate_client(struct smscore_device_t *coredev,
1028 smscore_client_t *client, int data_type, int id) 1035 struct smscore_client_t *client,
1036 int data_type, int id)
1029{ 1037{
1030 smscore_idlist_t *listentry; 1038 struct smscore_idlist_t *listentry;
1031 smscore_client_t *registered_client; 1039 struct smscore_client_t *registered_client;
1032 1040
1033 if (!client) { 1041 if (!client) {
1034 PERROR("bad parameter.\n"); 1042 PERROR("bad parameter.\n");
@@ -1042,7 +1050,7 @@ int smscore_validate_client(smscore_device_t *coredev,
1042 PERROR("The msg ID already registered to another client.\n"); 1050 PERROR("The msg ID already registered to another client.\n");
1043 return -EEXIST; 1051 return -EEXIST;
1044 } 1052 }
1045 listentry = kzalloc(sizeof(smscore_idlist_t), GFP_KERNEL); 1053 listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
1046 if (!listentry) { 1054 if (!listentry) {
1047 PERROR("Can't allocate memory for client id.\n"); 1055 PERROR("Can't allocate memory for client id.\n");
1048 return -ENOMEM; 1056 return -ENOMEM;
@@ -1068,11 +1076,11 @@ int smscore_validate_client(smscore_device_t *coredev,
1068 * 1076 *
1069 * @return 0 on success, <0 on error. 1077 * @return 0 on success, <0 on error.
1070 */ 1078 */
1071int smscore_register_client(smscore_device_t *coredev, 1079int smscore_register_client(struct smscore_device_t *coredev,
1072 smsclient_params_t *params, 1080 struct smsclient_params_t *params,
1073 smscore_client_t **client) 1081 struct smscore_client_t **client)
1074{ 1082{
1075 smscore_client_t *newclient; 1083 struct smscore_client_t *newclient;
1076 /* check that no other channel with same parameters exists */ 1084 /* check that no other channel with same parameters exists */
1077 if (smscore_find_client(coredev, params->data_type, 1085 if (smscore_find_client(coredev, params->data_type,
1078 params->initial_id)) { 1086 params->initial_id)) {
@@ -1080,7 +1088,7 @@ int smscore_register_client(smscore_device_t *coredev,
1080 return -EEXIST; 1088 return -EEXIST;
1081 } 1089 }
1082 1090
1083 newclient = kzalloc(sizeof(smscore_client_t), GFP_KERNEL); 1091 newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
1084 if (!newclient) { 1092 if (!newclient) {
1085 PERROR("Failed to allocate memory for client.\n"); 1093 PERROR("Failed to allocate memory for client.\n");
1086 return -ENOMEM; 1094 return -ENOMEM;
@@ -1109,17 +1117,17 @@ int smscore_register_client(smscore_device_t *coredev,
1109 * smscore_register_client 1117 * smscore_register_client
1110 * 1118 *
1111 */ 1119 */
1112void smscore_unregister_client(smscore_client_t *client) 1120void smscore_unregister_client(struct smscore_client_t *client)
1113{ 1121{
1114 smscore_device_t *coredev = client->coredev; 1122 struct smscore_device_t *coredev = client->coredev;
1115 unsigned long flags; 1123 unsigned long flags;
1116 1124
1117 spin_lock_irqsave(&coredev->clientslock, flags); 1125 spin_lock_irqsave(&coredev->clientslock, flags);
1118 1126
1119 1127
1120 while (!list_empty(&client->idlist)) { 1128 while (!list_empty(&client->idlist)) {
1121 smscore_idlist_t *identry = 1129 struct smscore_idlist_t *identry =
1122 (smscore_idlist_t *) client->idlist.next; 1130 (struct smscore_idlist_t *) client->idlist.next;
1123 list_del(&identry->entry); 1131 list_del(&identry->entry);
1124 kfree(identry); 1132 kfree(identry);
1125 } 1133 }
@@ -1143,10 +1151,11 @@ void smscore_unregister_client(smscore_client_t *client)
1143 * 1151 *
1144 * @return 0 on success, <0 on error. 1152 * @return 0 on success, <0 on error.
1145 */ 1153 */
1146int smsclient_sendrequest(smscore_client_t *client, void *buffer, size_t size) 1154int smsclient_sendrequest(struct smscore_client_t *client,
1155 void *buffer, size_t size)
1147{ 1156{
1148 smscore_device_t *coredev; 1157 struct smscore_device_t *coredev;
1149 SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) buffer; 1158 struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) buffer;
1150 int rc; 1159 int rc;
1151 1160
1152 if (client == NULL) { 1161 if (client == NULL) {
@@ -1177,7 +1186,7 @@ int smsclient_sendrequest(smscore_client_t *client, void *buffer, size_t size)
1177 * 1186 *
1178 * @return size (in bytes) of the buffer 1187 * @return size (in bytes) of the buffer
1179 */ 1188 */
1180int smscore_get_common_buffer_size(smscore_device_t *coredev) 1189int smscore_get_common_buffer_size(struct smscore_device_t *coredev)
1181{ 1190{
1182 return coredev->common_buffer_size; 1191 return coredev->common_buffer_size;
1183} 1192}
@@ -1190,7 +1199,7 @@ int smscore_get_common_buffer_size(smscore_device_t *coredev)
1190 * 1199 *
1191 * @return 0 on success, <0 on error. 1200 * @return 0 on success, <0 on error.
1192 */ 1201 */
1193int smscore_map_common_buffer(smscore_device_t *coredev, 1202int smscore_map_common_buffer(struct smscore_device_t *coredev,
1194 struct vm_area_struct *vma) 1203 struct vm_area_struct *vma)
1195{ 1204{
1196 unsigned long end = vma->vm_end, 1205 unsigned long end = vma->vm_end,
@@ -1247,8 +1256,9 @@ void smscore_module_exit(void)
1247 1256
1248 kmutex_lock(&g_smscore_deviceslock); 1257 kmutex_lock(&g_smscore_deviceslock);
1249 while (!list_empty(&g_smscore_notifyees)) { 1258 while (!list_empty(&g_smscore_notifyees)) {
1250 smscore_device_notifyee_t *notifyee = 1259 struct smscore_device_notifyee_t *notifyee =
1251 (smscore_device_notifyee_t *) g_smscore_notifyees.next; 1260 (struct smscore_device_notifyee_t *)
1261 g_smscore_notifyees.next;
1252 1262
1253 list_del(&notifyee->entry); 1263 list_del(&notifyee->entry);
1254 kfree(notifyee); 1264 kfree(notifyee);
@@ -1257,8 +1267,9 @@ void smscore_module_exit(void)
1257 1267
1258 kmutex_lock(&g_smscore_registrylock); 1268 kmutex_lock(&g_smscore_registrylock);
1259 while (!list_empty(&g_smscore_registry)) { 1269 while (!list_empty(&g_smscore_registry)) {
1260 smscore_registry_entry_t *entry = 1270 struct smscore_registry_entry_t *entry =
1261 (smscore_registry_entry_t *) g_smscore_registry.next; 1271 (struct smscore_registry_entry_t *)
1272 g_smscore_registry.next;
1262 1273
1263 list_del(&entry->entry); 1274 list_del(&entry->entry);
1264 kfree(entry); 1275 kfree(entry);
diff --git a/drivers/media/dvb/siano/smscoreapi.h b/drivers/media/dvb/siano/smscoreapi.h
index f0675cf4cef3..be98baf3085e 100644
--- a/drivers/media/dvb/siano/smscoreapi.h
+++ b/drivers/media/dvb/siano/smscoreapi.h
@@ -57,19 +57,19 @@ typedef struct mutex kmutex_t;
57#define SMS_ROM_NO_RESPONSE 2 57#define SMS_ROM_NO_RESPONSE 2
58#define SMS_DEVICE_NOT_READY 0x8000000 58#define SMS_DEVICE_NOT_READY 0x8000000
59 59
60typedef enum { 60enum sms_device_type_st {
61 SMS_STELLAR = 0, 61 SMS_STELLAR = 0,
62 SMS_NOVA_A0, 62 SMS_NOVA_A0,
63 SMS_NOVA_B0, 63 SMS_NOVA_B0,
64 SMS_VEGA, 64 SMS_VEGA,
65 SMS_NUM_OF_DEVICE_TYPES 65 SMS_NUM_OF_DEVICE_TYPES
66} sms_device_type_st; 66};
67 67
68typedef struct _smscore_device smscore_device_t; 68struct smscore_device_t;
69typedef struct _smscore_client smscore_client_t; 69struct smscore_client_t;
70typedef struct _smscore_buffer smscore_buffer_t; 70struct smscore_buffer_t;
71 71
72typedef int (*hotplug_t)(smscore_device_t *coredev, 72typedef int (*hotplug_t)(struct smscore_device_t *coredev,
73 struct device *device, int arrival); 73 struct device *device, int arrival);
74 74
75typedef int (*setmode_t)(void *context, int mode); 75typedef int (*setmode_t)(void *context, int mode);
@@ -79,11 +79,10 @@ typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size);
79typedef int (*preload_t)(void *context); 79typedef int (*preload_t)(void *context);
80typedef int (*postload_t)(void *context); 80typedef int (*postload_t)(void *context);
81 81
82typedef int (*onresponse_t)(void *context, smscore_buffer_t *cb); 82typedef int (*onresponse_t)(void *context, struct smscore_buffer_t *cb);
83typedef void (*onremove_t)(void *context); 83typedef void (*onremove_t)(void *context);
84 84
85typedef struct _smscore_buffer 85struct smscore_buffer_t {
86{
87 /* public members, once passed to clients can be changed freely */ 86 /* public members, once passed to clients can be changed freely */
88 struct list_head entry; 87 struct list_head entry;
89 int size; 88 int size;
@@ -93,10 +92,9 @@ typedef struct _smscore_buffer
93 void *p; 92 void *p;
94 dma_addr_t phys; 93 dma_addr_t phys;
95 unsigned long offset_in_common; 94 unsigned long offset_in_common;
96} *psmscore_buffer_t; 95};
97 96
98typedef struct _smsdevice_params 97struct smsdevice_params_t {
99{
100 struct device *device; 98 struct device *device;
101 99
102 int buffer_size; 100 int buffer_size;
@@ -112,18 +110,17 @@ typedef struct _smsdevice_params
112 postload_t postload_handler; 110 postload_t postload_handler;
113 111
114 void *context; 112 void *context;
115 sms_device_type_st device_type; 113 enum sms_device_type_st device_type;
116} smsdevice_params_t; 114};
117 115
118typedef struct _smsclient_params 116struct smsclient_params_t {
119{
120 int initial_id; 117 int initial_id;
121 int data_type; 118 int data_type;
122 onresponse_t onresponse_handler; 119 onresponse_t onresponse_handler;
123 onremove_t onremove_handler; 120 onremove_t onremove_handler;
124 121
125 void *context; 122 void *context;
126} smsclient_params_t; 123};
127 124
128/* GPIO definitions for antenna frequency domain control (SMS8021) */ 125/* GPIO definitions for antenna frequency domain control (SMS8021) */
129#define SMS_ANTENNA_GPIO_0 1 126#define SMS_ANTENNA_GPIO_0 1
@@ -201,8 +198,7 @@ typedef struct _smsclient_params
201#define SMS_INIT_MSG(ptr, type, len) \ 198#define SMS_INIT_MSG(ptr, type, len) \
202 SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len) 199 SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len)
203 200
204typedef enum 201enum SMS_DEVICE_MODE {
205{
206 DEVICE_MODE_NONE = -1, 202 DEVICE_MODE_NONE = -1,
207 DEVICE_MODE_DVBT = 0, 203 DEVICE_MODE_DVBT = 0,
208 DEVICE_MODE_DVBH, 204 DEVICE_MODE_DVBH,
@@ -214,33 +210,29 @@ typedef enum
214 DEVICE_MODE_CMMB, 210 DEVICE_MODE_CMMB,
215 DEVICE_MODE_RAW_TUNER, 211 DEVICE_MODE_RAW_TUNER,
216 DEVICE_MODE_MAX, 212 DEVICE_MODE_MAX,
217} SMS_DEVICE_MODE; 213};
218 214
219typedef struct SmsMsgHdr_S 215struct SmsMsgHdr_ST {
220{
221 u16 msgType; 216 u16 msgType;
222 u8 msgSrcId; 217 u8 msgSrcId;
223 u8 msgDstId; 218 u8 msgDstId;
224 u16 msgLength; /* Length of entire message, including header */ 219 u16 msgLength; /* Length of entire message, including header */
225 u16 msgFlags; 220 u16 msgFlags;
226} SmsMsgHdr_ST; 221};
227 222
228typedef struct SmsMsgData_S 223struct SmsMsgData_ST {
229{ 224 struct SmsMsgHdr_ST xMsgHeader;
230 SmsMsgHdr_ST xMsgHeader;
231 u32 msgData[1]; 225 u32 msgData[1];
232} SmsMsgData_ST; 226};
233 227
234typedef struct SmsDataDownload_S 228struct SmsDataDownload_ST {
235{ 229 struct SmsMsgHdr_ST xMsgHeader;
236 SmsMsgHdr_ST xMsgHeader;
237 u32 MemAddr; 230 u32 MemAddr;
238 u8 Payload[SMS_MAX_PAYLOAD_SIZE]; 231 u8 Payload[SMS_MAX_PAYLOAD_SIZE];
239} SmsDataDownload_ST; 232};
240 233
241typedef struct SmsVersionRes_S 234struct SmsVersionRes_ST {
242{ 235 struct SmsMsgHdr_ST xMsgHeader;
243 SmsMsgHdr_ST xMsgHeader;
244 236
245 u16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */ 237 u16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */
246 u8 Step; /* 0 - Step A */ 238 u8 Step; /* 0 - Step A */
@@ -263,18 +255,16 @@ typedef struct SmsVersionRes_S
263 u8 RomVersionFieldPatch; 255 u8 RomVersionFieldPatch;
264 256
265 u8 TextLabel[34]; 257 u8 TextLabel[34];
266} SmsVersionRes_ST; 258};
267 259
268typedef struct SmsFirmware_S 260struct SmsFirmware_ST {
269{
270 u32 CheckSum; 261 u32 CheckSum;
271 u32 Length; 262 u32 Length;
272 u32 StartAddress; 263 u32 StartAddress;
273 u8 Payload[1]; 264 u8 Payload[1];
274} SmsFirmware_ST; 265};
275 266
276typedef struct SMSHOSTLIB_STATISTICS_S 267struct SMSHOSTLIB_STATISTICS_ST {
277{
278 u32 Reserved; /* Reserved */ 268 u32 Reserved; /* Reserved */
279 269
280 /* Common parameters */ 270 /* Common parameters */
@@ -339,196 +329,25 @@ typedef struct SMSHOSTLIB_STATISTICS_S
339 u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero; 329 u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
340 * if set to 0xFFFFFFFF cell_id not yet recovered */ 330 * if set to 0xFFFFFFFF cell_id not yet recovered */
341 331
342} SMSHOSTLIB_STATISTICS_ST; 332};
343 333
344typedef struct 334struct SmsMsgStatisticsInfo_ST {
345{
346 u32 RequestResult; 335 u32 RequestResult;
347 336
348 SMSHOSTLIB_STATISTICS_ST Stat; 337 struct SMSHOSTLIB_STATISTICS_ST Stat;
349 338
350 /* Split the calc of the SNR in DAB */ 339 /* Split the calc of the SNR in DAB */
351 u32 Signal; /* dB */ 340 u32 Signal; /* dB */
352 u32 Noise; /* dB */ 341 u32 Noise; /* dB */
353 342
354} SmsMsgStatisticsInfo_ST; 343};
355
356typedef struct SMSHOSTLIB_ISDBT_LAYER_STAT_S
357{
358 /* Per-layer information */
359 u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET,
360 * 255 means layer does not exist */
361 u32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET,
362 * 255 means layer does not exist */
363 u32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
364 u32 BERErrorCount; /* Post Viterbi Error Bits Count */
365 u32 BERBitCount; /* Post Viterbi Total Bits Count */
366 u32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
367 u32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */
368 u32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
369 u32 TotalTSPackets; /* Total number of transport-stream packets */
370 u32 TILdepthI; /* Time interleaver depth I parameter,
371 * 255 means layer does not exist */
372 u32 NumberOfSegments; /* Number of segments in layer A,
373 * 255 means layer does not exist */
374 u32 TMCCErrors; /* TMCC errors */
375} SMSHOSTLIB_ISDBT_LAYER_STAT_ST;
376
377typedef struct SMSHOSTLIB_STATISTICS_ISDBT_S
378{
379 u32 StatisticsType; /* Enumerator identifying the type of the
380 * structure. Values are the same as
381 * SMSHOSTLIB_DEVICE_MODES_E
382 *
383 * This field MUST always be first in any
384 * statistics structure */
385
386 u32 FullSize; /* Total size of the structure returned by the modem.
387 * If the size requested by the host is smaller than
388 * FullSize, the struct will be truncated */
389
390 /* Common parameters */
391 u32 IsRfLocked; /* 0 - not locked, 1 - locked */
392 u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
393 u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
394
395 /* Reception quality */
396 s32 SNR; /* dB */
397 s32 RSSI; /* dBm */
398 s32 InBandPwr; /* In band power in dBM */
399 s32 CarrierOffset; /* Carrier Offset in Hz */
400
401 /* Transmission parameters */
402 u32 Frequency; /* Frequency in Hz */
403 u32 Bandwidth; /* Bandwidth in MHz */
404 u32 TransmissionMode; /* ISDB-T transmission mode */
405 u32 ModemState; /* 0 - Acquisition, 1 - Locked */
406 u32 GuardInterval; /* Guard Interval, 1 divided by value */
407 u32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */
408 u32 PartialReception; /* TRUE - partial reception, FALSE otherwise */
409 u32 NumOfLayers; /* Number of ISDB-T layers in the network */
410
411 /* Per-layer information */
412 /* Layers A, B and C */
413 SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3]; /* Per-layer statistics,
414 see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */
415 344
416 /* Interface information */
417 u32 SmsToHostTxErrors; /* Total number of transmission errors. */
418
419} SMSHOSTLIB_STATISTICS_ISDBT_ST;
420
421typedef struct SMSHOSTLIB_STATISTICS_DVB_S
422{
423 u32 StatisticsType; /* Enumerator identifying the type of the
424 * structure. Values are the same as
425 * SMSHOSTLIB_DEVICE_MODES_E
426 * This field MUST always first in any
427 * statistics structure */
428
429 u32 FullSize; /* Total size of the structure returned by the modem.
430 * If the size requested by the host is smaller than
431 * FullSize, the struct will be truncated */
432 /* Common parameters */
433 u32 IsRfLocked; /* 0 - not locked, 1 - locked */
434 u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
435 u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
436
437 /* Reception quality */
438 s32 SNR; /* dB */
439 u32 BER; /* Post Viterbi BER [1E-5] */
440 u32 BERErrorCount; /* Number of errornous SYNC bits. */
441 u32 BERBitCount; /* Total number of SYNC bits. */
442 u32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A */
443 u32 MFER; /* DVB-H frame error rate in percentage,
444 * 0xFFFFFFFF indicate N/A, valid only for DVB-H */
445 s32 RSSI; /* dBm */
446 s32 InBandPwr; /* In band power in dBM */
447 s32 CarrierOffset; /* Carrier Offset in bin/1024 */
448
449 /* Transmission parameters */
450 u32 Frequency; /* Frequency in Hz */
451 u32 Bandwidth; /* Bandwidth in MHz */
452 u32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
453 u32 TransmissionMode; /* FFT mode carriers in Kilos */
454 u32 GuardInterval; /* Guard Interval, 1 divided by value */
455 u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET */
456 u32 LPCodeRate; /* Low Priority Code Rate from
457 * SMSHOSTLIB_CODE_RATE_ET */
458 u32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET */
459 u32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET */
460
461 /* Burst parameters, valid only for DVB-H */
462 u32 BurstSize; /* Current burst size in bytes */
463 u32 BurstDuration; /* Current burst duration in mSec */
464 u32 BurstCycleTime; /* Current burst cycle time in mSec */
465 u32 CalculatedBurstCycleTime; /* Current burst cycle time in mSec,
466 * as calculated by demodulator */
467 u32 NumOfRows; /* Number of rows in MPE table */
468 u32 NumOfPaddCols; /* Number of padding columns in MPE table */
469 u32 NumOfPunctCols; /* Number of puncturing columns in MPE table */
470
471 u32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
472 u32 TotalTSPackets; /* Total number of transport-stream packets */
473
474 u32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include
475 * errors after MPE RS decoding */
476 u32 NumOfInvalidMpeTlbs; /* Number of MPE tables which include
477 * errors after MPE RS decoding */
478 u32 NumOfCorrectedMpeTlbs; /* Number of MPE tables which were
479 * corrected by MPE RS decoding */
480
481 u32 NumMPEReceived; /* DVB-H, Num MPE section received */
482
483 /* DVB-H TPS parameters */
484 u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
485 * if set to 0xFFFFFFFF cell_id not yet recovered */
486 u32 DvbhSrvIndHP; /* DVB-H service indication info,
487 * bit 1 - Time Slicing indicator,
488 * bit 0 - MPE-FEC indicator */
489 u32 DvbhSrvIndLP; /* DVB-H service indication info,
490 * bit 1 - Time Slicing indicator,
491 * bit 0 - MPE-FEC indicator */
492
493 /* Interface information */
494 u32 SmsToHostTxErrors; /* Total number of transmission errors. */
495 345
496} SMSHOSTLIB_STATISTICS_DVB_ST; 346struct smsdvb_client_t {
497
498typedef struct SMSHOSTLIB_GPIO_CONFIG_S
499{
500 u8 Direction; /* GPIO direction: Input - 0, Output - 1 */
501 u8 PullUpDown; /* PullUp/PullDown: None - 0,
502 * PullDown - 1, PullUp - 2, Keeper - 3 */
503 u8 InputCharacteristics; /* Input Characteristics: Normal - 0,
504 * Schmitt trigger - 1 */
505 u8 OutputSlewRate; /* Output Slew Rate:
506 * Fast slew rate - 0, Slow slew rate - 1 */
507 u8 OutputDriving; /* Output driving capability:
508 * 4mA - 0, 8mA - 1, 12mA - 2, 16mA - 3 */
509} SMSHOSTLIB_GPIO_CONFIG_ST;
510
511typedef struct SMSHOSTLIB_I2C_REQ_S
512{
513 u32 DeviceAddress; /* I2c device address */
514 u32 WriteCount; /* number of bytes to write */
515 u32 ReadCount; /* number of bytes to read */
516 u8 Data[1];
517} SMSHOSTLIB_I2C_REQ_ST;
518
519typedef struct SMSHOSTLIB_I2C_RES_S
520{
521 u32 Status; /* non-zero value in case of failure */
522 u32 ReadCount; /* number of bytes read */
523 u8 Data[1];
524} SMSHOSTLIB_I2C_RES_ST;
525
526typedef struct _smsdvb_client
527{
528 struct list_head entry; 347 struct list_head entry;
529 348
530 smscore_device_t *coredev; 349 struct smscore_device_t *coredev;
531 smscore_client_t *smsclient; 350 struct smscore_client_t *smsclient;
532 351
533 struct dvb_adapter adapter; 352 struct dvb_adapter adapter;
534 struct dvb_demux demux; 353 struct dvb_demux demux;
@@ -543,7 +362,7 @@ typedef struct _smsdvb_client
543 /* todo: save freq/band instead whole struct */ 362 /* todo: save freq/band instead whole struct */
544 struct dvb_frontend_parameters fe_params; 363 struct dvb_frontend_parameters fe_params;
545 364
546} smsdvb_client_t; 365};
547 366
548extern void smscore_registry_setmode(char *devpath, int mode); 367extern void smscore_registry_setmode(char *devpath, int mode);
549extern int smscore_registry_getmode(char *devpath); 368extern int smscore_registry_getmode(char *devpath);
@@ -551,37 +370,39 @@ extern int smscore_registry_getmode(char *devpath);
551extern int smscore_register_hotplug(hotplug_t hotplug); 370extern int smscore_register_hotplug(hotplug_t hotplug);
552extern void smscore_unregister_hotplug(hotplug_t hotplug); 371extern void smscore_unregister_hotplug(hotplug_t hotplug);
553 372
554extern int smscore_register_device(smsdevice_params_t *params, 373extern int smscore_register_device(struct smsdevice_params_t *params,
555 smscore_device_t **coredev); 374 struct smscore_device_t **coredev);
556extern void smscore_unregister_device(smscore_device_t *coredev); 375extern void smscore_unregister_device(struct smscore_device_t *coredev);
557 376
558extern int smscore_start_device(smscore_device_t *coredev); 377extern int smscore_start_device(struct smscore_device_t *coredev);
559extern int smscore_load_firmware(smscore_device_t *coredev, char *filename, 378extern int smscore_load_firmware(struct smscore_device_t *coredev,
560 loadfirmware_t loadfirmware_handler); 379 char *filename,
380 loadfirmware_t loadfirmware_handler);
561 381
562extern int smscore_load_firmware_from_buffer(smscore_device_t *coredev, 382extern int smscore_load_firmware_from_buffer(struct smscore_device_t *coredev,
563 u8 *buffer, int size, 383 u8 *buffer, int size,
564 int new_mode); 384 int new_mode);
565 385
566extern int smscore_set_device_mode(smscore_device_t *coredev, int mode); 386extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode);
567extern int smscore_get_device_mode(smscore_device_t *coredev); 387extern int smscore_get_device_mode(struct smscore_device_t *coredev);
568 388
569extern int smscore_register_client(smscore_device_t *coredev, 389extern int smscore_register_client(struct smscore_device_t *coredev,
570 smsclient_params_t *params, 390 struct smsclient_params_t *params,
571 smscore_client_t **client); 391 struct smscore_client_t **client);
572extern void smscore_unregister_client(smscore_client_t *client); 392extern void smscore_unregister_client(struct smscore_client_t *client);
573 393
574extern int smsclient_sendrequest(smscore_client_t *client, 394extern int smsclient_sendrequest(struct smscore_client_t *client,
575 void *buffer, size_t size); 395 void *buffer, size_t size);
576extern void smscore_onresponse(smscore_device_t *coredev, 396extern void smscore_onresponse(struct smscore_device_t *coredev,
577 smscore_buffer_t *cb); 397 struct smscore_buffer_t *cb);
578 398
579extern int smscore_get_common_buffer_size(smscore_device_t *coredev); 399extern int smscore_get_common_buffer_size(struct smscore_device_t *coredev);
580extern int smscore_map_common_buffer(smscore_device_t *coredev, 400extern int smscore_map_common_buffer(struct smscore_device_t *coredev,
581 struct vm_area_struct *vma); 401 struct vm_area_struct *vma);
582 402
583extern smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev); 403extern struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev);
584extern void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb); 404extern void smscore_putbuffer(struct smscore_device_t *coredev,
405 struct smscore_buffer_t *cb);
585 406
586/* smsdvb.c */ 407/* smsdvb.c */
587int smsdvb_register(void); 408int smsdvb_register(void);
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 65b1db61ac15..b17696fcbbc6 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -29,15 +29,16 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
29struct list_head g_smsdvb_clients; 29struct list_head g_smsdvb_clients;
30kmutex_t g_smsdvb_clientslock; 30kmutex_t g_smsdvb_clientslock;
31 31
32int smsdvb_onresponse(void *context, smscore_buffer_t *cb) 32int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
33{ 33{
34 smsdvb_client_t *client = (smsdvb_client_t *) context; 34 struct smsdvb_client_t *client = (struct smsdvb_client_t *) context;
35 SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); 35 struct SmsMsgHdr_ST *phdr =
36 (struct SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset);
36 37
37 switch (phdr->msgType) { 38 switch (phdr->msgType) {
38 case MSG_SMS_DVBT_BDA_DATA: 39 case MSG_SMS_DVBT_BDA_DATA:
39 dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1), 40 dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1),
40 cb->size - sizeof(SmsMsgHdr_ST)); 41 cb->size - sizeof(struct SmsMsgHdr_ST));
41 break; 42 break;
42 43
43 case MSG_SMS_RF_TUNE_RES: 44 case MSG_SMS_RF_TUNE_RES:
@@ -46,8 +47,8 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
46 47
47 case MSG_SMS_GET_STATISTICS_RES: 48 case MSG_SMS_GET_STATISTICS_RES:
48 { 49 {
49 SmsMsgStatisticsInfo_ST *p = 50 struct SmsMsgStatisticsInfo_ST *p =
50 (SmsMsgStatisticsInfo_ST *)(phdr + 1); 51 (struct SmsMsgStatisticsInfo_ST *)(phdr + 1);
51 52
52 if (p->Stat.IsDemodLocked) { 53 if (p->Stat.IsDemodLocked) {
53 client->fe_status = FE_HAS_SIGNAL | 54 client->fe_status = FE_HAS_SIGNAL |
@@ -82,7 +83,7 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
82 return 0; 83 return 0;
83} 84}
84 85
85void smsdvb_unregister_client(smsdvb_client_t *client) 86void smsdvb_unregister_client(struct smsdvb_client_t *client)
86{ 87{
87 /* must be called under clientslock */ 88 /* must be called under clientslock */
88 89
@@ -100,16 +101,16 @@ void smsdvb_onremove(void *context)
100{ 101{
101 kmutex_lock(&g_smsdvb_clientslock); 102 kmutex_lock(&g_smsdvb_clientslock);
102 103
103 smsdvb_unregister_client((smsdvb_client_t *) context); 104 smsdvb_unregister_client((struct smsdvb_client_t *) context);
104 105
105 kmutex_unlock(&g_smsdvb_clientslock); 106 kmutex_unlock(&g_smsdvb_clientslock);
106} 107}
107 108
108static int smsdvb_start_feed(struct dvb_demux_feed *feed) 109static int smsdvb_start_feed(struct dvb_demux_feed *feed)
109{ 110{
110 smsdvb_client_t *client = 111 struct smsdvb_client_t *client =
111 container_of(feed->demux, smsdvb_client_t, demux); 112 container_of(feed->demux, struct smsdvb_client_t, demux);
112 SmsMsgData_ST PidMsg; 113 struct SmsMsgData_ST PidMsg;
113 114
114 printk(KERN_DEBUG "%s add pid %d(%x)\n", __func__, 115 printk(KERN_DEBUG "%s add pid %d(%x)\n", __func__,
115 feed->pid, feed->pid); 116 feed->pid, feed->pid);
@@ -127,9 +128,9 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
127 128
128static int smsdvb_stop_feed(struct dvb_demux_feed *feed) 129static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
129{ 130{
130 smsdvb_client_t *client = 131 struct smsdvb_client_t *client =
131 container_of(feed->demux, smsdvb_client_t, demux); 132 container_of(feed->demux, struct smsdvb_client_t, demux);
132 SmsMsgData_ST PidMsg; 133 struct SmsMsgData_ST PidMsg;
133 134
134 printk(KERN_DEBUG "%s remove pid %d(%x)\n", __func__, 135 printk(KERN_DEBUG "%s remove pid %d(%x)\n", __func__,
135 feed->pid, feed->pid); 136 feed->pid, feed->pid);
@@ -145,7 +146,7 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
145 &PidMsg, sizeof(PidMsg)); 146 &PidMsg, sizeof(PidMsg));
146} 147}
147 148
148static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, 149static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client,
149 void *buffer, size_t size, 150 void *buffer, size_t size,
150 struct completion *completion) 151 struct completion *completion)
151{ 152{
@@ -158,18 +159,19 @@ static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client,
158 0 : -ETIME; 159 0 : -ETIME;
159} 160}
160 161
161static int smsdvb_send_statistics_request(smsdvb_client_t *client) 162static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
162{ 163{
163 SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, 164 struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ,
164 DVBT_BDA_CONTROL_MSG_ID, 165 DVBT_BDA_CONTROL_MSG_ID,
165 HIF_TASK, sizeof(SmsMsgHdr_ST), 0 }; 166 HIF_TASK, sizeof(struct SmsMsgHdr_ST), 0 };
166 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), 167 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
167 &client->stat_done); 168 &client->stat_done);
168} 169}
169 170
170static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) 171static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
171{ 172{
172 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 173 struct smsdvb_client_t *client =
174 container_of(fe, struct smsdvb_client_t, frontend);
173 int rc = smsdvb_send_statistics_request(client); 175 int rc = smsdvb_send_statistics_request(client);
174 176
175 if (!rc) 177 if (!rc)
@@ -180,7 +182,8 @@ static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
180 182
181static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) 183static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
182{ 184{
183 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 185 struct smsdvb_client_t *client =
186 container_of(fe, struct smsdvb_client_t, frontend);
184 int rc = smsdvb_send_statistics_request(client); 187 int rc = smsdvb_send_statistics_request(client);
185 188
186 if (!rc) 189 if (!rc)
@@ -191,7 +194,8 @@ static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
191 194
192static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) 195static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
193{ 196{
194 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 197 struct smsdvb_client_t *client =
198 container_of(fe, struct smsdvb_client_t, frontend);
195 int rc = smsdvb_send_statistics_request(client); 199 int rc = smsdvb_send_statistics_request(client);
196 200
197 if (!rc) 201 if (!rc)
@@ -202,7 +206,8 @@ static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
202 206
203static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) 207static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
204{ 208{
205 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 209 struct smsdvb_client_t *client =
210 container_of(fe, struct smsdvb_client_t, frontend);
206 int rc = smsdvb_send_statistics_request(client); 211 int rc = smsdvb_send_statistics_request(client);
207 212
208 if (!rc) 213 if (!rc)
@@ -225,11 +230,11 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe,
225static int smsdvb_set_frontend(struct dvb_frontend *fe, 230static int smsdvb_set_frontend(struct dvb_frontend *fe,
226 struct dvb_frontend_parameters *fep) 231 struct dvb_frontend_parameters *fep)
227{ 232{
228 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 233 struct smsdvb_client_t *client =
234 container_of(fe, struct smsdvb_client_t, frontend);
229 235
230 struct 236 struct {
231 { 237 struct SmsMsgHdr_ST Msg;
232 SmsMsgHdr_ST Msg;
233 u32 Data[3]; 238 u32 Data[3];
234 } Msg; 239 } Msg;
235 240
@@ -259,7 +264,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
259static int smsdvb_get_frontend(struct dvb_frontend *fe, 264static int smsdvb_get_frontend(struct dvb_frontend *fe,
260 struct dvb_frontend_parameters *fep) 265 struct dvb_frontend_parameters *fep)
261{ 266{
262 smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); 267 struct smsdvb_client_t *client =
268 container_of(fe, struct smsdvb_client_t, frontend);
263 269
264 printk(KERN_DEBUG "%s\n", __func__); 270 printk(KERN_DEBUG "%s\n", __func__);
265 271
@@ -303,11 +309,11 @@ static struct dvb_frontend_ops smsdvb_fe_ops = {
303 .read_snr = smsdvb_read_snr, 309 .read_snr = smsdvb_read_snr,
304}; 310};
305 311
306int smsdvb_hotplug(smscore_device_t *coredev, 312int smsdvb_hotplug(struct smscore_device_t *coredev,
307 struct device *device, int arrival) 313 struct device *device, int arrival)
308{ 314{
309 smsclient_params_t params; 315 struct smsclient_params_t params;
310 smsdvb_client_t *client; 316 struct smsdvb_client_t *client;
311 int rc; 317 int rc;
312 318
313 /* device removal handled by onremove callback */ 319 /* device removal handled by onremove callback */
@@ -320,7 +326,7 @@ int smsdvb_hotplug(smscore_device_t *coredev,
320 return 0; 326 return 0;
321 } 327 }
322 328
323 client = kzalloc(sizeof(smsdvb_client_t), GFP_KERNEL); 329 client = kzalloc(sizeof(struct smsdvb_client_t), GFP_KERNEL);
324 if (!client) { 330 if (!client) {
325 printk(KERN_INFO "%s kmalloc() failed\n", __func__); 331 printk(KERN_INFO "%s kmalloc() failed\n", __func__);
326 return -ENOMEM; 332 return -ENOMEM;
@@ -439,7 +445,7 @@ void smsdvb_unregister(void)
439 445
440 while (!list_empty(&g_smsdvb_clients)) 446 while (!list_empty(&g_smsdvb_clients))
441 smsdvb_unregister_client( 447 smsdvb_unregister_client(
442 (smsdvb_client_t *) g_smsdvb_clients.next); 448 (struct smsdvb_client_t *) g_smsdvb_clients.next);
443 449
444 kmutex_unlock(&g_smsdvb_clientslock); 450 kmutex_unlock(&g_smsdvb_clientslock);
445} 451}
diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
index 82f2e3e4bec6..85172f47c737 100644
--- a/drivers/media/dvb/siano/smsusb.c
+++ b/drivers/media/dvb/siano/smsusb.c
@@ -40,33 +40,31 @@
40#define USB_PID_NOVA_B 0x0201 40#define USB_PID_NOVA_B 0x0201
41#define USB_PID_VEGA 0x0300 41#define USB_PID_VEGA 0x0300
42 42
43typedef struct _smsusb_device smsusb_device_t; 43struct smsusb_device_t;
44 44
45typedef struct _smsusb_urb 45struct smsusb_urb_t {
46{ 46 struct smscore_buffer_t *cb;
47 smscore_buffer_t *cb; 47 struct smsusb_device_t *dev;
48 smsusb_device_t *dev;
49 48
50 struct urb urb; 49 struct urb urb;
51} smsusb_urb_t; 50};
52 51
53typedef struct _smsusb_device 52struct smsusb_device_t {
54{
55 struct usb_device *udev; 53 struct usb_device *udev;
56 smscore_device_t *coredev; 54 struct smscore_device_t *coredev;
57 55
58 smsusb_urb_t surbs[MAX_URBS]; 56 struct smsusb_urb_t surbs[MAX_URBS];
59 57
60 int response_alignment; 58 int response_alignment;
61 int buffer_size; 59 int buffer_size;
62} *psmsusb_device_t; 60};
63 61
64int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb); 62int smsusb_submit_urb(struct smsusb_device_t *dev, struct smsusb_urb_t *surb);
65 63
66void smsusb_onresponse(struct urb *urb) 64void smsusb_onresponse(struct urb *urb)
67{ 65{
68 smsusb_urb_t *surb = (smsusb_urb_t *) urb->context; 66 struct smsusb_urb_t *surb = (struct smsusb_urb_t *) urb->context;
69 smsusb_device_t *dev = surb->dev; 67 struct smsusb_device_t *dev = surb->dev;
70 68
71 if (urb->status < 0) { 69 if (urb->status < 0) {
72 printk(KERN_INFO "%s error, urb status %d, %d bytes\n", 70 printk(KERN_INFO "%s error, urb status %d, %d bytes\n",
@@ -75,7 +73,7 @@ void smsusb_onresponse(struct urb *urb)
75 } 73 }
76 74
77 if (urb->actual_length > 0) { 75 if (urb->actual_length > 0) {
78 SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) surb->cb->p; 76 struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) surb->cb->p;
79 77
80 if (urb->actual_length >= phdr->msgLength) { 78 if (urb->actual_length >= phdr->msgLength) {
81 surb->cb->size = phdr->msgLength; 79 surb->cb->size = phdr->msgLength;
@@ -102,7 +100,7 @@ void smsusb_onresponse(struct urb *urb)
102 /* move buffer pointer and 100 /* move buffer pointer and
103 * copy header to its new location */ 101 * copy header to its new location */
104 memcpy((char *) phdr + surb->cb->offset, 102 memcpy((char *) phdr + surb->cb->offset,
105 phdr, sizeof(SmsMsgHdr_ST)); 103 phdr, sizeof(struct SmsMsgHdr_ST));
106 } else 104 } else
107 surb->cb->offset = 0; 105 surb->cb->offset = 0;
108 106
@@ -119,7 +117,7 @@ exit_and_resubmit:
119 smsusb_submit_urb(dev, surb); 117 smsusb_submit_urb(dev, surb);
120} 118}
121 119
122int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb) 120int smsusb_submit_urb(struct smsusb_device_t *dev, struct smsusb_urb_t *surb)
123{ 121{
124 if (!surb->cb) { 122 if (!surb->cb) {
125 surb->cb = smscore_getbuffer(dev->coredev); 123 surb->cb = smscore_getbuffer(dev->coredev);
@@ -145,7 +143,7 @@ int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb)
145 return usb_submit_urb(&surb->urb, GFP_ATOMIC); 143 return usb_submit_urb(&surb->urb, GFP_ATOMIC);
146} 144}
147 145
148void smsusb_stop_streaming(smsusb_device_t *dev) 146void smsusb_stop_streaming(struct smsusb_device_t *dev)
149{ 147{
150 int i; 148 int i;
151 149
@@ -159,7 +157,7 @@ void smsusb_stop_streaming(smsusb_device_t *dev)
159 } 157 }
160} 158}
161 159
162int smsusb_start_streaming(smsusb_device_t *dev) 160int smsusb_start_streaming(struct smsusb_device_t *dev)
163{ 161{
164 int i, rc; 162 int i, rc;
165 163
@@ -178,7 +176,7 @@ int smsusb_start_streaming(smsusb_device_t *dev)
178 176
179int smsusb_sendrequest(void *context, void *buffer, size_t size) 177int smsusb_sendrequest(void *context, void *buffer, size_t size)
180{ 178{
181 smsusb_device_t *dev = (smsusb_device_t *) context; 179 struct smsusb_device_t *dev = (struct smsusb_device_t *) context;
182 int dummy; 180 int dummy;
183 181
184 return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2), 182 return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
@@ -235,7 +233,8 @@ int smsusb1_load_firmware(struct usb_device *udev, int id)
235 233
236void smsusb1_detectmode(void *context, int *mode) 234void smsusb1_detectmode(void *context, int *mode)
237{ 235{
238 char *product_string = ((smsusb_device_t *) context)->udev->product; 236 char *product_string =
237 ((struct smsusb_device_t *) context)->udev->product;
239 238
240 *mode = DEVICE_MODE_NONE; 239 *mode = DEVICE_MODE_NONE;
241 240
@@ -256,8 +255,8 @@ void smsusb1_detectmode(void *context, int *mode)
256 255
257int smsusb1_setmode(void *context, int mode) 256int smsusb1_setmode(void *context, int mode)
258{ 257{
259 SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK, 258 struct SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK,
260 sizeof(SmsMsgHdr_ST), 0 }; 259 sizeof(struct SmsMsgHdr_ST), 0 };
261 260
262 if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) { 261 if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
263 printk(KERN_INFO "%s invalid firmware id specified %d\n", 262 printk(KERN_INFO "%s invalid firmware id specified %d\n",
@@ -270,7 +269,8 @@ int smsusb1_setmode(void *context, int mode)
270 269
271void smsusb_term_device(struct usb_interface *intf) 270void smsusb_term_device(struct usb_interface *intf)
272{ 271{
273 smsusb_device_t *dev = (smsusb_device_t *) usb_get_intfdata(intf); 272 struct smsusb_device_t *dev =
273 (struct smsusb_device_t *) usb_get_intfdata(intf);
274 274
275 if (dev) { 275 if (dev) {
276 smsusb_stop_streaming(dev); 276 smsusb_stop_streaming(dev);
@@ -289,15 +289,15 @@ void smsusb_term_device(struct usb_interface *intf)
289 289
290int smsusb_init_device(struct usb_interface *intf) 290int smsusb_init_device(struct usb_interface *intf)
291{ 291{
292 smsdevice_params_t params; 292 struct smsdevice_params_t params;
293 smsusb_device_t *dev; 293 struct smsusb_device_t *dev;
294 int i, rc; 294 int i, rc;
295 295
296 /* create device object */ 296 /* create device object */
297 dev = kzalloc(sizeof(smsusb_device_t), GFP_KERNEL); 297 dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
298 if (!dev) { 298 if (!dev) {
299 printk(KERN_INFO "%s kzalloc(sizeof(smsusb_device_t) failed\n", 299 printk(KERN_INFO "%s kzalloc(sizeof(struct smsusb_device_t) "
300 __func__); 300 "failed\n", __func__);
301 return -ENOMEM; 301 return -ENOMEM;
302 } 302 }
303 303
@@ -334,7 +334,7 @@ int smsusb_init_device(struct usb_interface *intf)
334 dev->buffer_size = USB2_BUFFER_SIZE; 334 dev->buffer_size = USB2_BUFFER_SIZE;
335 dev->response_alignment = 335 dev->response_alignment =
336 dev->udev->ep_in[1]->desc.wMaxPacketSize - 336 dev->udev->ep_in[1]->desc.wMaxPacketSize -
337 sizeof(SmsMsgHdr_ST); 337 sizeof(struct SmsMsgHdr_ST);
338 338
339 params.flags |= SMS_DEVICE_FAMILY2; 339 params.flags |= SMS_DEVICE_FAMILY2;
340 break; 340 break;