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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"Fix the regression with AMD GPU suspend by reverting the
handling of bus regulators in the I2C core.

Also, there is a fix for the MPC driver to prevent an
out-of-bound-access"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
Revert "i2c: core: support bus regulator controlling in adapter"
i2c: mpc: Avoid out of bounds memory access

+9 -101
+9 -6
drivers/i2c/busses/i2c-mpc.c
··· 492 492 493 493 static void mpc_i2c_do_action(struct mpc_i2c *i2c) 494 494 { 495 - struct i2c_msg *msg = &i2c->msgs[i2c->curr_msg]; 495 + struct i2c_msg *msg = NULL; 496 496 int dir = 0; 497 497 int recv_len = 0; 498 498 u8 byte; ··· 501 501 502 502 i2c->cntl_bits &= ~(CCR_RSTA | CCR_MTX | CCR_TXAK); 503 503 504 - if (msg->flags & I2C_M_RD) 505 - dir = 1; 506 - if (msg->flags & I2C_M_RECV_LEN) 507 - recv_len = 1; 504 + if (i2c->action != MPC_I2C_ACTION_STOP) { 505 + msg = &i2c->msgs[i2c->curr_msg]; 506 + if (msg->flags & I2C_M_RD) 507 + dir = 1; 508 + if (msg->flags & I2C_M_RECV_LEN) 509 + recv_len = 1; 510 + } 508 511 509 512 switch (i2c->action) { 510 513 case MPC_I2C_ACTION_RESTART: ··· 584 581 break; 585 582 } 586 583 587 - if (msg->len == i2c->byte_posn) { 584 + if (msg && msg->len == i2c->byte_posn) { 588 585 i2c->curr_msg++; 589 586 i2c->byte_posn = 0; 590 587
-95
drivers/i2c/i2c-core-base.c
··· 466 466 static int i2c_device_probe(struct device *dev) 467 467 { 468 468 struct i2c_client *client = i2c_verify_client(dev); 469 - struct i2c_adapter *adap; 470 469 struct i2c_driver *driver; 471 470 int status; 472 471 473 472 if (!client) 474 473 return 0; 475 474 476 - adap = client->adapter; 477 475 client->irq = client->init_irq; 478 476 479 477 if (!client->irq) { ··· 537 539 538 540 dev_dbg(dev, "probe\n"); 539 541 540 - if (adap->bus_regulator) { 541 - status = regulator_enable(adap->bus_regulator); 542 - if (status < 0) { 543 - dev_err(&adap->dev, "Failed to enable bus regulator\n"); 544 - goto err_clear_wakeup_irq; 545 - } 546 - } 547 - 548 542 status = of_clk_set_defaults(dev->of_node, false); 549 543 if (status < 0) 550 544 goto err_clear_wakeup_irq; ··· 595 605 static void i2c_device_remove(struct device *dev) 596 606 { 597 607 struct i2c_client *client = to_i2c_client(dev); 598 - struct i2c_adapter *adap; 599 608 struct i2c_driver *driver; 600 609 601 - adap = client->adapter; 602 610 driver = to_i2c_driver(dev->driver); 603 611 if (driver->remove) { 604 612 int status; ··· 611 623 devres_release_group(&client->dev, client->devres_group_id); 612 624 613 625 dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev)); 614 - if (!pm_runtime_status_suspended(&client->dev) && adap->bus_regulator) 615 - regulator_disable(adap->bus_regulator); 616 626 617 627 dev_pm_clear_wake_irq(&client->dev); 618 628 device_init_wakeup(&client->dev, false); ··· 619 633 if (client->flags & I2C_CLIENT_HOST_NOTIFY) 620 634 pm_runtime_put(&client->adapter->dev); 621 635 } 622 - 623 - #ifdef CONFIG_PM_SLEEP 624 - static int i2c_resume_early(struct device *dev) 625 - { 626 - struct i2c_client *client = i2c_verify_client(dev); 627 - int err; 628 - 629 - if (!client) 630 - return 0; 631 - 632 - if (pm_runtime_status_suspended(&client->dev) && 633 - client->adapter->bus_regulator) { 634 - err = regulator_enable(client->adapter->bus_regulator); 635 - if (err) 636 - return err; 637 - } 638 - 639 - return pm_generic_resume_early(&client->dev); 640 - } 641 - 642 - static int i2c_suspend_late(struct device *dev) 643 - { 644 - struct i2c_client *client = i2c_verify_client(dev); 645 - int err; 646 - 647 - if (!client) 648 - return 0; 649 - 650 - err = pm_generic_suspend_late(&client->dev); 651 - if (err) 652 - return err; 653 - 654 - if (!pm_runtime_status_suspended(&client->dev) && 655 - client->adapter->bus_regulator) 656 - return regulator_disable(client->adapter->bus_regulator); 657 - 658 - return 0; 659 - } 660 - #endif 661 - 662 - #ifdef CONFIG_PM 663 - static int i2c_runtime_resume(struct device *dev) 664 - { 665 - struct i2c_client *client = i2c_verify_client(dev); 666 - int err; 667 - 668 - if (!client) 669 - return 0; 670 - 671 - if (client->adapter->bus_regulator) { 672 - err = regulator_enable(client->adapter->bus_regulator); 673 - if (err) 674 - return err; 675 - } 676 - 677 - return pm_generic_runtime_resume(&client->dev); 678 - } 679 - 680 - static int i2c_runtime_suspend(struct device *dev) 681 - { 682 - struct i2c_client *client = i2c_verify_client(dev); 683 - int err; 684 - 685 - if (!client) 686 - return 0; 687 - 688 - err = pm_generic_runtime_suspend(&client->dev); 689 - if (err) 690 - return err; 691 - 692 - if (client->adapter->bus_regulator) 693 - return regulator_disable(client->adapter->bus_regulator); 694 - return 0; 695 - } 696 - #endif 697 - 698 - static const struct dev_pm_ops i2c_device_pm = { 699 - SET_LATE_SYSTEM_SLEEP_PM_OPS(i2c_suspend_late, i2c_resume_early) 700 - SET_RUNTIME_PM_OPS(i2c_runtime_suspend, i2c_runtime_resume, NULL) 701 - }; 702 636 703 637 static void i2c_device_shutdown(struct device *dev) 704 638 { ··· 679 773 .probe = i2c_device_probe, 680 774 .remove = i2c_device_remove, 681 775 .shutdown = i2c_device_shutdown, 682 - .pm = &i2c_device_pm, 683 776 }; 684 777 EXPORT_SYMBOL_GPL(i2c_bus_type); 685 778