aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio/rio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rapidio/rio.c')
-rw-r--r--drivers/rapidio/rio.c110
1 files changed, 48 insertions, 62 deletions
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 38d949405618..83406696c7aa 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -81,6 +81,7 @@ u16 rio_local_get_device_id(struct rio_mport *port)
81 81
82 return (RIO_GET_DID(port->sys_size, result)); 82 return (RIO_GET_DID(port->sys_size, result));
83} 83}
84EXPORT_SYMBOL_GPL(rio_local_get_device_id);
84 85
85/** 86/**
86 * rio_query_mport - Query mport device attributes 87 * rio_query_mport - Query mport device attributes
@@ -110,9 +111,8 @@ EXPORT_SYMBOL(rio_query_mport);
110 */ 111 */
111struct rio_net *rio_alloc_net(struct rio_mport *mport) 112struct rio_net *rio_alloc_net(struct rio_mport *mport)
112{ 113{
113 struct rio_net *net; 114 struct rio_net *net = kzalloc(sizeof(*net), GFP_KERNEL);
114 115
115 net = kzalloc(sizeof(struct rio_net), GFP_KERNEL);
116 if (net) { 116 if (net) {
117 INIT_LIST_HEAD(&net->node); 117 INIT_LIST_HEAD(&net->node);
118 INIT_LIST_HEAD(&net->devices); 118 INIT_LIST_HEAD(&net->devices);
@@ -243,18 +243,17 @@ int rio_request_inb_mbox(struct rio_mport *mport,
243 int rc = -ENOSYS; 243 int rc = -ENOSYS;
244 struct resource *res; 244 struct resource *res;
245 245
246 if (mport->ops->open_inb_mbox == NULL) 246 if (!mport->ops->open_inb_mbox)
247 goto out; 247 goto out;
248 248
249 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 249 res = kzalloc(sizeof(*res), GFP_KERNEL);
250
251 if (res) { 250 if (res) {
252 rio_init_mbox_res(res, mbox, mbox); 251 rio_init_mbox_res(res, mbox, mbox);
253 252
254 /* Make sure this mailbox isn't in use */ 253 /* Make sure this mailbox isn't in use */
255 if ((rc = 254 rc = request_resource(&mport->riores[RIO_INB_MBOX_RESOURCE],
256 request_resource(&mport->riores[RIO_INB_MBOX_RESOURCE], 255 res);
257 res)) < 0) { 256 if (rc < 0) {
258 kfree(res); 257 kfree(res);
259 goto out; 258 goto out;
260 } 259 }
@@ -277,6 +276,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
277 out: 276 out:
278 return rc; 277 return rc;
279} 278}
279EXPORT_SYMBOL_GPL(rio_request_inb_mbox);
280 280
281/** 281/**
282 * rio_release_inb_mbox - release inbound mailbox message service 282 * rio_release_inb_mbox - release inbound mailbox message service
@@ -305,6 +305,7 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
305 305
306 return 0; 306 return 0;
307} 307}
308EXPORT_SYMBOL_GPL(rio_release_inb_mbox);
308 309
309/** 310/**
310 * rio_request_outb_mbox - request outbound mailbox service 311 * rio_request_outb_mbox - request outbound mailbox service
@@ -326,18 +327,17 @@ int rio_request_outb_mbox(struct rio_mport *mport,
326 int rc = -ENOSYS; 327 int rc = -ENOSYS;
327 struct resource *res; 328 struct resource *res;
328 329
329 if (mport->ops->open_outb_mbox == NULL) 330 if (!mport->ops->open_outb_mbox)
330 goto out; 331 goto out;
331 332
332 res = kzalloc(sizeof(struct resource), GFP_KERNEL); 333 res = kzalloc(sizeof(*res), GFP_KERNEL);
333
334 if (res) { 334 if (res) {
335 rio_init_mbox_res(res, mbox, mbox); 335 rio_init_mbox_res(res, mbox, mbox);
336 336
337 /* Make sure this outbound mailbox isn't in use */ 337 /* Make sure this outbound mailbox isn't in use */
338 if ((rc = 338 rc = request_resource(&mport->riores[RIO_OUTB_MBOX_RESOURCE],
339 request_resource(&mport->riores[RIO_OUTB_MBOX_RESOURCE], 339 res);
340 res)) < 0) { 340 if (rc < 0) {
341 kfree(res); 341 kfree(res);
342 goto out; 342 goto out;
343 } 343 }
@@ -360,6 +360,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
360 out: 360 out:
361 return rc; 361 return rc;
362} 362}
363EXPORT_SYMBOL_GPL(rio_request_outb_mbox);
363 364
364/** 365/**
365 * rio_release_outb_mbox - release outbound mailbox message service 366 * rio_release_outb_mbox - release outbound mailbox message service
@@ -388,6 +389,7 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
388 389
389 return 0; 390 return 0;
390} 391}
392EXPORT_SYMBOL_GPL(rio_release_outb_mbox);
391 393
392/** 394/**
393 * rio_setup_inb_dbell - bind inbound doorbell callback 395 * rio_setup_inb_dbell - bind inbound doorbell callback
@@ -405,13 +407,10 @@ rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
405 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst, 407 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst,
406 u16 info)) 408 u16 info))
407{ 409{
408 int rc = 0; 410 struct rio_dbell *dbell = kmalloc(sizeof(*dbell), GFP_KERNEL);
409 struct rio_dbell *dbell;
410 411
411 if (!(dbell = kmalloc(sizeof(struct rio_dbell), GFP_KERNEL))) { 412 if (!dbell)
412 rc = -ENOMEM; 413 return -ENOMEM;
413 goto out;
414 }
415 414
416 dbell->res = res; 415 dbell->res = res;
417 dbell->dinb = dinb; 416 dbell->dinb = dinb;
@@ -420,9 +419,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
420 mutex_lock(&mport->lock); 419 mutex_lock(&mport->lock);
421 list_add_tail(&dbell->node, &mport->dbells); 420 list_add_tail(&dbell->node, &mport->dbells);
422 mutex_unlock(&mport->lock); 421 mutex_unlock(&mport->lock);
423 422 return 0;
424 out:
425 return rc;
426} 423}
427 424
428/** 425/**
@@ -444,17 +441,16 @@ int rio_request_inb_dbell(struct rio_mport *mport,
444 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, 441 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src,
445 u16 dst, u16 info)) 442 u16 dst, u16 info))
446{ 443{
447 int rc = 0; 444 int rc;
448 445 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
449 struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL);
450 446
451 if (res) { 447 if (res) {
452 rio_init_dbell_res(res, start, end); 448 rio_init_dbell_res(res, start, end);
453 449
454 /* Make sure these doorbells aren't in use */ 450 /* Make sure these doorbells aren't in use */
455 if ((rc = 451 rc = request_resource(&mport->riores[RIO_DOORBELL_RESOURCE],
456 request_resource(&mport->riores[RIO_DOORBELL_RESOURCE], 452 res);
457 res)) < 0) { 453 if (rc < 0) {
458 kfree(res); 454 kfree(res);
459 goto out; 455 goto out;
460 } 456 }
@@ -467,6 +463,7 @@ int rio_request_inb_dbell(struct rio_mport *mport,
467 out: 463 out:
468 return rc; 464 return rc;
469} 465}
466EXPORT_SYMBOL_GPL(rio_request_inb_dbell);
470 467
471/** 468/**
472 * rio_release_inb_dbell - release inbound doorbell message service 469 * rio_release_inb_dbell - release inbound doorbell message service
@@ -508,6 +505,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)
508 out: 505 out:
509 return rc; 506 return rc;
510} 507}
508EXPORT_SYMBOL_GPL(rio_release_inb_dbell);
511 509
512/** 510/**
513 * rio_request_outb_dbell - request outbound doorbell message range 511 * rio_request_outb_dbell - request outbound doorbell message range
@@ -536,6 +534,7 @@ struct resource *rio_request_outb_dbell(struct rio_dev *rdev, u16 start,
536 534
537 return res; 535 return res;
538} 536}
537EXPORT_SYMBOL_GPL(rio_request_outb_dbell);
539 538
540/** 539/**
541 * rio_release_outb_dbell - release outbound doorbell message range 540 * rio_release_outb_dbell - release outbound doorbell message range
@@ -553,6 +552,7 @@ int rio_release_outb_dbell(struct rio_dev *rdev, struct resource *res)
553 552
554 return rc; 553 return rc;
555} 554}
555EXPORT_SYMBOL_GPL(rio_release_outb_dbell);
556 556
557/** 557/**
558 * rio_add_mport_pw_handler - add port-write message handler into the list 558 * rio_add_mport_pw_handler - add port-write message handler into the list
@@ -567,22 +567,17 @@ int rio_add_mport_pw_handler(struct rio_mport *mport, void *context,
567 int (*pwcback)(struct rio_mport *mport, 567 int (*pwcback)(struct rio_mport *mport,
568 void *context, union rio_pw_msg *msg, int step)) 568 void *context, union rio_pw_msg *msg, int step))
569{ 569{
570 int rc = 0; 570 struct rio_pwrite *pwrite = kzalloc(sizeof(*pwrite), GFP_KERNEL);
571 struct rio_pwrite *pwrite;
572 571
573 pwrite = kzalloc(sizeof(struct rio_pwrite), GFP_KERNEL); 572 if (!pwrite)
574 if (!pwrite) { 573 return -ENOMEM;
575 rc = -ENOMEM;
576 goto out;
577 }
578 574
579 pwrite->pwcback = pwcback; 575 pwrite->pwcback = pwcback;
580 pwrite->context = context; 576 pwrite->context = context;
581 mutex_lock(&mport->lock); 577 mutex_lock(&mport->lock);
582 list_add_tail(&pwrite->node, &mport->pwrites); 578 list_add_tail(&pwrite->node, &mport->pwrites);
583 mutex_unlock(&mport->lock); 579 mutex_unlock(&mport->lock);
584out: 580 return 0;
585 return rc;
586} 581}
587EXPORT_SYMBOL_GPL(rio_add_mport_pw_handler); 582EXPORT_SYMBOL_GPL(rio_add_mport_pw_handler);
588 583
@@ -632,7 +627,7 @@ int rio_request_inb_pwrite(struct rio_dev *rdev,
632 int rc = 0; 627 int rc = 0;
633 628
634 spin_lock(&rio_global_list_lock); 629 spin_lock(&rio_global_list_lock);
635 if (rdev->pwcback != NULL) 630 if (rdev->pwcback)
636 rc = -ENOMEM; 631 rc = -ENOMEM;
637 else 632 else
638 rdev->pwcback = pwcback; 633 rdev->pwcback = pwcback;
@@ -698,7 +693,7 @@ EXPORT_SYMBOL_GPL(rio_pw_enable);
698int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local, 693int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local,
699 u64 rbase, u32 size, u32 rflags) 694 u64 rbase, u32 size, u32 rflags)
700{ 695{
701 int rc = 0; 696 int rc;
702 unsigned long flags; 697 unsigned long flags;
703 698
704 if (!mport->ops->map_inb) 699 if (!mport->ops->map_inb)
@@ -742,7 +737,7 @@ EXPORT_SYMBOL_GPL(rio_unmap_inb_region);
742int rio_map_outb_region(struct rio_mport *mport, u16 destid, u64 rbase, 737int rio_map_outb_region(struct rio_mport *mport, u16 destid, u64 rbase,
743 u32 size, u32 rflags, dma_addr_t *local) 738 u32 size, u32 rflags, dma_addr_t *local)
744{ 739{
745 int rc = 0; 740 int rc;
746 unsigned long flags; 741 unsigned long flags;
747 742
748 if (!mport->ops->map_outb) 743 if (!mport->ops->map_outb)
@@ -975,7 +970,7 @@ rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum)
975 rdev = rdev->prev; 970 rdev = rdev->prev;
976 } 971 }
977 972
978 if (prev == NULL) 973 if (!prev)
979 goto err_out; 974 goto err_out;
980 975
981 p_port = prev->rswitch->route_table[rdev->destid]; 976 p_port = prev->rswitch->route_table[rdev->destid];
@@ -1054,7 +1049,7 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
1054 RIO_MNT_REQ_CMD_IS); 1049 RIO_MNT_REQ_CMD_IS);
1055 1050
1056 /* Exit if the response is not expected */ 1051 /* Exit if the response is not expected */
1057 if (lnkresp == NULL) 1052 if (!lnkresp)
1058 return 0; 1053 return 0;
1059 1054
1060 checkcount = 3; 1055 checkcount = 3;
@@ -1411,7 +1406,9 @@ rio_mport_get_feature(struct rio_mport * port, int local, u16 destid,
1411 ext_ftr_ptr, &ftr_header); 1406 ext_ftr_ptr, &ftr_header);
1412 if (RIO_GET_BLOCK_ID(ftr_header) == ftr) 1407 if (RIO_GET_BLOCK_ID(ftr_header) == ftr)
1413 return ext_ftr_ptr; 1408 return ext_ftr_ptr;
1414 if (!(ext_ftr_ptr = RIO_GET_BLOCK_PTR(ftr_header))) 1409
1410 ext_ftr_ptr = RIO_GET_BLOCK_PTR(ftr_header);
1411 if (!ext_ftr_ptr)
1415 break; 1412 break;
1416 } 1413 }
1417 1414
@@ -1462,6 +1459,7 @@ struct rio_dev *rio_get_asm(u16 vid, u16 did,
1462 spin_unlock(&rio_global_list_lock); 1459 spin_unlock(&rio_global_list_lock);
1463 return rdev; 1460 return rdev;
1464} 1461}
1462EXPORT_SYMBOL_GPL(rio_get_asm);
1465 1463
1466/** 1464/**
1467 * rio_get_device - Begin or continue searching for a RIO device by vid/did 1465 * rio_get_device - Begin or continue searching for a RIO device by vid/did
@@ -1481,6 +1479,7 @@ struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from)
1481{ 1479{
1482 return rio_get_asm(vid, did, RIO_ANY_ID, RIO_ANY_ID, from); 1480 return rio_get_asm(vid, did, RIO_ANY_ID, RIO_ANY_ID, from);
1483} 1481}
1482EXPORT_SYMBOL_GPL(rio_get_device);
1484 1483
1485/** 1484/**
1486 * rio_std_route_add_entry - Add switch route table entry using standard 1485 * rio_std_route_add_entry - Add switch route table entry using standard
@@ -1696,7 +1695,7 @@ int rio_route_add_entry(struct rio_dev *rdev,
1696 1695
1697 spin_lock(&rdev->rswitch->lock); 1696 spin_lock(&rdev->rswitch->lock);
1698 1697
1699 if (ops == NULL || ops->add_entry == NULL) { 1698 if (!ops || !ops->add_entry) {
1700 rc = rio_std_route_add_entry(rdev->net->hport, rdev->destid, 1699 rc = rio_std_route_add_entry(rdev->net->hport, rdev->destid,
1701 rdev->hopcount, table, 1700 rdev->hopcount, table,
1702 route_destid, route_port); 1701 route_destid, route_port);
@@ -1749,7 +1748,7 @@ int rio_route_get_entry(struct rio_dev *rdev, u16 table,
1749 1748
1750 spin_lock(&rdev->rswitch->lock); 1749 spin_lock(&rdev->rswitch->lock);
1751 1750
1752 if (ops == NULL || ops->get_entry == NULL) { 1751 if (!ops || !ops->get_entry) {
1753 rc = rio_std_route_get_entry(rdev->net->hport, rdev->destid, 1752 rc = rio_std_route_get_entry(rdev->net->hport, rdev->destid,
1754 rdev->hopcount, table, 1753 rdev->hopcount, table,
1755 route_destid, route_port); 1754 route_destid, route_port);
@@ -1797,7 +1796,7 @@ int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock)
1797 1796
1798 spin_lock(&rdev->rswitch->lock); 1797 spin_lock(&rdev->rswitch->lock);
1799 1798
1800 if (ops == NULL || ops->clr_table == NULL) { 1799 if (!ops || !ops->clr_table) {
1801 rc = rio_std_route_clr_table(rdev->net->hport, rdev->destid, 1800 rc = rio_std_route_clr_table(rdev->net->hport, rdev->destid,
1802 rdev->hopcount, table); 1801 rdev->hopcount, table);
1803 } else if (try_module_get(ops->owner)) { 1802 } else if (try_module_get(ops->owner)) {
@@ -1889,7 +1888,7 @@ struct dma_async_tx_descriptor *rio_dma_prep_xfer(struct dma_chan *dchan,
1889{ 1888{
1890 struct rio_dma_ext rio_ext; 1889 struct rio_dma_ext rio_ext;
1891 1890
1892 if (dchan->device->device_prep_slave_sg == NULL) { 1891 if (!dchan->device->device_prep_slave_sg) {
1893 pr_err("%s: prep_rio_sg == NULL\n", __func__); 1892 pr_err("%s: prep_rio_sg == NULL\n", __func__);
1894 return NULL; 1893 return NULL;
1895 } 1894 }
@@ -2189,7 +2188,6 @@ int rio_init_mports(void)
2189 2188
2190 work = kcalloc(n, sizeof *work, GFP_KERNEL); 2189 work = kcalloc(n, sizeof *work, GFP_KERNEL);
2191 if (!work) { 2190 if (!work) {
2192 pr_err("RIO: no memory for work struct\n");
2193 destroy_workqueue(rio_wq); 2191 destroy_workqueue(rio_wq);
2194 goto no_disc; 2192 goto no_disc;
2195 } 2193 }
@@ -2216,6 +2214,7 @@ no_disc:
2216 2214
2217 return 0; 2215 return 0;
2218} 2216}
2217EXPORT_SYMBOL_GPL(rio_init_mports);
2219 2218
2220static int rio_get_hdid(int index) 2219static int rio_get_hdid(int index)
2221{ 2220{
@@ -2330,16 +2329,3 @@ int rio_unregister_mport(struct rio_mport *port)
2330 return 0; 2329 return 0;
2331} 2330}
2332EXPORT_SYMBOL_GPL(rio_unregister_mport); 2331EXPORT_SYMBOL_GPL(rio_unregister_mport);
2333
2334EXPORT_SYMBOL_GPL(rio_local_get_device_id);
2335EXPORT_SYMBOL_GPL(rio_get_device);
2336EXPORT_SYMBOL_GPL(rio_get_asm);
2337EXPORT_SYMBOL_GPL(rio_request_inb_dbell);
2338EXPORT_SYMBOL_GPL(rio_release_inb_dbell);
2339EXPORT_SYMBOL_GPL(rio_request_outb_dbell);
2340EXPORT_SYMBOL_GPL(rio_release_outb_dbell);
2341EXPORT_SYMBOL_GPL(rio_request_inb_mbox);
2342EXPORT_SYMBOL_GPL(rio_release_inb_mbox);
2343EXPORT_SYMBOL_GPL(rio_request_outb_mbox);
2344EXPORT_SYMBOL_GPL(rio_release_outb_mbox);
2345EXPORT_SYMBOL_GPL(rio_init_mports);