.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
2 | 3 | |
---|
3 | 4 | #define DPRINTK(fmt, ...) \ |
---|
.. | .. |
---|
18 | 19 | #include <linux/module.h> |
---|
19 | 20 | |
---|
20 | 21 | #include <asm/page.h> |
---|
21 | | -#include <asm/pgtable.h> |
---|
22 | 22 | #include <asm/xen/hypervisor.h> |
---|
23 | 23 | #include <xen/xenbus.h> |
---|
24 | 24 | #include <xen/events.h> |
---|
.. | .. |
---|
125 | 125 | return xenbus_dev_probe(dev); |
---|
126 | 126 | } |
---|
127 | 127 | |
---|
| 128 | +static void xenbus_frontend_dev_shutdown(struct device *_dev) |
---|
| 129 | +{ |
---|
| 130 | + struct xenbus_device *dev = to_xenbus_device(_dev); |
---|
| 131 | + unsigned long timeout = 5*HZ; |
---|
| 132 | + |
---|
| 133 | + DPRINTK("%s", dev->nodename); |
---|
| 134 | + |
---|
| 135 | + get_device(&dev->dev); |
---|
| 136 | + if (dev->state != XenbusStateConnected) { |
---|
| 137 | + pr_info("%s: %s: %s != Connected, skipping\n", |
---|
| 138 | + __func__, dev->nodename, xenbus_strstate(dev->state)); |
---|
| 139 | + goto out; |
---|
| 140 | + } |
---|
| 141 | + xenbus_switch_state(dev, XenbusStateClosing); |
---|
| 142 | + timeout = wait_for_completion_timeout(&dev->down, timeout); |
---|
| 143 | + if (!timeout) |
---|
| 144 | + pr_info("%s: %s timeout closing device\n", |
---|
| 145 | + __func__, dev->nodename); |
---|
| 146 | + out: |
---|
| 147 | + put_device(&dev->dev); |
---|
| 148 | +} |
---|
| 149 | + |
---|
128 | 150 | static const struct dev_pm_ops xenbus_pm_ops = { |
---|
129 | 151 | .suspend = xenbus_dev_suspend, |
---|
130 | 152 | .resume = xenbus_frontend_dev_resume, |
---|
.. | .. |
---|
145 | 167 | .uevent = xenbus_uevent_frontend, |
---|
146 | 168 | .probe = xenbus_frontend_dev_probe, |
---|
147 | 169 | .remove = xenbus_dev_remove, |
---|
148 | | - .shutdown = xenbus_dev_shutdown, |
---|
| 170 | + .shutdown = xenbus_frontend_dev_shutdown, |
---|
149 | 171 | .dev_groups = xenbus_dev_groups, |
---|
150 | 172 | |
---|
151 | 173 | .pm = &xenbus_pm_ops, |
---|
.. | .. |
---|
379 | 401 | case XenbusStateConnected: |
---|
380 | 402 | xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateClosing); |
---|
381 | 403 | xenbus_reset_wait_for_backend(be, XenbusStateClosing); |
---|
382 | | - /* fall through */ |
---|
| 404 | + fallthrough; |
---|
383 | 405 | |
---|
384 | 406 | case XenbusStateClosing: |
---|
385 | 407 | xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateClosed); |
---|
386 | 408 | xenbus_reset_wait_for_backend(be, XenbusStateClosed); |
---|
387 | | - /* fall through */ |
---|
| 409 | + fallthrough; |
---|
388 | 410 | |
---|
389 | 411 | case XenbusStateClosed: |
---|
390 | 412 | xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateInitialising); |
---|