Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'hisi-drivers-for-6.1' of https://github.com/hisilicon/linux-hisi into arm/drivers

HiSilicon driver updates for 6.1:
- some small improvements to the hisi_lpc driver

* tag 'hisi-drivers-for-6.1' of https://github.com/hisilicon/linux-hisi:
bus: hisi_lpc: Use platform_device_register_full()
bus: hisi_lpc: Don't guard ACPI IDs with ACPI_PTR()
bus: hisi_lpc: Correct error code for timeout
bus: hisi_lpc: Use devm_platform_ioremap_resource
bus: hisi_lpc: Don't dereference fwnode handle

Link: https://lore.kernel.org/r/631FE463.6070701@hisilicon.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+44 -52
+44 -52
drivers/bus/hisi_lpc.c
··· 85 85 ndelay(LPC_NSEC_PERWAIT); 86 86 } while (--waitcnt); 87 87 88 - return -ETIME; 88 + return -ETIMEDOUT; 89 89 } 90 90 91 91 /* ··· 347 347 unsigned long sys_port; 348 348 resource_size_t len = resource_size(res); 349 349 350 - sys_port = logic_pio_trans_hwaddr(&host->fwnode, res->start, len); 350 + sys_port = logic_pio_trans_hwaddr(acpi_fwnode_handle(host), res->start, len); 351 351 if (sys_port == ~0UL) 352 352 return -EFAULT; 353 353 ··· 472 472 473 473 struct hisi_lpc_acpi_cell { 474 474 const char *hid; 475 - const char *name; 476 - void *pdata; 477 - size_t pdata_size; 475 + const struct platform_device_info *pdevinfo; 478 476 }; 479 477 480 478 static void hisi_lpc_acpi_remove(struct device *hostdev) ··· 503 505 /* ipmi */ 504 506 { 505 507 .hid = "IPI0001", 506 - .name = "hisi-lpc-ipmi", 508 + .pdevinfo = (struct platform_device_info []) { 509 + { 510 + .parent = hostdev, 511 + .fwnode = acpi_fwnode_handle(child), 512 + .name = "hisi-lpc-ipmi", 513 + .id = PLATFORM_DEVID_AUTO, 514 + .res = res, 515 + .num_res = num_res, 516 + }, 517 + }, 507 518 }, 508 519 /* 8250-compatible uart */ 509 520 { 510 521 .hid = "HISI1031", 511 - .name = "serial8250", 512 - .pdata = (struct plat_serial8250_port []) { 522 + .pdevinfo = (struct platform_device_info []) { 513 523 { 514 - .iobase = res->start, 515 - .uartclk = 1843200, 516 - .iotype = UPIO_PORT, 517 - .flags = UPF_BOOT_AUTOCONF, 524 + .parent = hostdev, 525 + .fwnode = acpi_fwnode_handle(child), 526 + .name = "serial8250", 527 + .id = PLATFORM_DEVID_AUTO, 528 + .res = res, 529 + .num_res = num_res, 530 + .data = (struct plat_serial8250_port []) { 531 + { 532 + .iobase = res->start, 533 + .uartclk = 1843200, 534 + .iotype = UPIO_PORT, 535 + .flags = UPF_BOOT_AUTOCONF, 536 + }, 537 + {} 538 + }, 539 + .size_data = 2 * sizeof(struct plat_serial8250_port), 518 540 }, 519 - {} 520 541 }, 521 - .pdata_size = 2 * 522 - sizeof(struct plat_serial8250_port), 523 542 }, 524 543 {} 525 544 }; 526 545 527 - for (; cell && cell->name; cell++) { 546 + for (; cell && cell->hid; cell++) { 528 547 if (!strcmp(cell->hid, hid)) { 529 548 found = true; 530 549 break; ··· 555 540 return 0; 556 541 } 557 542 558 - pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO); 559 - if (!pdev) 560 - return -ENOMEM; 561 - 562 - pdev->dev.parent = hostdev; 563 - ACPI_COMPANION_SET(&pdev->dev, child); 564 - 565 - ret = platform_device_add_resources(pdev, res, num_res); 566 - if (ret) 567 - goto fail; 568 - 569 - ret = platform_device_add_data(pdev, cell->pdata, cell->pdata_size); 570 - if (ret) 571 - goto fail; 572 - 573 - ret = platform_device_add(pdev); 574 - if (ret) 575 - goto fail; 543 + pdev = platform_device_register_full(cell->pdevinfo); 544 + if (IS_ERR(pdev)) 545 + return PTR_ERR(pdev); 576 546 577 547 acpi_device_set_enumerated(child); 578 548 return 0; 579 - 580 - fail: 581 - platform_device_put(pdev); 582 - return ret; 583 549 } 584 550 585 551 /* ··· 585 589 586 590 return ret; 587 591 } 588 - 589 - static const struct acpi_device_id hisi_lpc_acpi_match[] = { 590 - {"HISI0191"}, 591 - {} 592 - }; 593 592 #else 594 593 static int hisi_lpc_acpi_probe(struct device *dev) 595 594 { ··· 606 615 static int hisi_lpc_probe(struct platform_device *pdev) 607 616 { 608 617 struct device *dev = &pdev->dev; 609 - struct acpi_device *acpi_device = ACPI_COMPANION(dev); 610 618 struct logic_pio_hwaddr *range; 611 619 struct hisi_lpc_dev *lpcdev; 612 620 resource_size_t io_end; 613 - struct resource *res; 614 621 int ret; 615 622 616 623 lpcdev = devm_kzalloc(dev, sizeof(*lpcdev), GFP_KERNEL); ··· 617 628 618 629 spin_lock_init(&lpcdev->cycle_lock); 619 630 620 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 621 - lpcdev->membase = devm_ioremap_resource(dev, res); 631 + lpcdev->membase = devm_platform_ioremap_resource(pdev, 0); 622 632 if (IS_ERR(lpcdev->membase)) 623 633 return PTR_ERR(lpcdev->membase); 624 634 ··· 625 637 if (!range) 626 638 return -ENOMEM; 627 639 628 - range->fwnode = dev->fwnode; 640 + range->fwnode = dev_fwnode(dev); 629 641 range->flags = LOGIC_PIO_INDIRECT; 630 642 range->size = PIO_INDIRECT_SIZE; 631 643 range->hostdata = lpcdev; ··· 639 651 } 640 652 641 653 /* register the LPC host PIO resources */ 642 - if (acpi_device) 654 + if (is_acpi_device_node(range->fwnode)) 643 655 ret = hisi_lpc_acpi_probe(dev); 644 656 else 645 657 ret = of_platform_populate(dev->of_node, NULL, NULL, dev); ··· 660 672 static int hisi_lpc_remove(struct platform_device *pdev) 661 673 { 662 674 struct device *dev = &pdev->dev; 663 - struct acpi_device *acpi_device = ACPI_COMPANION(dev); 664 675 struct hisi_lpc_dev *lpcdev = dev_get_drvdata(dev); 665 676 struct logic_pio_hwaddr *range = lpcdev->io_host; 666 677 667 - if (acpi_device) 678 + if (is_acpi_device_node(range->fwnode)) 668 679 hisi_lpc_acpi_remove(dev); 669 680 else 670 681 of_platform_depopulate(dev); ··· 679 692 {} 680 693 }; 681 694 695 + static const struct acpi_device_id hisi_lpc_acpi_match[] = { 696 + {"HISI0191"}, 697 + {} 698 + }; 699 + 682 700 static struct platform_driver hisi_lpc_driver = { 683 701 .driver = { 684 702 .name = DRV_NAME, 685 703 .of_match_table = hisi_lpc_of_match, 686 - .acpi_match_table = ACPI_PTR(hisi_lpc_acpi_match), 704 + .acpi_match_table = hisi_lpc_acpi_match, 687 705 }, 688 706 .probe = hisi_lpc_probe, 689 707 .remove = hisi_lpc_remove,