aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/siano/smscoreapi.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-06-15 16:52:24 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:21:59 -0400
commit18245e18eeae15e928b46c1ae0f3a19bdc50419d (patch)
treead4944cb0d154e737ab979d4010240f66275e291 /drivers/media/dvb/siano/smscoreapi.c
parentca78373687bddcd436e1bf2d9b6806cfd9cad8b8 (diff)
V4L/DVB (8286): sms1xxx: remove typedefs
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/siano/smscoreapi.c')
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c243
1 files changed, 127 insertions, 116 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);