Skip to content

Commit 82169da

Browse files
committed
xenbus: add xenbus_device parameter to xenbus_read_driver_state()
In order to prepare checking the xenbus device status in xenbus_read_driver_state(), add the pointer to struct xenbus_device as a parameter. Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> # SCSI Acked-by: Jakub Kicinski <kuba@kernel.org> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/xen-pcifront.c Signed-off-by: Juergen Gross <jgross@suse.com> Message-ID: <20260218095205.453657-2-jgross@suse.com>
1 parent 7271cb9 commit 82169da

8 files changed

Lines changed: 36 additions & 33 deletions

File tree

drivers/net/xen-netfront.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ static int xennet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
16461646

16471647
/* avoid the race with XDP headroom adjustment */
16481648
wait_event(module_wq,
1649-
xenbus_read_driver_state(np->xbdev->otherend) ==
1649+
xenbus_read_driver_state(np->xbdev, np->xbdev->otherend) ==
16501650
XenbusStateReconfigured);
16511651
np->netfront_xdp_enabled = true;
16521652

@@ -1764,9 +1764,9 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
17641764
do {
17651765
xenbus_switch_state(dev, XenbusStateInitialising);
17661766
err = wait_event_timeout(module_wq,
1767-
xenbus_read_driver_state(dev->otherend) !=
1767+
xenbus_read_driver_state(dev, dev->otherend) !=
17681768
XenbusStateClosed &&
1769-
xenbus_read_driver_state(dev->otherend) !=
1769+
xenbus_read_driver_state(dev, dev->otherend) !=
17701770
XenbusStateUnknown, XENNET_TIMEOUT);
17711771
} while (!err);
17721772

@@ -2627,31 +2627,31 @@ static void xennet_bus_close(struct xenbus_device *dev)
26272627
{
26282628
int ret;
26292629

2630-
if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)
2630+
if (xenbus_read_driver_state(dev, dev->otherend) == XenbusStateClosed)
26312631
return;
26322632
do {
26332633
xenbus_switch_state(dev, XenbusStateClosing);
26342634
ret = wait_event_timeout(module_wq,
2635-
xenbus_read_driver_state(dev->otherend) ==
2636-
XenbusStateClosing ||
2637-
xenbus_read_driver_state(dev->otherend) ==
2638-
XenbusStateClosed ||
2639-
xenbus_read_driver_state(dev->otherend) ==
2640-
XenbusStateUnknown,
2641-
XENNET_TIMEOUT);
2635+
xenbus_read_driver_state(dev, dev->otherend) ==
2636+
XenbusStateClosing ||
2637+
xenbus_read_driver_state(dev, dev->otherend) ==
2638+
XenbusStateClosed ||
2639+
xenbus_read_driver_state(dev, dev->otherend) ==
2640+
XenbusStateUnknown,
2641+
XENNET_TIMEOUT);
26422642
} while (!ret);
26432643

2644-
if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed)
2644+
if (xenbus_read_driver_state(dev, dev->otherend) == XenbusStateClosed)
26452645
return;
26462646

26472647
do {
26482648
xenbus_switch_state(dev, XenbusStateClosed);
26492649
ret = wait_event_timeout(module_wq,
2650-
xenbus_read_driver_state(dev->otherend) ==
2651-
XenbusStateClosed ||
2652-
xenbus_read_driver_state(dev->otherend) ==
2653-
XenbusStateUnknown,
2654-
XENNET_TIMEOUT);
2650+
xenbus_read_driver_state(dev, dev->otherend) ==
2651+
XenbusStateClosed ||
2652+
xenbus_read_driver_state(dev, dev->otherend) ==
2653+
XenbusStateUnknown,
2654+
XENNET_TIMEOUT);
26552655
} while (!ret);
26562656
}
26572657

drivers/pci/xen-pcifront.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ static void pcifront_try_connect(struct pcifront_device *pdev)
856856
int err;
857857

858858
/* Only connect once */
859-
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
859+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
860860
XenbusStateInitialised)
861861
return;
862862

@@ -876,7 +876,7 @@ static int pcifront_try_disconnect(struct pcifront_device *pdev)
876876
enum xenbus_state prev_state;
877877

878878

879-
prev_state = xenbus_read_driver_state(pdev->xdev->nodename);
879+
prev_state = xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename);
880880

881881
if (prev_state >= XenbusStateClosing)
882882
goto out;
@@ -895,7 +895,7 @@ static int pcifront_try_disconnect(struct pcifront_device *pdev)
895895

896896
static void pcifront_attach_devices(struct pcifront_device *pdev)
897897
{
898-
if (xenbus_read_driver_state(pdev->xdev->nodename) ==
898+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) ==
899899
XenbusStateReconfiguring)
900900
pcifront_connect(pdev);
901901
}
@@ -909,7 +909,7 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
909909
struct pci_dev *pci_dev;
910910
char str[64];
911911

