Skip to content

Commit a19f75d

Browse files
committed
Revert "i2c: core: support bus regulator controlling in adapter"
This largely reverts commit 5a7b95f. It breaks suspend with AMD GPUs, and we couldn't incrementally fix it. So, let's remove the code and go back to the drawing board. We keep the header extension to not break drivers already populating the regulator. We expect to re-add the code handling it soon. Fixes: 5a7b95f ("i2c: core: support bus regulator controlling in adapter") Reported-by: "Tareque Md.Hanif" <tarequemd.hanif@yahoo.com> Link: https://lore.kernel.org/r/1295184560.182511.1639075777725@mail.yahoo.com Reported-by: Konstantin Kharlamov <hi-angel@yandex.ru> Link: https://lore.kernel.org/r/7143a7147978f4104171072d9f5225d2ce355ec1.camel@yandex.ru BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1850 Tested-by: "Tareque Md.Hanif" <tarequemd.hanif@yahoo.com> Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru> Signed-off-by: Wolfram Sang <wsa@kernel.org> Cc: <stable@vger.kernel.org> # 5.14+
1 parent 72a4a87 commit a19f75d

File tree

1 file changed

+0
-95
lines changed

1 file changed

+0
-95
lines changed

drivers/i2c/i2c-core-base.c

-95
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,12 @@ static int i2c_smbus_host_notify_to_irq(const struct i2c_client *client)
466466
static int i2c_device_probe(struct device *dev)
467467
{
468468
struct i2c_client *client = i2c_verify_client(dev);
469-
struct i2c_adapter *adap;
470469
struct i2c_driver *driver;
471470
int status;
472471

473472
if (!client)
474473
return 0;
475474

476-
adap = client->adapter;
477475
client->irq = client->init_irq;
478476

479477
if (!client->irq) {
@@ -539,14 +537,6 @@ static int i2c_device_probe(struct device *dev)
539537

540538
dev_dbg(dev, "probe\n");
541539

542-
if (adap->bus_regulator) {
543-
status = regulator_enable(adap->bus_regulator);
544-
if (status < 0) {
545-
dev_err(&adap->dev, "Failed to enable bus regulator\n");
546-
goto err_clear_wakeup_irq;
547-
}
548-
}
549-
550540
status = of_clk_set_defaults(dev->of_node, false);
551541
if (status < 0)
552542
goto err_clear_wakeup_irq;
@@ -605,10 +595,8 @@ static int i2c_device_probe(struct device *dev)
605595
static void i2c_device_remove(struct device *dev)
606596
{
607597
struct i2c_client *client = to_i2c_client(dev);
608-
struct i2c_adapter *adap;
609598
struct i2c_driver *driver;
610599

611-
adap = client->adapter;
612600
driver = to_i2c_driver(dev->driver);
613601
if (driver->remove) {
614602
int status;
@@ -623,8 +611,6 @@ static void i2c_device_remove(struct device *dev)
623611
devres_release_group(&client->dev, client->devres_group_id);
624612

625613
dev_pm_domain_detach(&client->dev, !i2c_acpi_waive_d0_probe(dev));
626-
if (!pm_runtime_status_suspended(&client->dev) && adap->bus_regulator)
627-
regulator_disable(adap->bus_regulator);
628614

629615
dev_pm_clear_wake_irq(&client->dev);
630616
device_init_wakeup(&client->dev, false);
@@ -634,86 +620,6 @@ static void i2c_device_remove(struct device *dev)
634620
pm_runtime_put(&client->adapter->dev);
635621
}
636622

637-
#ifdef CONFIG_PM_SLEEP
638-
static int i2c_resume_early(struct device *dev)
639-
{
640-
struct i2c_client *client = i2c_verify_client(dev);
641-
int err;
642-
643-
if (!client)
644-
return 0;
645-
646-
if (pm_runtime_status_suspended(&client->dev) &&
647-
client->adapter->bus_regulator) {
648-
err = regulator_enable(client->adapter->bus_regulator);
649-
if (err)
650-
return err;
651-
}
652-
653-
return pm_generic_resume_early(&client->dev);
654-
}
655-
656-
static int i2c_suspend_late(struct device *dev)
657-
{
658-
struct i2c_client *client = i2c_verify_client(dev);
659-
int err;
660-
661-
if (!client)
662-
return 0;
663-
664-
err = pm_generic_suspend_late(&client->dev);
665-
if (err)
666-
return err;
667-
668-
if (!pm_runtime_status_suspended(&client->dev) &&
669-
client->adapter->bus_regulator)
670-
return regulator_disable(client->adapter->bus_regulator);
671-
672-
return 0;
673-
}
674-
#endif
675-
676-
#ifdef CONFIG_PM
677-
static int i2c_runtime_resume(struct device *dev)
678-
{
679-
struct i2c_client *client = i2c_verify_client(dev);
680-
int err;
681-
682-
if (!client)
683-
return 0;
684-
685-
if (client->adapter->bus_regulator) {
686-
err = regulator_enable(client->adapter->bus_regulator);
687-
if (err)
688-
return err;
689-
}
690-
691-
return pm_generic_runtime_resume(&client->dev);
692-
}
693-
694-
static int i2c_runtime_suspend(struct device *dev)
695-
{
696-
struct i2c_client *client = i2c_verify_client(dev);
697-
int err;
698-
699-
if (!client)
700-
return 0;
701-
702-
err = pm_generic_runtime_suspend(&client->dev);
703-
if (err)
704-
return err;
705-
706-
if (client->adapter->bus_regulator)
707-
return regulator_disable(client->adapter->bus_regulator);
708-
return 0;
709-
}
710-
#endif
711-
712-
static const struct dev_pm_ops i2c_device_pm = {
713-
SET_LATE_SYSTEM_SLEEP_PM_OPS(i2c_suspend_late, i2c_resume_early)
714-
SET_RUNTIME_PM_OPS(i2c_runtime_suspend, i2c_runtime_resume, NULL)
715-
};
716-
717623
static void i2c_device_shutdown(struct device *dev)
718624
{
719625
struct i2c_client *client = i2c_verify_client(dev);
@@ -773,7 +679,6 @@ struct bus_type i2c_bus_type = {
773679
.probe = i2c_device_probe,
774680
.remove = i2c_device_remove,
775681
.shutdown = i2c_device_shutdown,
776-
.pm = &i2c_device_pm,
777682
};
778683
EXPORT_SYMBOL_GPL(i2c_bus_type);
779684

0 commit comments

Comments
 (0)