diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2019-09-17 16:44:49 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-04 14:26:14 +0200 |
commit | 905eccc6a509d2818e3dd1304c55dc5291b7ea88 (patch) | |
tree | cb66e39355b269e6d711bd75c6f2c07dcff84085 | |
parent | usb: usb251xb: simplify reset helper (diff) | |
download | linux-905eccc6a509d2818e3dd1304c55dc5291b7ea88.tar.xz linux-905eccc6a509d2818e3dd1304c55dc5291b7ea88.zip |
usb: usb251xb: add pm_ops
Currently the driver don't support pm_ops. These ops are not necessary
if the supply isn't switchable (always on). This assumptions seems to be
wrong because no one needs a powered hub during suspend-to-ram/disk.
So adding simple_dev_pm_ops to be able to switch off the hub during
suspend and to restore the config after a resume operation.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Acked-by: Richard Leitner <richard.leitner@skidata.com>
Link: https://lore.kernel.org/r/20190917144449.32739-5-m.felsch@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/misc/usb251xb.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c index bc031d33f433..5bba19937da1 100644 --- a/drivers/usb/misc/usb251xb.c +++ b/drivers/usb/misc/usb251xb.c @@ -701,6 +701,29 @@ static int usb251xb_i2c_probe(struct i2c_client *i2c, return usb251xb_probe(hub); } +static int __maybe_unused usb251xb_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct usb251xb *hub = i2c_get_clientdata(client); + + return regulator_disable(hub->vdd); +} + +static int __maybe_unused usb251xb_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct usb251xb *hub = i2c_get_clientdata(client); + int err; + + err = regulator_enable(hub->vdd); + if (err) + return err; + + return usb251xb_connect(hub); +} + +static SIMPLE_DEV_PM_OPS(usb251xb_pm_ops, usb251xb_suspend, usb251xb_resume); + static const struct i2c_device_id usb251xb_id[] = { { "usb2512b", 0 }, { "usb2512bi", 0 }, @@ -718,6 +741,7 @@ static struct i2c_driver usb251xb_i2c_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = of_match_ptr(usb251xb_of_match), + .pm = &usb251xb_pm_ops, }, .probe = usb251xb_i2c_probe, .id_table = usb251xb_id, |