912-
state = xenbus_read_driver_state(pdev->xdev->nodename);
912+
state = xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename);
913913
if (state == XenbusStateInitialised) {
914914
dev_dbg(&pdev->xdev->dev, "Handle skipped connect.\n");
915915
/* We missed Connected and need to initialize. */

drivers/scsi/xen-scsifront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ static void scsifront_backend_changed(struct xenbus_device *dev,
11751175
return;
11761176
}
11771177

1178-
if (xenbus_read_driver_state(dev->nodename) ==
1178+
if (xenbus_read_driver_state(dev, dev->nodename) ==
11791179
XenbusStateInitialised)
11801180
scsifront_do_lun_hotplug(info, VSCSIFRONT_OP_ADD_LUN);
11811181

drivers/xen/xen-pciback/xenbus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ static int xen_pcibk_attach(struct xen_pcibk_device *pdev)
149149

150150
mutex_lock(&pdev->dev_lock);
151151
/* Make sure we only do this setup once */
152-
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
152+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
153153
XenbusStateInitialised)
154154
goto out;
155155

156156
/* Wait for frontend to state that it has published the configuration */
157-
if (xenbus_read_driver_state(pdev->xdev->otherend) !=
157+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->otherend) !=
158158
XenbusStateInitialised)
159159
goto out;
160160

@@ -374,7 +374,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
374374
dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
375375

376376
mutex_lock(&pdev->dev_lock);
377-
if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
377+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) != state)
378378
goto out;
379379

380380
err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
@@ -572,7 +572,7 @@ static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev)
572572
/* It's possible we could get the call to setup twice, so make sure
573573
* we're not already connected.
574574
*/
575-
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
575+
if (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename) !=
576576
XenbusStateInitWait)
577577
goto out;
578578

@@ -662,7 +662,7 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
662662
struct xen_pcibk_device *pdev =
663663
container_of(watch, struct xen_pcibk_device, be_watch);
664664

665-
switch (xenbus_read_driver_state(pdev->xdev->nodename)) {
665+
switch (xenbus_read_driver_state(pdev->xdev, pdev->xdev->nodename)) {
666666
case XenbusStateInitWait:
667667
xen_pcibk_setup_backend(pdev);
668668
break;

drivers/xen/xenbus/xenbus_client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,14 @@ static int xenbus_unmap_ring_hvm(struct xenbus_device *dev, void *vaddr)
931931

932932
/**
933933
* xenbus_read_driver_state - read state from a store path
934+
* @dev: xenbus device pointer
934935
* @path: path for driver
935936
*
936937
* Returns: the state of the driver rooted at the given store path, or
937938
* XenbusStateUnknown if no state can be read.
938939
*/
939-
enum xenbus_state xenbus_read_driver_state(const char *path)
940+
enum xenbus_state xenbus_read_driver_state(const struct xenbus_device *dev,
941+
const char *path)
940942
{
941943
enum xenbus_state result;
942944
int err = xenbus_gather(XBT_NIL, path, "state", "%d", &result, NULL);

drivers/xen/xenbus/xenbus_probe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void xenbus_otherend_changed(struct xenbus_watch *watch,
191191
return;
192192
}
193193

194-
state = xenbus_read_driver_state(dev->otherend);
194+
state = xenbus_read_driver_state(dev, dev->otherend);
195195

196196
dev_dbg(&dev->dev, "state is %d, (%s), %s, %s\n",
197197
state, xenbus_strstate(state), dev->otherend_watch.node, path);
@@ -364,7 +364,7 @@ void xenbus_dev_remove(struct device *_dev)
364364
* closed.
365365
*/
366366
if (!drv->allow_rebind ||
367-
xenbus_read_driver_state(dev->nodename) == XenbusStateClosing)
367+
xenbus_read_driver_state(dev, dev->nodename) == XenbusStateClosing)
368368
xenbus_switch_state(dev, XenbusStateClosed);
369369
}
370370
EXPORT_SYMBOL_GPL(xenbus_dev_remove);
@@ -514,7 +514,7 @@ int xenbus_probe_node(struct xen_bus_type *bus,
514514
size_t stringlen;
515515
char *tmpstring;
516516

517-
enum xenbus_state state = xenbus_read_driver_state(nodename);
517+
enum xenbus_state state = xenbus_read_driver_state(NULL, nodename);
518518

519519
if (state != XenbusStateInitialising) {
520520
/* Device is not new, so ignore it. This can happen if a

drivers/xen/xenbus/xenbus_probe_frontend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int print_device_status(struct device *dev, void *data)
253253
} else if (xendev->state < XenbusStateConnected) {
254254
enum xenbus_state rstate = XenbusStateUnknown;
255255
if (xendev->otherend)
256-
rstate = xenbus_read_driver_state(xendev->otherend);
256+
rstate = xenbus_read_driver_state(xendev, xendev->otherend);
257257
pr_warn("Timeout connecting to device: %s (local state %d, remote state %d)\n",
258258
xendev->nodename, xendev->state, rstate);
259259
}

include/xen/xenbus.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr);
228228
int xenbus_alloc_evtchn(struct xenbus_device *dev, evtchn_port_t *port);
229229
int xenbus_free_evtchn(struct xenbus_device *dev, evtchn_port_t port);
230230

231-
enum xenbus_state xenbus_read_driver_state(const char *path);
231+
enum xenbus_state xenbus_read_driver_state(const struct xenbus_device *dev,
232+
const char *path);
232233

233234
__printf(3, 4)
234235
void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...);

0 commit comments

Comments
 (0)