win-pvdrivers

changeset 94:ee715addb716

xenbus: tidy up msg_reply and AddWatch
author Andy Grover <andy.grover@oracle.com>
date Thu Jan 03 16:34:04 2008 -0800 (2008-01-03)
parents 2a2f98373c9a
children b55f4ed508b0
files xenpci/xenbus.c
line diff
     1.1 --- a/xenpci/xenbus.c	Thu Jan 03 16:19:31 2008 -0800
     1.2 +++ b/xenpci/xenbus.c	Thu Jan 03 16:34:04 2008 -0800
     1.3 @@ -218,31 +218,19 @@ xenbus_msg_reply(
     1.4  {
     1.5    PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
     1.6    int id;
     1.7 -//  DEFINE_WAIT(w);
     1.8 -  struct xsd_sockmsg *rep;
     1.9  
    1.10  //  KdPrint((__DRIVER_NAME " --> xenbus_msg_reply\n"));
    1.11  
    1.12    id = allocate_xenbus_id(Device);
    1.13 -//  add_waiter(w, req_info[id].waitq);
    1.14 -
    1.15    xb_write(Device, type, id, trans, io, nr_reqs);
    1.16 -//
    1.17 -//  schedule();
    1.18 -//  remove_waiter(w);
    1.19 -//  wake(current);
    1.20 -//
    1.21 +
    1.22  //  KdPrint((__DRIVER_NAME "     starting wait\n"));
    1.23 -
    1.24    KeWaitForSingleObject(&xpdd->req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
    1.25 -
    1.26    //KdPrint((__DRIVER_NAME "     wait complete\n"));
    1.27  
    1.28 -  rep = xpdd->req_info[id].Reply;
    1.29 -//  BUG_ON(rep->req_id != id);
    1.30    release_xenbus_id(Device, id);
    1.31  //  KdPrint((__DRIVER_NAME " <-- xenbus_msg_reply\n"));
    1.32 -  return rep;
    1.33 +  return xpdd->req_info[id].Reply;
    1.34  }
    1.35  
    1.36  char *
    1.37 @@ -589,10 +577,11 @@ XenBus_AddWatch(
    1.38    int i;
    1.39    char Token[20];
    1.40    struct write_req req[2];
    1.41 +  PXENBUS_WATCH_ENTRY w_entry;
    1.42  
    1.43  //  KdPrint((__DRIVER_NAME " --> XenBus_AddWatch\n"));
    1.44  
    1.45 -  // check that Path < 128 chars
    1.46 +  ASSERT(strlen(Path) < ARRAY_SIZE(w_entry->Path));
    1.47  
    1.48    for (i = 0; i < MAX_WATCH_ENTRIES; i++)
    1.49      if (xpdd->XenBus_WatchEntries[i].Active == 0)
    1.50 @@ -604,6 +593,14 @@ XenBus_AddWatch(
    1.51      return NULL;
    1.52    }
    1.53  
    1.54 +  /* must init watchentry before starting watch */
    1.55 +  w_entry = &xpdd->XenBus_WatchEntries[i];
    1.56 +  strncpy(w_entry->Path, Path, ARRAY_SIZE(w_entry->Path));
    1.57 +  w_entry->ServiceRoutine = ServiceRoutine;
    1.58 +  w_entry->ServiceContext = ServiceContext;
    1.59 +  w_entry->Count = 0;
    1.60 +  w_entry->Active = 1;
    1.61 +
    1.62    req[0].data = Path;
    1.63    req[0].len = strlen(Path) + 1;
    1.64  
    1.65 @@ -611,13 +608,6 @@ XenBus_AddWatch(
    1.66    req[1].data = Token;
    1.67    req[1].len = strlen(Token) + 1;
    1.68  
    1.69 -  /* must init watchentry before starting watch */
    1.70 -  strncpy(xpdd->XenBus_WatchEntries[i].Path, Path, 128);
    1.71 -  xpdd->XenBus_WatchEntries[i].ServiceRoutine = ServiceRoutine;
    1.72 -  xpdd->XenBus_WatchEntries[i].ServiceContext = ServiceContext;
    1.73 -  xpdd->XenBus_WatchEntries[i].Count = 0;
    1.74 -  xpdd->XenBus_WatchEntries[i].Active = 1;
    1.75 -
    1.76    rep = xenbus_msg_reply(Device, XS_WATCH, xbt, req, ARRAY_SIZE(req));
    1.77  
    1.78    msg = errmsg(rep);