aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_pmc_ipc.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2016-09-23 23:54:08 -0400
committerDarren Hart <dvhart@linux.intel.com>2016-09-28 19:33:04 -0400
commitea1a76bad8c9d0e7d91e7e4c9adf98fe3c7f09b7 (patch)
treec041007de8d6b6495ad793f9456c6a7c24d3e448 /drivers/platform/x86/intel_pmc_ipc.c
parentb5643539b82559b858b8efe3fc8343f66cf9a0b5 (diff)
platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full
Use platform_device_register_full() instead of open-coded. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/intel_pmc_ipc.c')
-rw-r--r--drivers/platform/x86/intel_pmc_ipc.c110
1 files changed, 33 insertions, 77 deletions
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index b86e1bcaa055..665a9a19adcb 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -522,48 +522,36 @@ static struct resource telemetry_res[] = {
522static int ipc_create_punit_device(void) 522static int ipc_create_punit_device(void)
523{ 523{
524 struct platform_device *pdev; 524 struct platform_device *pdev;
525 int ret; 525 const struct platform_device_info pdevinfo = {
526 526 .parent = ipcdev.dev,
527 pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1); 527 .name = PUNIT_DEVICE_NAME,
528 if (!pdev) { 528 .id = -1,
529 dev_err(ipcdev.dev, "Failed to alloc punit platform device\n"); 529 .res = punit_res_array,
530 return -ENOMEM; 530 .num_res = ARRAY_SIZE(punit_res_array),
531 } 531 };
532 532
533 pdev->dev.parent = ipcdev.dev; 533 pdev = platform_device_register_full(&pdevinfo);
534 ret = platform_device_add_resources(pdev, punit_res_array, 534 if (IS_ERR(pdev))
535 ARRAY_SIZE(punit_res_array)); 535 return PTR_ERR(pdev);
536 if (ret) {
537 dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
538 goto err;
539 }
540 536
541 ret = platform_device_add(pdev);
542 if (ret) {
543 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
544 goto err;
545 }
546 ipcdev.punit_dev = pdev; 537 ipcdev.punit_dev = pdev;
547 538
548 return 0; 539 return 0;
549err:
550 platform_device_put(pdev);
551 return ret;
552} 540}
553 541
554static int ipc_create_tco_device(void) 542static int ipc_create_tco_device(void)
555{ 543{
556 struct platform_device *pdev; 544 struct platform_device *pdev;
557 struct resource *res; 545 struct resource *res;
558 int ret; 546 const struct platform_device_info pdevinfo = {
559 547 .parent = ipcdev.dev,
560 pdev = platform_device_alloc(TCO_DEVICE_NAME, -1); 548 .name = TCO_DEVICE_NAME,
561 if (!pdev) { 549 .id = -1,
562 dev_err(ipcdev.dev, "Failed to alloc tco platform device\n"); 550 .res = tco_res,
563 return -ENOMEM; 551 .num_res = ARRAY_SIZE(tco_res),
564 } 552 .data = &tco_info,
565 553 .size_data = sizeof(tco_info),
566 pdev->dev.parent = ipcdev.dev; 554 };
567 555
568 res = tco_res + TCO_RESOURCE_ACPI_IO; 556 res = tco_res + TCO_RESOURCE_ACPI_IO;
569 res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET; 557 res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET;
@@ -577,45 +565,26 @@ static int ipc_create_tco_device(void)
577 res->start = ipcdev.gcr_base + TCO_PMC_OFFSET; 565 res->start = ipcdev.gcr_base + TCO_PMC_OFFSET;
578 res->end = res->start + TCO_PMC_SIZE - 1; 566 res->end = res->start + TCO_PMC_SIZE - 1;
579 567
580 ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res)); 568 pdev = platform_device_register_full(&pdevinfo);
581 if (ret) { 569 if (IS_ERR(pdev))
582 dev_err(ipcdev.dev, "Failed to add tco platform resources\n"); 570 return PTR_ERR(pdev);
583 goto err;
584 }
585
586 ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info));
587 if (ret) {
588 dev_err(ipcdev.dev, "Failed to add tco platform data\n");
589 goto err;
590 }
591 571
592 ret = platform_device_add(pdev);
593 if (ret) {
594 dev_err(ipcdev.dev, "Failed to add tco platform device\n");
595 goto err;
596 }
597 ipcdev.tco_dev = pdev; 572 ipcdev.tco_dev = pdev;
598 573
599 return 0; 574 return 0;
600err:
601 platform_device_put(pdev);
602 return ret;
603} 575}
604 576
605static int ipc_create_telemetry_device(void) 577static int ipc_create_telemetry_device(void)
606{ 578{
607 struct platform_device *pdev; 579 struct platform_device *pdev;
608 struct resource *res; 580 struct resource *res;
609 int ret; 581 const struct platform_device_info pdevinfo = {
610 582 .parent = ipcdev.dev,
611 pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1); 583 .name = TELEMETRY_DEVICE_NAME,
612 if (!pdev) { 584 .id = -1,
613 dev_err(ipcdev.dev, 585 .res = telemetry_res,
614 "Failed to allocate telemetry platform device\n"); 586 .num_res = ARRAY_SIZE(telemetry_res),
615 return -ENOMEM; 587 };
616 }
617
618 pdev->dev.parent = ipcdev.dev;
619 588
620 res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM; 589 res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM;
621 res->start = ipcdev.telem_punit_ssram_base; 590 res->start = ipcdev.telem_punit_ssram_base;
@@ -625,26 +594,13 @@ static int ipc_create_telemetry_device(void)
625 res->start = ipcdev.telem_pmc_ssram_base; 594 res->start = ipcdev.telem_pmc_ssram_base;
626 res->end = res->start + ipcdev.telem_pmc_ssram_size - 1; 595 res->end = res->start + ipcdev.telem_pmc_ssram_size - 1;
627 596
628 ret = platform_device_add_resources(pdev, telemetry_res, 597 pdev = platform_device_register_full(&pdevinfo);
629 ARRAY_SIZE(telemetry_res)); 598 if (IS_ERR(pdev))
630 if (ret) { 599 return PTR_ERR(pdev);
631 dev_err(ipcdev.dev,
632 "Failed to add telemetry platform resources\n");
633 goto err;
634 }
635 600
636 ret = platform_device_add(pdev);
637 if (ret) {
638 dev_err(ipcdev.dev,
639 "Failed to add telemetry platform device\n");
640 goto err;
641 }
642 ipcdev.telemetry_dev = pdev; 601 ipcdev.telemetry_dev = pdev;
643 602
644 return 0; 603 return 0;
645err:
646 platform_device_put(pdev);
647 return ret;
648} 604}
649 605
650static int ipc_create_pmc_devices(void) 606static int ipc_create_pmc_devices(void)