All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 000/141] staging: unisys: s-Par driver rebuild series
@ 2015-05-05 22:35 Benjamin Romer
  2015-05-05 22:35 ` [PATCH 001/141] staging: unisys: Move module parameters around and mark static Benjamin Romer
                   ` (143 more replies)
  0 siblings, 144 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Benjamin Romer

This series of patches contains a complete overhaul of the s-Par driver tree,
introducing a new (and significantly improved) driver called visorbus.
This new module consolidates the support code from the many other
modules that existed in our tree, allowing us to remove those, and makes
much better use of built in kernel functionality. The driver tree is
flattened out and large amounts of old code are pruned away, and the ability
to automatically load the driver based on ACPI table data is added.

Benjamin Romer (3):
  staging: unisys: add ACPI and PCI requirement to Kconfig
  staging: unisys: fix visorbus Kconfig
  staging: unisys: remove visorutil from top level Makefile

David Kershner (16):
  staging: unisys: remove server crust from visorchipset.
  staging: unisys: get rid of serialloopbacktest
  staging: unisys: Remove appos_subsystems.h
  staging: unisys: move hypervisor calls into visorbus
  staging: unisys: Move controlframework into controlvmchannel.h
  staging: unisys: Move channel.h to include. Controvlm to visorbus
  staging: unisys: vbuschannel belonsg to visorbus
  staging: unisys: Move diagchannel to include
  staging: unisys: Move files out of common-spar
  staging: unisys: Get rid of references to common-spar
  staging: unisys: get rid of sparstop
  staging: unisys: remove remaining utility headers
  staging: unisys: Update diag serverity enum
  staging: unisys: Remove unneeded fields in diagchannel.h
  staging: unisys: Clean up diag_serverity enum
  staging: unisys: Get rid of unused function

Don Zickus (26):
  staging: unisys: Move visorchannel into visorbus
  staging: unisys: Dissolve visorchannel.h
  staging: unisys: Move visorbus.h to public namespace
  staging: unisys: Remove unused driver
  staging: unisys: Embed struct device for easier handling of attr
  staging: unisys: Wire up proper device attr for bus
  staging: unisys: Move the visorbus device underneath devices
  staging: unisys: remove unused bus attribute code
  staging: unisys: Properly move version file into bus attr
  staging: unisys: Remove dead kobj structs
  staging: unisys: Clean up device sysfs attributes
  staging: unisys: Prep for removing 'info' structs
  staging: unisys: Add visor device find routine
  staging: unisys: Add a function to set the clientpartition
  staging: unisys: Add checks for creation
  staging: unisys: Convert cmd functions to visor_device
  staging: unisys: Convert the epilog functions to visor_device
  staging: unisys: Convert the notifier functions to visor_device
  staging: unisys: Convert the bus/device creation to visor_device
  staging: unisys: Convert the responders to visor_device
  staging: unisys: Convert the device attributes to visor_device
  staging: unisys: Convert init/exit routines to visor_device
  staging: unisys: Remove dead code leftover from conversion
  staging: unisys: Remove unused intr
  staging: unisys: Hide vbus_hdr_info from public visor_device
  staging: unisys: Hide contents of pending_msg_hdr

Erik Arfvidson (21):
  staging: unisys: add visorbus driver
  staging: unisys: remove visorchipset_umode.h
  staging: unisys: moving file.h functionality to visorchipset.h
  staging: unisys: remove file.c and pass functionality to visorchipset
  staging: unisys: move parser.[ch] functionality into visorchipset
  staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64
  staging: unisys: remove unused enum from controlvmchannel.h
  staging: unisys: remove unused #define in controlvmchannel
  staging: unisys: remove unused #define MAX_SERIAL_NUM
  staging: unisys: remove unused CONTROL_VM messages from enum
  staging: unisys: rename variable to reserverd since it is unused
  staging: unisys: controlvmchannel.h comment aligment and cleanup
  staging: unisys: remove unused device_map and guest_devices struct
  staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN
  staging: unisys: remove unused chipset feature PCIVBUS
  staging: unisys: remove unused #define in iochannel.h
  staging: unisys: cleanup and align iochannel.h comments
  staging: unisys: move timskmod.h functionality
  staging: unisys: remove charqueue.c
  staging: unisys: remove timskmod.h and procobjecttree.h
  staging: unisys: move periodic_work.c into the visorbus directory

Jes Sorensen (62):
  staging: unisys: Move module parameters around and mark static
  staging: unisys: Move MYDRVNAME to visorchipset.h
  staging: unisys: Eliminate globals.h
  staging: unisys: Fix up a few cases of bad formatting
  staging: unisys: Remove some unnecessary parenthesis
  staging: unisys: Remove unncessary parenthesis
  staging: unisys: Don't zero struct elements which will be memset away
  staging: unisys: Do not initialize variables unnecessarily
  staging: unisys: Get rid of uint usage
  staging: unisys: Remove unused cache object counter
  staging: unisys: Don't include timskmod.h
  staging: unisys: Remove a couple of unnecessary blank lines
  staging: unisys: buffer_list_pool isn't used for anything
  staging: unisys: Remove write-only visorchipset_bus_info.dev_no
  staging: unisys: findbus() doesn't need to be inline
  staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC
  staging: unisys: finddevice() doesn't need to be inline
  staging: unisys: delbusdevices() doesn't need to be inline
  staging: unisys: Avoid some == 0 checks
  staging: unisys: No point in checking != 0
  staging: unisys: Remove write-only variable g_diag_msg_hdr
  staging: unisys: Remove write-only variable g_del_dump_msg_hdr
  staging: unisys: visorchannel: visorchannel_create_overlap() is never
    used
  staging: unisys: visorbus: visorchannel_create_guts() always has
    parent == NULL
  staging: unisys: memregion: Nothing uses overlap allocations, so nuke
    it
  staging: unisys: memregion: Use proper errno for mapit()
  staging: unisys: memregion: Eliminate unnecessary 'requested' flag
  staging: unisys: visorchipset: parser_init_guts(): Localize memregion
    usage
  staging: unisys: visorchipset: Use ioremap direction rather than heavy
    visor_memregion
  staging: unisys: visorchipset.c: No need to include memregion.h
    anymore
  staging: unisys: visorchannel_clear(): Avoid 64KB memory leak
  staging: unisys: visorchannel_clear(): No need to use vmalloc here
  staging: unisys: decouple visor_memregion_{read, write}()
  staging: unisys: memregion: move struct memregion to memregion.h
  staging: unisys: memregion: Embed memregion in struct channel
  staging: unisys: visorchannel_get_memregion() isn't used
  staging: unisys: Eliminate unused visorchannel_dump_section()
  staging: unisys: Eliminate visor_memregion_create()
  staging: unisys: memregion: Eliminate visor_memregion_destroy()
  staging: unisys: memregion: Eliminate visor_memregion_resize()
  staging: unisys: memregion: Eliminate visor_memregion_get_*()
    functions
  staging: unisys: memregion: {un, }mapit() are no longer used
  staging: unisys: visorchannel_write(): Use memcpy_toio() directly
  staging: unisys: visorchannel_read(): Use memcpy_fromio() directly
  staging: unisys: visorchannel_write(): Handle partial channel_header
    writes
  staging: unisys: visorchannel_create_guts(): Use visorchannel_read()
  staging: unisys: Eliminate visor_memregion_read()
  staging: unisys: Eliminate visor_memregion_write()
  staging: unisys: Finally remove the last remnants of memregion
  staging: unisys: visorchannel: Make visorchannel_create take a gfp_t
  staging: unisys: visorchipset: Declare parser_init_byte_stream()
    static
  staging: unisys: parser: Remove unused functions and mark others
    static
  staging: unisys: parser_init_guts(): standard_payload_header is always
    false
  staging: unisys: Remove wrapper around parser_init_guts()
  staging: unisys: visorchipset: Remove unused cache allocator
  staging: unisys: uislib.h: Remove unused cache allocation prototypes
  staging: unisys: visorchipset_file_{init, cleanup}(): mark static
  staging: unisys: Remove unused visorchipset_save_message()
  staging: unisys: visorchipset_init(): Simplify initial checks
  staging: unisys: Remove unused livedump_info
  staging: unisys: Include missing headers
  staging: unisys: Removed unused entries from struct
    visor_channeltype_descriptor

Prarit Bhargava (13):
  staging: unisys: unify businst attributes into visorbus_main.c
  staging: unisys: unify channel attributes into visorbus_main.c
  staging: unisys: unify devmajorminor attributes into visorbus_main.c
  staging: unisys: rename visorchannel_funcs.c to visorchannel.c
  staging: unisys: remove globals.h
  staging: unisys: remove visorbus_private.h
  staging: unisys: move visorchipset files to visorbus
  staging: unisys: cleanup visorbus_private.h
  staging: unisys: visorchannel cleanup visorchannel_create_guts()
  staging: unisys: visorchannel some general function cleanups
  staging: unisys: fix sig_read_data and sig_read_data functions
  staging: unisys: remove BOOL,TRUE,FALSE definitions
  staging: unisys: add acpi pnp driver

 drivers/staging/unisys/Kconfig                     |    6 +-
 drivers/staging/unisys/Makefile                    |    4 +-
 .../unisys/common-spar/include/channels/channel.h  |  590 -----
 .../common-spar/include/channels/channel_guid.h    |   61 -
 .../include/channels/controlframework.h            |   62 -
 .../include/channels/controlvmchannel.h            |  511 -----
 .../common-spar/include/channels/diagchannel.h     |  427 ----
 .../common-spar/include/channels/iochannel.h       |  784 -------
 .../common-spar/include/channels/vbuschannel.h     |   94 -
 .../include/controlvmcompletionstatus.h            |   94 -
 .../include/diagnostics/appos_subsystems.h         |  310 ---
 .../unisys/common-spar/include/iovmcall_gnuc.h     |   49 -
 .../unisys/common-spar/include/vbusdeviceinfo.h    |  213 --
 .../staging/unisys/common-spar/include/version.h   |   45 -
 .../unisys/common-spar/include/vmcallinterface.h   |  163 --
 drivers/staging/unisys/include/channel.h           |  555 +++++
 drivers/staging/unisys/include/channel_guid.h      |   61 +
 drivers/staging/unisys/include/diagchannel.h       |   43 +
 drivers/staging/unisys/include/guestlinuxdebug.h   |    1 -
 drivers/staging/unisys/include/iochannel.h         |  651 ++++++
 drivers/staging/unisys/include/periodic_work.h     |   10 +-
 drivers/staging/unisys/include/procobjecttree.h    |   47 -
 drivers/staging/unisys/include/sparstop.h          |   30 -
 drivers/staging/unisys/include/timskmod.h          |  153 --
 drivers/staging/unisys/include/uisqueue.h          |  396 ----
 drivers/staging/unisys/include/uisthread.h         |   42 -
 drivers/staging/unisys/include/uisutils.h          |  299 ---
 drivers/staging/unisys/include/vbushelper.h        |    2 -
 drivers/staging/unisys/include/version.h           |   45 +
 drivers/staging/unisys/include/visorbus.h          |  221 ++
 drivers/staging/unisys/visorbus/Kconfig            |    9 +
 drivers/staging/unisys/visorbus/Makefile           |   13 +
 drivers/staging/unisys/visorbus/controlvmchannel.h |  485 ++++
 .../unisys/visorbus/controlvmcompletionstatus.h    |   94 +
 drivers/staging/unisys/visorbus/iovmcall_gnuc.h    |   49 +
 drivers/staging/unisys/visorbus/periodic_work.c    |  205 ++
 drivers/staging/unisys/visorbus/vbuschannel.h      |   94 +
 drivers/staging/unisys/visorbus/vbusdeviceinfo.h   |  213 ++
 drivers/staging/unisys/visorbus/visorbus_main.c    | 1541 +++++++++++++
 drivers/staging/unisys/visorbus/visorbus_private.h |   71 +
 drivers/staging/unisys/visorbus/visorchannel.c     |  587 +++++
 drivers/staging/unisys/visorbus/visorchipset.c     | 2363 ++++++++++++++++++++
 drivers/staging/unisys/visorbus/vmcallinterface.h  |  161 ++
 drivers/staging/unisys/visorchannel/Makefile       |    2 -
 drivers/staging/unisys/visorchannel/globals.h      |    2 -
 drivers/staging/unisys/visorchannel/visorchannel.h |   76 -
 .../unisys/visorchannel/visorchannel_funcs.c       |  663 ------
 drivers/staging/unisys/visorchipset/Kconfig        |   11 -
 drivers/staging/unisys/visorchipset/Makefile       |   15 -
 drivers/staging/unisys/visorchipset/file.c         |  160 --
 drivers/staging/unisys/visorchipset/file.h         |   27 -
 drivers/staging/unisys/visorchipset/globals.h      |   41 -
 drivers/staging/unisys/visorchipset/parser.c       |  430 ----
 drivers/staging/unisys/visorchipset/parser.h       |   46 -
 drivers/staging/unisys/visorchipset/visorchipset.h |  232 --
 .../unisys/visorchipset/visorchipset_main.c        | 2327 -------------------
 .../unisys/visorchipset/visorchipset_umode.h       |   35 -
 drivers/staging/unisys/visorutil/Kconfig           |    9 -
 drivers/staging/unisys/visorutil/Makefile          |    9 -
 drivers/staging/unisys/visorutil/charqueue.c       |  127 --
 drivers/staging/unisys/visorutil/charqueue.h       |   37 -
 drivers/staging/unisys/visorutil/memregion.h       |   43 -
 .../staging/unisys/visorutil/memregion_direct.c    |  207 --
 drivers/staging/unisys/visorutil/periodic_work.c   |  204 --
 drivers/staging/unisys/visorutil/visorkmodutils.c  |   71 -
 65 files changed, 7471 insertions(+), 9157 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/channel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/channel_guid.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/controlframework.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/diagchannel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/iochannel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/version.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/vmcallinterface.h
 create mode 100644 drivers/staging/unisys/include/channel.h
 create mode 100644 drivers/staging/unisys/include/channel_guid.h
 create mode 100644 drivers/staging/unisys/include/diagchannel.h
 create mode 100644 drivers/staging/unisys/include/iochannel.h
 delete mode 100644 drivers/staging/unisys/include/procobjecttree.h
 delete mode 100644 drivers/staging/unisys/include/sparstop.h
 delete mode 100644 drivers/staging/unisys/include/timskmod.h
 delete mode 100644 drivers/staging/unisys/include/uisqueue.h
 delete mode 100644 drivers/staging/unisys/include/uisthread.h
 delete mode 100644 drivers/staging/unisys/include/uisutils.h
 create mode 100644 drivers/staging/unisys/include/version.h
 create mode 100644 drivers/staging/unisys/include/visorbus.h
 create mode 100644 drivers/staging/unisys/visorbus/Kconfig
 create mode 100644 drivers/staging/unisys/visorbus/Makefile
 create mode 100644 drivers/staging/unisys/visorbus/controlvmchannel.h
 create mode 100644 drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
 create mode 100644 drivers/staging/unisys/visorbus/iovmcall_gnuc.h
 create mode 100644 drivers/staging/unisys/visorbus/periodic_work.c
 create mode 100644 drivers/staging/unisys/visorbus/vbuschannel.h
 create mode 100644 drivers/staging/unisys/visorbus/vbusdeviceinfo.h
 create mode 100644 drivers/staging/unisys/visorbus/visorbus_main.c
 create mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h
 create mode 100644 drivers/staging/unisys/visorbus/visorchannel.c
 create mode 100644 drivers/staging/unisys/visorbus/visorchipset.c
 create mode 100644 drivers/staging/unisys/visorbus/vmcallinterface.h
 delete mode 100644 drivers/staging/unisys/visorchannel/visorchannel.h
 delete mode 100644 drivers/staging/unisys/visorchannel/visorchannel_funcs.c
 delete mode 100644 drivers/staging/unisys/visorchipset/Kconfig
 delete mode 100644 drivers/staging/unisys/visorchipset/Makefile
 delete mode 100644 drivers/staging/unisys/visorchipset/file.c
 delete mode 100644 drivers/staging/unisys/visorchipset/file.h
 delete mode 100644 drivers/staging/unisys/visorchipset/globals.h
 delete mode 100644 drivers/staging/unisys/visorchipset/parser.c
 delete mode 100644 drivers/staging/unisys/visorchipset/parser.h
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset.h
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset_main.c
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset_umode.h
 delete mode 100644 drivers/staging/unisys/visorutil/Kconfig
 delete mode 100644 drivers/staging/unisys/visorutil/Makefile
 delete mode 100644 drivers/staging/unisys/visorutil/charqueue.c
 delete mode 100644 drivers/staging/unisys/visorutil/charqueue.h
 delete mode 100644 drivers/staging/unisys/visorutil/memregion.h
 delete mode 100644 drivers/staging/unisys/visorutil/memregion_direct.c
 delete mode 100644 drivers/staging/unisys/visorutil/periodic_work.c
 delete mode 100644 drivers/staging/unisys/visorutil/visorkmodutils.c

-- 
2.1.4

^ permalink raw reply	[flat|nested] 173+ messages in thread

* [PATCH 001/141] staging: unisys: Move module parameters around and mark static
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 002/141] staging: unisys: Move MYDRVNAME to visorchipset.h Benjamin Romer
                   ` (142 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Move the module parameters and make sure they are static.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Tested-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/globals.h      | 10 -------
 .../unisys/visorchipset/visorchipset_main.c        | 31 +++++++++++-----------
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h
index 36b21ec..0884a68 100644
--- a/drivers/staging/unisys/visorchipset/globals.h
+++ b/drivers/staging/unisys/visorchipset/globals.h
@@ -28,14 +28,4 @@
 
 /* module parameters */
 
-extern int visorchipset_testvnic;
-extern int visorchipset_testvnicclient;
-extern int visorchipset_testmsg;
-extern int visorchipset_major;
-extern int visorchipset_serverregwait;
-extern int visorchipset_clientregwait;
-extern int visorchipset_testteardown;
-extern int visorchipset_disable_controlvm;
-extern int visorchipset_holdchipsetready;
-
 #endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 90e41cb..7720d2c 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -44,6 +44,19 @@
 #define POLLJIFFIES_CONTROLVMCHANNEL_FAST   1
 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
 
+/*
+ * Module parameters
+ */
+static int visorchipset_testvnic;
+static int visorchipset_testvnicclient;
+static int visorchipset_testmsg;
+static int visorchipset_major;
+static int visorchipset_serverregwait;
+static int visorchipset_clientregwait = 1;	/* default is on */
+static int visorchipset_testteardown;
+static int visorchipset_disable_controlvm;
+static int visorchipset_holdchipsetready;
+
 /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
 * we switch to slow polling mode.  As soon as we get a controlvm
 * message, we switch back to fast polling mode.
@@ -2280,43 +2293,31 @@ visorchipset_exit(void)
 
 module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
-int visorchipset_testvnic = 0;
-
 module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
-int visorchipset_testvnicclient = 0;
-
 module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_testmsg,
 		 "1 to manufacture the chipset, bus, and switch messages");
-int visorchipset_testmsg = 0;
-
 module_param_named(major, visorchipset_major, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node");
-int visorchipset_major = 0;
-
+MODULE_PARM_DESC(visorchipset_major,
+		 "major device number to use for the device node");
 module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_serverreqwait,
 		 "1 to have the module wait for the visor bus to register");
-int visorchipset_serverregwait = 0;	/* default is off */
 module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
-int visorchipset_clientregwait = 1;	/* default is on */
 module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_testteardown,
 		 "1 to test teardown of the chipset, bus, and switch");
-int visorchipset_testteardown = 0;	/* default is off */
 module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
 		   S_IRUGO);
 MODULE_PARM_DESC(visorchipset_disable_controlvm,
 		 "1 to disable polling of controlVm channel");
-int visorchipset_disable_controlvm = 0;	/* default is off */
 module_param_named(holdchipsetready, visorchipset_holdchipsetready,
 		   int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_holdchipsetready,
 		 "1 to hold response to CHIPSET_READY");
-int visorchipset_holdchipsetready = 0; /* default is to send CHIPSET_READY
-				      * response immediately */
+
 module_init(visorchipset_init);
 module_exit(visorchipset_exit);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 002/141] staging: unisys: Move MYDRVNAME to visorchipset.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
  2015-05-05 22:35 ` [PATCH 001/141] staging: unisys: Move module parameters around and mark static Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 003/141] staging: unisys: Eliminate globals.h Benjamin Romer
                   ` (141 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/globals.h      | 2 --
 drivers/staging/unisys/visorchipset/visorchipset.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h
index 0884a68..ee7e3b4 100644
--- a/drivers/staging/unisys/visorchipset/globals.h
+++ b/drivers/staging/unisys/visorchipset/globals.h
@@ -24,8 +24,6 @@
 #include "visorchipset_umode.h"
 #include "version.h"
 
-#define MYDRVNAME "visorchipset"
-
 /* module parameters */
 
 #endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 87b63f0..2c2d3fb 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -28,6 +28,8 @@
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
+#define MYDRVNAME "visorchipset"
+
 /** Describes the state from the perspective of which controlvm messages have
  *  been received for a bus or device.
  */
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 003/141] staging: unisys: Eliminate globals.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
  2015-05-05 22:35 ` [PATCH 001/141] staging: unisys: Move module parameters around and mark static Benjamin Romer
  2015-05-05 22:35 ` [PATCH 002/141] staging: unisys: Move MYDRVNAME to visorchipset.h Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 004/141] staging: unisys: Fix up a few cases of bad formatting Benjamin Romer
                   ` (140 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/file.c         |  6 +++--
 drivers/staging/unisys/visorchipset/file.h         |  2 --
 drivers/staging/unisys/visorchipset/globals.h      | 29 ----------------------
 .../unisys/visorchipset/visorchipset_main.c        |  2 +-
 4 files changed, 5 insertions(+), 34 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorchipset/globals.h

diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index 6fc5689..7d8247a 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -19,10 +19,12 @@
  * communicate with the visorchipset driver using a device/file interface.
  */
 
-#include "globals.h"
-#include "visorchannel.h"
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include "version.h"
+#include "visorchipset.h"
+#include "visorchipset_umode.h"
+#include "visorchannel.h"
 #include "uisutils.h"
 #include "file.h"
 
diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h
index 51f7699..6ff28a1 100644
--- a/drivers/staging/unisys/visorchipset/file.h
+++ b/drivers/staging/unisys/visorchipset/file.h
@@ -18,8 +18,6 @@
 #ifndef __FILE_H__
 #define __FILE_H__
 
-#include "globals.h"
-
 int visorchipset_file_init(dev_t majorDev,
 			   struct visorchannel **pControlVm_channel);
 void visorchipset_file_cleanup(dev_t major_dev);
diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h
deleted file mode 100644
index ee7e3b4..0000000
--- a/drivers/staging/unisys/visorchipset/globals.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* globals.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHIPSET_GLOBALS_H__
-#define __VISORCHIPSET_GLOBALS_H__
-
-#include "diagnostics/appos_subsystems.h"
-#include "timskmod.h"
-#include "visorchipset.h"
-#include "visorchipset_umode.h"
-#include "version.h"
-
-/* module parameters */
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 7720d2c..767c495 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -15,7 +15,7 @@
  * details.
  */
 
-#include "globals.h"
+#include "version.h"
 #include "visorchipset.h"
 #include "procobjecttree.h"
 #include "visorchannel.h"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 004/141] staging: unisys: Fix up a few cases of bad formatting
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (2 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 003/141] staging: unisys: Eliminate globals.h Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 005/141] staging: unisys: Remove some unnecessary parenthesis Benjamin Romer
                   ` (139 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index 7d8247a..e63ef2a 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -99,7 +99,7 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
 }
 
 static long visorchipset_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
+			       unsigned long arg)
 {
 	s64 adjustment;
 	s64 vrtc_offset;
@@ -108,14 +108,14 @@ static long visorchipset_ioctl(struct file *file, unsigned int cmd,
 	case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
 		/* get the physical rtc offset */
 		vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
-		if (copy_to_user
-		    ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) {
+		if (copy_to_user((void __user *)arg, &vrtc_offset,
+				 sizeof(vrtc_offset))) {
 			return -EFAULT;
 		}
 		return SUCCESS;
 	case VMCALL_UPDATE_PHYSICAL_TIME:
-		if (copy_from_user
-		    (&adjustment, (void __user *)arg, sizeof(adjustment))) {
+		if (copy_from_user(&adjustment, (void __user *)arg,
+				   sizeof(adjustment))) {
 			return -EFAULT;
 		}
 		return issue_vmcall_update_physical_time(adjustment);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 005/141] staging: unisys: Remove some unnecessary parenthesis
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (3 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 004/141] staging: unisys: Fix up a few cases of bad formatting Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 006/141] staging: unisys: Remove unncessary parenthesis Benjamin Romer
                   ` (138 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_umode.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h
index 6cf6eccb..8af5bf3 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset_umode.h
@@ -29,7 +29,7 @@
 /** The user-mode program can access the control channel buffer directly
  *  via this memory map.
  */
-#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET    (0x00000000)
-#define VISORCHIPSET_MMAP_CONTROLCHANSIZE      (0x00400000)  /* 4MB */
+#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
+#define VISORCHIPSET_MMAP_CONTROLCHANSIZE	0x00400000	/* 4MB */
 
 #endif /* __VISORCHIPSET_UMODE_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 006/141] staging: unisys: Remove unncessary parenthesis
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (4 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 005/141] staging: unisys: Remove some unnecessary parenthesis Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 007/141] staging: unisys: Don't zero struct elements which will be memset away Benjamin Romer
                   ` (137 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 767c495..b4e28d2 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -519,7 +519,7 @@ static ssize_t remaining_steps_store(struct device *dev,
 static void
 bus_info_clear(void *v)
 {
-	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v);
+	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
 
 	kfree(p->name);
 	p->name = NULL;
@@ -535,7 +535,7 @@ static void
 dev_info_clear(void *v)
 {
 	struct visorchipset_device_info *p =
-			(struct visorchipset_device_info *)(v);
+		(struct visorchipset_device_info *) v;
 
 	p->state.created = 0;
 	memset(p, 0, sizeof(struct visorchipset_device_info));
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 007/141] staging: unisys: Don't zero struct elements which will be memset away
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (5 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 006/141] staging: unisys: Remove unncessary parenthesis Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 008/141] staging: unisys: Do not initialize variables unnecessarily Benjamin Romer
                   ` (136 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index b4e28d2..90018ac 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -522,12 +522,7 @@ bus_info_clear(void *v)
 	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
 
 	kfree(p->name);
-	p->name = NULL;
-
 	kfree(p->description);
-	p->description = NULL;
-
-	p->state.created = 0;
 	memset(p, 0, sizeof(struct visorchipset_bus_info));
 }
 
@@ -537,7 +532,6 @@ dev_info_clear(void *v)
 	struct visorchipset_device_info *p =
 		(struct visorchipset_device_info *) v;
 
-	p->state.created = 0;
 	memset(p, 0, sizeof(struct visorchipset_device_info));
 }
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 008/141] staging: unisys: Do not initialize variables unnecessarily
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (6 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 007/141] staging: unisys: Don't zero struct elements which will be memset away Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 009/141] staging: unisys: Get rid of uint usage Benjamin Romer
                   ` (135 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../unisys/visorchipset/visorchipset_main.c        | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 90018ac..0d3abce 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -782,7 +782,7 @@ EXPORT_SYMBOL_GPL(visorchipset_save_message);
 static void
 bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 {
-	struct visorchipset_bus_info *p = NULL;
+	struct visorchipset_bus_info *p;
 	bool need_clear = false;
 
 	p = findbus(&bus_info_list, bus_no);
@@ -818,7 +818,7 @@ device_changestate_responder(enum controlvm_id cmd_id,
 			     u32 bus_no, u32 dev_no, int response,
 			     struct spar_segment_state response_state)
 {
-	struct visorchipset_device_info *p = NULL;
+	struct visorchipset_device_info *p;
 	struct controlvm_message outmsg;
 
 	p = finddevice(&dev_info_list, bus_no, dev_no);
@@ -845,7 +845,7 @@ device_changestate_responder(enum controlvm_id cmd_id,
 static void
 device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 {
-	struct visorchipset_device_info *p = NULL;
+	struct visorchipset_device_info *p;
 	bool need_clear = false;
 
 	p = finddevice(&dev_info_list, bus_no, dev_no);
@@ -943,7 +943,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 	      struct controlvm_message_header *msg_hdr, int response,
 	      bool need_response, bool for_visorbus)
 {
-	struct visorchipset_busdev_notifiers *notifiers = NULL;
+	struct visorchipset_busdev_notifiers *notifiers;
 	bool notified = false;
 
 	struct visorchipset_device_info *dev_info =
@@ -1041,7 +1041,7 @@ bus_create(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->create_bus.bus_no;
 	int rc = CONTROLVM_RESP_SUCCESS;
-	struct visorchipset_bus_info *bus_info = NULL;
+	struct visorchipset_bus_info *bus_info;
 
 	bus_info = findbus(&bus_info_list, bus_no);
 	if (bus_info && (bus_info->state.created == 1)) {
@@ -1108,8 +1108,8 @@ bus_configure(struct controlvm_message *inmsg,
 	      struct parser_context *parser_ctx)
 {
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->configure_bus.bus_no;
-	struct visorchipset_bus_info *bus_info = NULL;
+	u32 bus_no;
+	struct visorchipset_bus_info *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 	char s[99];
 
@@ -1150,8 +1150,8 @@ my_device_create(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->create_device.bus_no;
 	u32 dev_no = cmd->create_device.dev_no;
-	struct visorchipset_device_info *dev_info = NULL;
-	struct visorchipset_bus_info *bus_info = NULL;
+	struct visorchipset_device_info *dev_info;
+	struct visorchipset_bus_info *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
 	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
@@ -1221,7 +1221,7 @@ my_device_changestate(struct controlvm_message *inmsg)
 	u32 bus_no = cmd->device_change_state.bus_no;
 	u32 dev_no = cmd->device_change_state.dev_no;
 	struct spar_segment_state state = cmd->device_change_state.state;
-	struct visorchipset_device_info *dev_info = NULL;
+	struct visorchipset_device_info *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
 	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
@@ -1248,7 +1248,7 @@ my_device_destroy(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->destroy_device.bus_no;
 	u32 dev_no = cmd->destroy_device.dev_no;
-	struct visorchipset_device_info *dev_info = NULL;
+	struct visorchipset_device_info *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
 	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
@@ -1538,8 +1538,8 @@ parahotplug_request_kickoff(struct parahotplug_request *req)
 static void
 parahotplug_process_list(void)
 {
-	struct list_head *pos = NULL;
-	struct list_head *tmp = NULL;
+	struct list_head *pos;
+	struct list_head *tmp;
 
 	spin_lock(&parahotplug_request_list_lock);
 
@@ -1570,8 +1570,8 @@ parahotplug_process_list(void)
 static int
 parahotplug_request_complete(int id, u16 active)
 {
-	struct list_head *pos = NULL;
-	struct list_head *tmp = NULL;
+	struct list_head *pos;
+	struct list_head *tmp;
 
 	spin_lock(&parahotplug_request_list_lock);
 
@@ -1656,10 +1656,10 @@ static bool
 handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
 {
 	struct controlvm_message_packet *cmd = &inmsg.cmd;
-	u64 parm_addr = 0;
-	u32 parm_bytes = 0;
+	u64 parm_addr;
+	u32 parm_bytes;
 	struct parser_context *parser_ctx = NULL;
-	bool local_addr = false;
+	bool local_addr;
 	struct controlvm_message ackmsg;
 
 	/* create parsing context if necessary */
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 009/141] staging: unisys: Get rid of uint usage
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (7 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 008/141] staging: unisys: Do not initialize variables unnecessarily Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 010/141] staging: unisys: Remove unused cache object counter Benjamin Romer
                   ` (134 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 0d3abce..9b6c768 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -2120,7 +2120,7 @@ static ssize_t devicedisabled_store(struct device *dev,
 				    struct device_attribute *attr,
 				    const char *buf, size_t count)
 {
-	uint id;
+	unsigned int id;
 
 	if (kstrtouint(buf, 10, &id) != 0)
 		return -EINVAL;
@@ -2137,7 +2137,7 @@ static ssize_t deviceenabled_store(struct device *dev,
 				   struct device_attribute *attr,
 				   const char *buf, size_t count)
 {
-	uint id;
+	unsigned int id;
 
 	if (kstrtouint(buf, 10, &id) != 0)
 		return -EINVAL;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 010/141] staging: unisys: Remove unused cache object counter
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (8 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 009/141] staging: unisys: Get rid of uint usage Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 011/141] staging: unisys: Don't include timskmod.h Benjamin Romer
                   ` (133 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

kmem_cache statistics are available through SLAB anyway

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 9b6c768..e33d886 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -213,8 +213,6 @@ struct putfile_request {
 	int completion_status;
 };
 
-static atomic_t visorchipset_cache_buffers_in_use = ATOMIC_INIT(0);
-
 struct parahotplug_request {
 	struct list_head list;
 	int id;
@@ -2077,7 +2075,6 @@ visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block,
 	if (!p)
 		return NULL;
 
-	atomic_inc(&visorchipset_cache_buffers_in_use);
 	return p;
 }
 
@@ -2089,7 +2086,6 @@ visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
 	if (!p)
 		return;
 
-	atomic_dec(&visorchipset_cache_buffers_in_use);
 	kmem_cache_free(pool, p);
 }
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 011/141] staging: unisys: Don't include timskmod.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (9 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 010/141] staging: unisys: Remove unused cache object counter Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 012/141] staging: unisys: Remove a couple of unnecessary blank lines Benjamin Romer
                   ` (132 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/parser.h       | 1 -
 drivers/staging/unisys/visorchipset/visorchipset.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h
index 73be279..3fe17c0 100644
--- a/drivers/staging/unisys/visorchipset/parser.h
+++ b/drivers/staging/unisys/visorchipset/parser.h
@@ -20,7 +20,6 @@
 
 #include <linux/uuid.h>
 
-#include "timskmod.h"
 #include "channel.h"
 
 typedef enum {
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 2c2d3fb..3c57782 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -20,7 +20,6 @@
 
 #include <linux/uuid.h>
 
-#include "timskmod.h"
 #include "channel.h"
 #include "controlvmchannel.h"
 #include "parser.h"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 012/141] staging: unisys: Remove a couple of unnecessary blank lines
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (10 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 011/141] staging: unisys: Don't include timskmod.h Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 013/141] staging: unisys: buffer_list_pool isn't used for anything Benjamin Romer
                   ` (131 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 3c57782..53bbc49 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -68,7 +68,6 @@ struct visorchipset_channel_info {
 	u64 n_channel_bytes;
 	uuid_le channel_type_uuid;
 	uuid_le channel_inst_uuid;
-
 };
 
 /** Attributes for a particular Supervisor device.
@@ -90,7 +89,6 @@ struct visorchipset_device_info {
 	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
 	/** For private use by the bus driver */
 	void *bus_driver_context;
-
 };
 
 static inline struct visorchipset_device_info *finddevice(
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 013/141] staging: unisys: buffer_list_pool isn't used for anything
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (11 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 012/141] staging: unisys: Remove a couple of unnecessary blank lines Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 014/141] staging: unisys: Remove write-only visorchipset_bus_info.dev_no Benjamin Romer
                   ` (130 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/visorchipset/visorchipset_main.c  | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index e33d886..69730d1 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -138,13 +138,6 @@ static struct visor_livedump_info livedump_info;
 static struct controlvm_message controlvm_pending_msg;
 static bool controlvm_pending_msg_valid = false;
 
-/* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
- * TRANSMIT_FILE PutFile payloads.
- */
-static struct kmem_cache *putfile_buffer_list_pool;
-static const char putfile_buffer_list_pool_name[] =
-	"controlvm_putfile_buffer_list_pool";
-
 /* This identifies a data buffer that has been received via a controlvm messages
  * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
  */
@@ -2195,15 +2188,6 @@ visorchipset_init(void)
 
 	memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-	putfile_buffer_list_pool =
-	    kmem_cache_create(putfile_buffer_list_pool_name,
-			      sizeof(struct putfile_buffer_entry),
-			      0, SLAB_HWCACHE_ALIGN, NULL);
-	if (!putfile_buffer_list_pool) {
-		POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
-		rc = -1;
-		goto cleanup;
-	}
 	if (!visorchipset_disable_controlvm) {
 		/* if booting in a crash kernel */
 		if (is_kdump_kernel())
@@ -2262,10 +2246,6 @@ visorchipset_exit(void)
 		periodic_controlvm_workqueue = NULL;
 		destroy_controlvm_payload_info(&controlvm_payload_info);
 	}
-	if (putfile_buffer_list_pool) {
-		kmem_cache_destroy(putfile_buffer_list_pool);
-		putfile_buffer_list_pool = NULL;
-	}
 
 	cleanup_controlvm_structures();
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 014/141] staging: unisys: Remove write-only visorchipset_bus_info.dev_no
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (12 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 013/141] staging: unisys: buffer_list_pool isn't used for anything Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 015/141] staging: unisys: findbus() doesn't need to be inline Benjamin Romer
                   ` (129 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h      | 1 -
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 53bbc49..d21fcb0 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -140,7 +140,6 @@ struct visorchipset_bus_info {
 	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
 	/** For private use by the bus driver */
 	void *bus_driver_context;
-	u32 dev_no;
 };
 
 static inline struct visorchipset_bus_info *
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 69730d1..e78ae7b 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -1051,7 +1051,6 @@ bus_create(struct controlvm_message *inmsg)
 
 	INIT_LIST_HEAD(&bus_info->entry);
 	bus_info->bus_no = bus_no;
-	bus_info->dev_no = cmd->create_bus.dev_count;
 
 	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 015/141] staging: unisys: findbus() doesn't need to be inline
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (13 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 014/141] staging: unisys: Remove write-only visorchipset_bus_info.dev_no Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 016/141] staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC Benjamin Romer
                   ` (128 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h | 12 ---------
 .../unisys/visorchipset/visorchipset_main.c        | 31 +++++++++++++++-------
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index d21fcb0..70b9e6e 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -142,18 +142,6 @@ struct visorchipset_bus_info {
 	void *bus_driver_context;
 };
 
-static inline struct visorchipset_bus_info *
-findbus(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_bus_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no)
-			return p;
-	}
-	return NULL;
-}
-
 /*  These functions will be called from within visorchipset when certain
  *  events happen.  (The implementation of these functions is outside of
  *  visorchipset.)
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index e78ae7b..f647567 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -526,6 +526,19 @@ dev_info_clear(void *v)
 	memset(p, 0, sizeof(struct visorchipset_device_info));
 }
 
+static struct visorchipset_bus_info *
+bus_find(struct list_head *list, u32 bus_no)
+{
+	struct visorchipset_bus_info *p;
+
+	list_for_each_entry(p, list, entry) {
+		if (p->bus_no == bus_no)
+			return p;
+	}
+
+	return NULL;
+}
+
 static u8
 check_chipset_events(void)
 {
@@ -776,7 +789,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 	struct visorchipset_bus_info *p;
 	bool need_clear = false;
 
-	p = findbus(&bus_info_list, bus_no);
+	p = bus_find(&bus_info_list, bus_no);
 	if (!p)
 		return;
 
@@ -866,10 +879,10 @@ bus_epilog(u32 bus_no,
 	   u32 cmd, struct controlvm_message_header *msg_hdr,
 	   int response, bool need_response)
 {
+	struct visorchipset_bus_info *bus_info;
 	bool notified = false;
 
-	struct visorchipset_bus_info *bus_info = findbus(&bus_info_list,
-							 bus_no);
+	bus_info = bus_find(&bus_info_list, bus_no);
 
 	if (!bus_info)
 		return;
@@ -1034,7 +1047,7 @@ bus_create(struct controlvm_message *inmsg)
 	int rc = CONTROLVM_RESP_SUCCESS;
 	struct visorchipset_bus_info *bus_info;
 
-	bus_info = findbus(&bus_info_list, bus_no);
+	bus_info = bus_find(&bus_info_list, bus_no);
 	if (bus_info && (bus_info->state.created == 1)) {
 		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1083,7 +1096,7 @@ bus_destroy(struct controlvm_message *inmsg)
 	struct visorchipset_bus_info *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	bus_info = findbus(&bus_info_list, bus_no);
+	bus_info = bus_find(&bus_info_list, bus_no);
 	if (!bus_info)
 		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 	else if (bus_info->state.created == 0)
@@ -1107,7 +1120,7 @@ bus_configure(struct controlvm_message *inmsg,
 	POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	bus_info = findbus(&bus_info_list, bus_no);
+	bus_info = bus_find(&bus_info_list, bus_no);
 	if (!bus_info) {
 		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1151,7 +1164,7 @@ my_device_create(struct controlvm_message *inmsg)
 		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 		goto cleanup;
 	}
-	bus_info = findbus(&bus_info_list, bus_no);
+	bus_info = bus_find(&bus_info_list, bus_no);
 	if (!bus_info) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1995,7 +2008,7 @@ device_resume_response(u32 bus_no, u32 dev_no, int response)
 bool
 visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
 {
-	void *p = findbus(&bus_info_list, bus_no);
+	void *p = bus_find(&bus_info_list, bus_no);
 
 	if (!p)
 		return false;
@@ -2007,7 +2020,7 @@ EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
 bool
 visorchipset_set_bus_context(u32 bus_no, void *context)
 {
-	struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no);
+	struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
 
 	if (!p)
 		return false;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 016/141] staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (14 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 015/141] staging: unisys: findbus() doesn't need to be inline Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 017/141] staging: unisys: finddevice() doesn't need to be inline Benjamin Romer
                   ` (127 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 70b9e6e..59552af 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -194,9 +194,6 @@ visorchipset_register_busdev_server(
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info);
 
-typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg,
-					       int status);
-
 void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response);
 
 bool visorchipset_get_bus_info(u32 bus_no,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 017/141] staging: unisys: finddevice() doesn't need to be inline
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (15 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 016/141] staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 018/141] staging: unisys: delbusdevices() " Benjamin Romer
                   ` (126 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h | 12 --------
 .../unisys/visorchipset/visorchipset_main.c        | 32 ++++++++++++++++------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 59552af..a3fe8b7 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -91,18 +91,6 @@ struct visorchipset_device_info {
 	void *bus_driver_context;
 };
 
-static inline struct visorchipset_device_info *finddevice(
-		struct list_head *list, u32 bus_no, u32 dev_no)
-{
-	struct visorchipset_device_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no && p->dev_no == dev_no)
-			return p;
-	}
-	return NULL;
-}
-
 static inline void delbusdevices(struct list_head *list, u32 bus_no)
 {
 	struct visorchipset_device_info *p, *tmp;
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index f647567..d1f0d18 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -539,6 +539,19 @@ bus_find(struct list_head *list, u32 bus_no)
 	return NULL;
 }
 
+static struct visorchipset_device_info *
+device_find(struct list_head *list, u32 bus_no, u32 dev_no)
+{
+	struct visorchipset_device_info *p;
+
+	list_for_each_entry(p, list, entry) {
+		if (p->bus_no == bus_no && p->dev_no == dev_no)
+			return p;
+	}
+
+	return NULL;
+}
+
 static u8
 check_chipset_events(void)
 {
@@ -825,7 +838,7 @@ device_changestate_responder(enum controlvm_id cmd_id,
 	struct visorchipset_device_info *p;
 	struct controlvm_message outmsg;
 
-	p = finddevice(&dev_info_list, bus_no, dev_no);
+	p = device_find(&dev_info_list, bus_no, dev_no);
 	if (!p)
 		return;
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
@@ -852,7 +865,7 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 	struct visorchipset_device_info *p;
 	bool need_clear = false;
 
-	p = finddevice(&dev_info_list, bus_no, dev_no);
+	p = device_find(&dev_info_list, bus_no, dev_no);
 	if (!p)
 		return;
 	if (response >= 0) {
@@ -951,7 +964,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 	bool notified = false;
 
 	struct visorchipset_device_info *dev_info =
-		finddevice(&dev_info_list, bus_no, dev_no);
+		device_find(&dev_info_list, bus_no, dev_no);
 	char *envp[] = {
 		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
 		NULL
@@ -1157,7 +1170,7 @@ my_device_create(struct controlvm_message *inmsg)
 	struct visorchipset_bus_info *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
 	if (dev_info && (dev_info->state.created == 1)) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1227,7 +1240,7 @@ my_device_changestate(struct controlvm_message *inmsg)
 	struct visorchipset_device_info *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
 	if (!dev_info) {
 		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1254,7 +1267,7 @@ my_device_destroy(struct controlvm_message *inmsg)
 	struct visorchipset_device_info *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
 	if (!dev_info)
 		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
 	else if (dev_info->state.created == 0)
@@ -2033,7 +2046,7 @@ bool
 visorchipset_get_device_info(u32 bus_no, u32 dev_no,
 			     struct visorchipset_device_info *dev_info)
 {
-	void *p = finddevice(&dev_info_list, bus_no, dev_no);
+	void *p = device_find(&dev_info_list, bus_no, dev_no);
 
 	if (!p)
 		return false;
@@ -2045,8 +2058,9 @@ EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
 bool
 visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
 {
-	struct visorchipset_device_info *p =
-			finddevice(&dev_info_list, bus_no, dev_no);
+	struct visorchipset_device_info *p;
+
+	p = device_find(&dev_info_list, bus_no, dev_no);
 
 	if (!p)
 		return false;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 018/141] staging: unisys: delbusdevices() doesn't need to be inline
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (16 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 017/141] staging: unisys: finddevice() doesn't need to be inline Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 019/141] staging: unisys: Avoid some == 0 checks Benjamin Romer
                   ` (125 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset.h      | 12 ------------
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 16 ++++++++++++++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index a3fe8b7..1d66c37 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -91,18 +91,6 @@ struct visorchipset_device_info {
 	void *bus_driver_context;
 };
 
-static inline void delbusdevices(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_device_info *p, *tmp;
-
-	list_for_each_entry_safe(p, tmp, list, entry) {
-		if (p->bus_no == bus_no) {
-			list_del(&p->entry);
-			kfree(p);
-		}
-	}
-}
-
 /** Attributes for a particular Supervisor bus.
  *  (For a service partition acting as the server for buses/devices, there
  *  is a 1-to-1 relationship between busses and guest partitions.)
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index d1f0d18..9f5c539 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -552,6 +552,18 @@ device_find(struct list_head *list, u32 bus_no, u32 dev_no)
 	return NULL;
 }
 
+static void busdevices_del(struct list_head *list, u32 bus_no)
+{
+	struct visorchipset_device_info *p, *tmp;
+
+	list_for_each_entry_safe(p, tmp, list, entry) {
+		if (p->bus_no == bus_no) {
+			list_del(&p->entry);
+			kfree(p);
+		}
+	}
+}
+
 static u8
 check_chipset_events(void)
 {
@@ -810,7 +822,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 		if ((cmd_id == CONTROLVM_BUS_CREATE) &&
 		    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
 			/* undo the row we just created... */
-			delbusdevices(&dev_info_list, bus_no);
+			busdevices_del(&dev_info_list, bus_no);
 	} else {
 		if (cmd_id == CONTROLVM_BUS_CREATE)
 			p->state.created = 1;
@@ -826,7 +838,7 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 	p->pending_msg_hdr.id = CONTROLVM_INVALID;
 	if (need_clear) {
 		bus_info_clear(p);
-		delbusdevices(&dev_info_list, bus_no);
+		busdevices_del(&dev_info_list, bus_no);
 	}
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 019/141] staging: unisys: Avoid some == 0 checks
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (17 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 018/141] staging: unisys: delbusdevices() " Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 020/141] staging: unisys: No point in checking != 0 Benjamin Romer
                   ` (124 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/file.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index e63ef2a..a17027c 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -36,7 +36,7 @@ static struct visorchannel **file_controlvm_channel;
 void
 visorchipset_file_cleanup(dev_t major_dev)
 {
-	if (file_cdev.ops != NULL)
+	if (file_cdev.ops)
 		cdev_del(&file_cdev);
 	file_cdev.ops = NULL;
 	unregister_chrdev_region(major_dev, 1);
@@ -47,7 +47,7 @@ visorchipset_open(struct inode *inode, struct file *file)
 {
 	unsigned minor_number = iminor(inode);
 
-	if (minor_number != 0)
+	if (minor_number)
 		return -ENODEV;
 	file->private_data = NULL;
 	return 0;
@@ -73,16 +73,16 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
 	switch (offset) {
 	case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
 		vma->vm_flags |= VM_IO;
-		if (*file_controlvm_channel == NULL) {
+		if (!*file_controlvm_channel)
 			return -ENXIO;
-		}
+
 		visorchannel_read(*file_controlvm_channel,
 			offsetof(struct spar_controlvm_channel_protocol,
 				 gp_control_channel),
 			&addr, sizeof(addr));
-		if (addr == 0) {
+		if (!addr)
 			return -ENXIO;
-		}
+
 		physaddr = (unsigned long)addr;
 		if (remap_pfn_range(vma, vma->vm_start,
 				    physaddr >> PAGE_SHIFT,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 020/141] staging: unisys: No point in checking != 0
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (18 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 019/141] staging: unisys: Avoid some == 0 checks Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 021/141] staging: unisys: Remove write-only variable g_diag_msg_hdr Benjamin Romer
                   ` (123 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../unisys/visorchipset/visorchipset_main.c        | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 9f5c539..3b5f3d6 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -368,7 +368,7 @@ static ssize_t toolaction_store(struct device *dev,
 	u8 tool_action;
 	int ret;
 
-	if (kstrtou8(buf, 10, &tool_action) != 0)
+	if (kstrtou8(buf, 10, &tool_action))
 		return -EINVAL;
 
 	ret = visorchannel_write(controlvm_channel,
@@ -402,7 +402,7 @@ static ssize_t boottotool_store(struct device *dev,
 	int val, ret;
 	struct efi_spar_indication efi_spar_indication;
 
-	if (kstrtoint(buf, 10, &val) != 0)
+	if (kstrtoint(buf, 10, &val))
 		return -EINVAL;
 
 	efi_spar_indication.boot_to_tool = val;
@@ -434,7 +434,7 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
 	u32 error;
 	int ret;
 
-	if (kstrtou32(buf, 10, &error) != 0)
+	if (kstrtou32(buf, 10, &error))
 		return -EINVAL;
 
 	ret = visorchannel_write(controlvm_channel,
@@ -464,7 +464,7 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
 	u32 text_id;
 	int ret;
 
-	if (kstrtou32(buf, 10, &text_id) != 0)
+	if (kstrtou32(buf, 10, &text_id))
 		return -EINVAL;
 
 	ret = visorchannel_write(controlvm_channel,
@@ -495,7 +495,7 @@ static ssize_t remaining_steps_store(struct device *dev,
 	u16 remaining_steps;
 	int ret;
 
-	if (kstrtou16(buf, 10, &remaining_steps) != 0)
+	if (kstrtou16(buf, 10, &remaining_steps))
 		return -EINVAL;
 
 	ret = visorchannel_write(controlvm_channel,
@@ -1701,7 +1701,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
 	 * within our OS-controlled memory.  We need to know that, because it
 	 * makes a difference in how we compute the virtual address.
 	 */
-	if (parm_addr != 0 && parm_bytes != 0) {
+	if (parm_addr && parm_bytes) {
 		bool retry = false;
 
 		parser_ctx =
@@ -1962,7 +1962,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
 	}
 
 	/* reuse IOVM create bus message */
-	if (local_crash_bus_msg.cmd.create_bus.channel_addr != 0) {
+	if (local_crash_bus_msg.cmd.create_bus.channel_addr) {
 		bus_create(&local_crash_bus_msg);
 	} else {
 		POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
@@ -1971,7 +1971,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
 	}
 
 	/* reuse create device message for storage device */
-	if (local_crash_dev_msg.cmd.create_device.channel_addr != 0) {
+	if (local_crash_dev_msg.cmd.create_device.channel_addr) {
 		my_device_create(&local_crash_dev_msg);
 	} else {
 		POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
@@ -2129,10 +2129,10 @@ static ssize_t chipsetready_store(struct device *dev,
 	if (sscanf(buf, "%63s", msgtype) != 1)
 		return -EINVAL;
 
-	if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0) {
+	if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) {
 		chipset_events[0] = 1;
 		return count;
-	} else if (strcmp(msgtype, "MODULES_LOADED") == 0) {
+	} else if (!strcmp(msgtype, "MODULES_LOADED")) {
 		chipset_events[1] = 1;
 		return count;
 	}
@@ -2149,7 +2149,7 @@ static ssize_t devicedisabled_store(struct device *dev,
 {
 	unsigned int id;
 
-	if (kstrtouint(buf, 10, &id) != 0)
+	if (kstrtouint(buf, 10, &id))
 		return -EINVAL;
 
 	parahotplug_request_complete(id, 0);
@@ -2166,7 +2166,7 @@ static ssize_t deviceenabled_store(struct device *dev,
 {
 	unsigned int id;
 
-	if (kstrtouint(buf, 10, &id) != 0)
+	if (kstrtouint(buf, 10, &id))
 		return -EINVAL;
 
 	parahotplug_request_complete(id, 1);
@@ -2195,7 +2195,7 @@ visorchipset_init(void)
 	}
 
 	addr = controlvm_get_channel_address();
-	if (addr != 0) {
+	if (addr) {
 		controlvm_channel =
 		    visorchannel_create_with_lock
 		    (addr,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 021/141] staging: unisys: Remove write-only variable g_diag_msg_hdr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (19 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 020/141] staging: unisys: No point in checking != 0 Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:35 ` [PATCH 022/141] staging: unisys: Remove write-only variable g_del_dump_msg_hdr Benjamin Romer
                   ` (122 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 3b5f3d6..b733147 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -75,7 +75,6 @@ static struct delayed_work periodic_controlvm_work;
 static struct workqueue_struct *periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(notifier_lock);
 
-static struct controlvm_message_header g_diag_msg_hdr;
 static struct controlvm_message_header g_chipset_msg_hdr;
 static struct controlvm_message_header g_del_dump_msg_hdr;
 static const uuid_le spar_diag_pool_channel_protocol_uuid =
@@ -1742,7 +1741,6 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
 			/* save the hdr and cmd structures for later use */
 			/* when sending back the response to Command */
 			my_device_changestate(&inmsg);
-			g_diag_msg_hdr = inmsg.hdr;
 			g_devicechangestate_packet = inmsg.cmd;
 			break;
 		}
@@ -2220,8 +2218,6 @@ visorchipset_init(void)
 		goto cleanup;
 	}
 
-	memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
 	memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
@@ -2287,8 +2283,6 @@ visorchipset_exit(void)
 
 	cleanup_controlvm_structures();
 
-	memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
 	memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 022/141] staging: unisys: Remove write-only variable g_del_dump_msg_hdr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (20 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 021/141] staging: unisys: Remove write-only variable g_diag_msg_hdr Benjamin Romer
@ 2015-05-05 22:35 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 023/141] staging: unisys: add visorbus driver Benjamin Romer
                   ` (121 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:35 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/visorchipset_main.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index b733147..5ea6f9e 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -76,7 +76,6 @@ static struct workqueue_struct *periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(notifier_lock);
 
 static struct controlvm_message_header g_chipset_msg_hdr;
-static struct controlvm_message_header g_del_dump_msg_hdr;
 static const uuid_le spar_diag_pool_channel_protocol_uuid =
 	SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
 /* 0xffffff is an invalid Bus/Device number */
@@ -2220,8 +2219,6 @@ visorchipset_init(void)
 
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-	memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
 	if (!visorchipset_disable_controlvm) {
 		/* if booting in a crash kernel */
 		if (is_kdump_kernel())
@@ -2285,8 +2282,6 @@ visorchipset_exit(void)
 
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-	memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
 	visorchannel_destroy(controlvm_channel);
 
 	visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 023/141] staging: unisys: add visorbus driver
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (21 preceding siblings ...)
  2015-05-05 22:35 ` [PATCH 022/141] staging: unisys: Remove write-only variable g_del_dump_msg_hdr Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-06  9:41   ` Dan Carpenter
  2015-05-09  8:59   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 024/141] staging: unisys: Move visorchannel into visorbus Benjamin Romer
                   ` (120 subsequent siblings)
  143 siblings, 2 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This base driver provides bus functionality to visorhid, visorhba,
and visornic which will be later added to our driver base. Visorbus
supports sPar bus model and manages bus specific functionality. It
maintains the sysfs subtree /sys/devices/visorbus*/.It is
responsible for device creation and destruction of the devices on
its bus.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Kconfig                     |    1 +
 drivers/staging/unisys/Makefile                    |    1 +
 .../common-spar/include/channels/vbuschannel.h     |    2 +-
 drivers/staging/unisys/visorbus/Kconfig            |   10 +
 drivers/staging/unisys/visorbus/Makefile           |   14 +
 drivers/staging/unisys/visorbus/businst_attr.c     |  103 ++
 drivers/staging/unisys/visorbus/businst_attr.h     |   40 +
 drivers/staging/unisys/visorbus/channel_attr.c     |  227 +++
 drivers/staging/unisys/visorbus/channel_attr.h     |   27 +
 .../staging/unisys/visorbus/devmajorminor_attr.c   |  192 +++
 .../staging/unisys/visorbus/devmajorminor_attr.h   |   31 +
 drivers/staging/unisys/visorbus/visorbus.h         |  166 ++
 drivers/staging/unisys/visorbus/visorbus_main.c    | 1643 ++++++++++++++++++++
 drivers/staging/unisys/visorbus/visorbus_private.h |   50 +
 14 files changed, 2506 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/unisys/visorbus/Kconfig
 create mode 100644 drivers/staging/unisys/visorbus/Makefile
 create mode 100644 drivers/staging/unisys/visorbus/businst_attr.c
 create mode 100644 drivers/staging/unisys/visorbus/businst_attr.h
 create mode 100644 drivers/staging/unisys/visorbus/channel_attr.c
 create mode 100644 drivers/staging/unisys/visorbus/channel_attr.h
 create mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.c
 create mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.h
 create mode 100644 drivers/staging/unisys/visorbus/visorbus.h
 create mode 100644 drivers/staging/unisys/visorbus/visorbus_main.c
 create mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index 14e1ea6..8d056b5 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -12,5 +12,6 @@ if UNISYSSPAR
 source "drivers/staging/unisys/visorutil/Kconfig"
 source "drivers/staging/unisys/visorchannel/Kconfig"
 source "drivers/staging/unisys/visorchipset/Kconfig"
+source "drivers/staging/unisys/visorbus/Kconfig"
 
 endif # UNISYSSPAR
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index 97e750d..1ed9d39 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -4,3 +4,4 @@
 obj-$(CONFIG_UNISYS_VISORUTIL)		+= visorutil/
 obj-$(CONFIG_UNISYS_VISORCHANNEL)	+= visorchannel/
 obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset/
+obj-$(CONFIG_UNISYS_VISORBUS)		+= visorbus/
diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
index 2c42ce1..5ed83a3 100644
--- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
@@ -54,7 +54,7 @@ static const uuid_le spar_vbus_channel_protocol_uuid =
 #define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes)    \
 	(spar_check_channel_server(spar_vbus_channel_protocol_uuid,	\
 				   "vbus",				\
-				   sizeof(struct ultra_vbus_channel_protocol),\
+				   sizeof(struct spar_vbus_channel_protocol),\
 				   actual_bytes))
 
 #pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig
new file mode 100644
index 0000000..0141528
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/Kconfig
@@ -0,0 +1,10 @@
+#
+# Unisys visorbus configuration
+#
+
+config UNISYS_VISORBUS
+	tristate "Unisys visorbus driver"
+	depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && UNISYS_VISORCHIPSET
+	---help---
+	If you say Y here, you will enable the Unisys visorbus driver.
+
diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
new file mode 100644
index 0000000..60bb96b
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -0,0 +1,14 @@
+#
+# Makefile for Unisys visorbus
+#
+
+obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
+
+visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o
+
+ccflags-y += -Idrivers/staging/unisys/include
+ccflags-y += -Idrivers/staging/unisys/visorchannel
+ccflags-y += -Idrivers/staging/unisys/visorchipset
+ccflags-y += -Idrivers/staging/unisys/common-spar/include
+ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
+ccflags-y += -Idrivers/staging/unisys/visorutil
diff --git a/drivers/staging/unisys/visorbus/businst_attr.c b/drivers/staging/unisys/visorbus/businst_attr.c
new file mode 100644
index 0000000..b3fea9d
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/businst_attr.c
@@ -0,0 +1,103 @@
+/* businst_attr.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*   This is actually something they forgot to put in the kernel.
+ *   struct bus_type in the kernel SHOULD have a "busses" member, which
+ *   should be treated similarly to the "devices" and "drivers" members.
+ *   There SHOULD be:
+ *   - a "businst_attribute" analogous to the existing "bus_attribute"
+ *   - a "businst_create_file" and "businst_remove_file" analogous to the
+ *     existing "bus_create_file" and "bus_remove_file".
+ *   That's what I created businst.c and businst.h to do.
+ *
+ *   We want to add the "busses" sub-tree in sysfs, where we will house the
+ *   names and properties of each bus instance:
+ *
+ *       /sys/bus/<bustypename>/
+ *           version
+ *           devices
+ *               <devname1> --> /sys/devices/<businstancename><devname1>
+ *               <devname2> --> /sys/devices/<businstancename><devname2>
+ *           drivers
+ *               <driverinstancename1>
+ *                   <driverinstance1property1>
+ *                   <driverinstance1property2>
+ *                   ...
+ *               <driverinstancename2>
+ *                   <driverinstance2property1>
+ *                   <driverinstance2property2>
+ *                   ...
+ *   >>      busses
+ *   >>          <businstancename1>
+ *   >>              <businstance1property1>
+ *   >>              <businstance1property2>
+ *   >>              ...
+ *   >>          <businstancename2>
+ *   >>              <businstance2property1>
+ *   >>              <businstance2property2>
+ *   >>              ...
+ *
+ *   I considered adding bus instance properties under
+ *   /sys/devices/<businstancename>.  But I thought there may be existing
+ *   notions that ONLY device sub-trees should live under
+ *   /sys/devices/<businstancename>.  So I stayed out of there.
+ *
+ */
+
+#include "businst_attr.h"
+
+#define to_businst_attr(_attr) \
+	container_of(_attr, struct businst_attribute, attr)
+#define to_visorbus_devdata(obj) \
+	container_of(obj, struct visorbus_devdata, kobj)
+#define CURRENT_FILE_PC VISOR_BUS_PC_businst_attr_c
+
+ssize_t businst_attr_show(struct kobject *kobj, struct attribute *attr,
+			  char *buf)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->show)
+		ret = businst_attr->show(bus, buf);
+	return ret;
+}
+
+ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
+			   const char *buf, size_t count)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->store)
+		ret = businst_attr->store(bus, buf, count);
+	return ret;
+}
+
+int businst_create_file(struct visorbus_devdata *bus,
+			struct businst_attribute *attr)
+{
+	return sysfs_create_file(&bus->kobj, &attr->attr);
+}
+
+void businst_remove_file(struct visorbus_devdata *bus,
+			 struct businst_attribute *attr)
+{
+	sysfs_remove_file(&bus->kobj, &attr->attr);
+}
diff --git a/drivers/staging/unisys/visorbus/businst_attr.h b/drivers/staging/unisys/visorbus/businst_attr.h
new file mode 100644
index 0000000..e9fb36a
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/businst_attr.h
@@ -0,0 +1,40 @@
+/* businst_attr.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __BUSINST_H__
+#define __BUSINST_H__
+
+#include "visorbus_private.h"	/* just to get visorbus_devdata declaration */
+#include "timskmod.h"
+
+struct businst_attribute {
+	struct attribute attr;
+	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
+	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
+			  size_t count);
+};
+
+ssize_t businst_attr_show(struct kobject *kobj,
+			  struct attribute *attr, char *buf);
+ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
+			   const char *buf, size_t count);
+int businst_create_file(struct visorbus_devdata *bus,
+			struct businst_attribute *attr);
+void businst_remove_file(struct visorbus_devdata *bus,
+			 struct businst_attribute *attr);
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/channel_attr.c b/drivers/staging/unisys/visorbus/channel_attr.c
new file mode 100644
index 0000000..0d7184a
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/channel_attr.c
@@ -0,0 +1,227 @@
+/* channel_attr.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/* Implement publishing of channel attributes under:
+ *
+ *     /sys/bus/visorbus<x>/dev<y>/channel
+ *
+ */
+
+#include "channel_attr.h"
+#define CURRENT_FILE_PC VISOR_BUS_PC_channel_attr_c
+#define to_channel_attr(_attr) \
+	container_of(_attr, struct channel_attribute, attr)
+#define to_visor_device_from_kobjchannel(obj) \
+	container_of(obj, struct visor_device, kobjchannel)
+
+struct channel_attribute {
+	struct attribute attr;
+	 ssize_t (*show)(struct visor_device*, char *buf);
+	 ssize_t (*store)(struct visor_device*, const char *buf, size_t count);
+};
+
+/* begin implementation of specific channel attributes to appear under
+* /sys/bus/visorbus<x>/dev<y>/channel
+*/
+static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf)
+{
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+			visorchannel_get_physaddr(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf)
+{
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+			visorchannel_get_nbytes(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev,
+						  char *buf) {
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+			visorchannel_get_clientpartition(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf)
+{
+	char s[99];
+
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%s\n",
+			visorchannel_id(dev->visorchannel, s));
+}
+
+static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf)
+{
+	char s[99];
+
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%s\n",
+			visorchannel_zoneid(dev->visorchannel, s));
+}
+
+static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf)
+{
+	int i = 0;
+	struct bus_type *xbus = dev->device.bus;
+	struct device_driver *xdrv = dev->device.driver;
+	struct visor_driver *drv = NULL;
+
+	if (!dev->visorchannel || !xbus || !xdrv)
+		return 0;
+	i = xbus->match(&dev->device, xdrv);
+	if (!i)
+		return 0;
+	drv = to_visor_driver(xdrv);
+	return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
+}
+
+static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf)
+{
+	int count = 0;
+/* TODO: replace this with debugfs code
+	struct seq_file *m = NULL;
+	if (dev->visorchannel == NULL)
+		return 0;
+	m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
+	if (m == NULL)
+		return 0;
+	visorchannel_debug(dev->visorchannel, 1, m, 0);
+	count = m->count;
+	visor_seq_file_done_buffer(m);
+	m = NULL;
+*/
+	return count;
+}
+
+static struct channel_attribute all_channel_attrs[] = {
+	__ATTR(physaddr, S_IRUGO,
+	       devicechannel_attr_physaddr, NULL),
+	__ATTR(nbytes, S_IRUGO,
+	       devicechannel_attr_nbytes, NULL),
+	__ATTR(clientpartition, S_IRUGO,
+	       devicechannel_attr_clientpartition, NULL),
+	__ATTR(typeguid, S_IRUGO,
+	       devicechannel_attr_typeguid, NULL),
+	__ATTR(zoneguid, S_IRUGO,
+	       devicechannel_attr_zoneguid, NULL),
+	__ATTR(typename, S_IRUGO,
+	       devicechannel_attr_typename, NULL),
+	__ATTR(dump, S_IRUGO,
+	       devicechannel_attr_dump, NULL),
+};
+
+/* end implementation of specific channel attributes */
+
+static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr,
+				 char *buf)
+{
+	struct channel_attribute *channel_attr = to_channel_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
+	ssize_t ret = 0;
+
+	if (channel_attr->show)
+		ret = channel_attr->show(dev, buf);
+	return ret;
+}
+
+static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct channel_attribute *channel_attr = to_channel_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
+	ssize_t ret = 0;
+
+	if (channel_attr->store)
+		ret = channel_attr->store(dev, buf, count);
+	return ret;
+}
+
+static int channel_create_file(struct visor_device *dev,
+			       struct channel_attribute *attr)
+{
+	return sysfs_create_file(&dev->kobjchannel, &attr->attr);
+}
+
+static void channel_remove_file(struct visor_device *dev,
+				struct channel_attribute *attr)
+{
+	sysfs_remove_file(&dev->kobjchannel, &attr->attr);
+}
+
+static const struct sysfs_ops channel_sysfs_ops = {
+	.show = channel_attr_show,
+	.store = channel_attr_store,
+};
+
+static struct kobj_type channel_kobj_type = {
+	.sysfs_ops = &channel_sysfs_ops
+};
+
+int register_channel_attributes(struct visor_device *dev)
+{
+	int rc = 0, i = 0, x = 0;
+
+	if (dev->kobjchannel.parent)
+		goto away;	/* already registered */
+	x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type,
+				 &dev->device.kobj, "channel");
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+
+	kobject_uevent(&dev->kobjchannel, KOBJ_ADD);
+
+	for (i = 0;
+	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
+	     i++)
+		x = channel_create_file(dev, &all_channel_attrs[i]);
+	if (x < 0) {
+		while (--i >= 0)
+			channel_remove_file(dev, &all_channel_attrs[i]);
+		kobject_del(&dev->kobjchannel);
+		kobject_put(&dev->kobjchannel);
+		rc = x;
+		goto away;
+	}
+away:
+	return rc;
+}
+
+void unregister_channel_attributes(struct visor_device *dev)
+{
+	int i = 0;
+
+	if (!dev->kobjchannel.parent)
+		return;		/* already unregistered */
+	for (i = 0;
+	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
+	     i++)
+		channel_remove_file(dev, &all_channel_attrs[i]);
+
+	kobject_del(&dev->kobjchannel);
+	kobject_put(&dev->kobjchannel);
+	dev->kobjchannel.parent = NULL;
+}
diff --git a/drivers/staging/unisys/visorbus/channel_attr.h b/drivers/staging/unisys/visorbus/channel_attr.h
new file mode 100644
index 0000000..00ae37c
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/channel_attr.h
@@ -0,0 +1,27 @@
+/* channel_attr.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __CHANNEL_ATTR_H__
+#define __CHANNEL_ATTR_H__
+
+#include "visorbus.h"		/* just to get visor_device declaration */
+#include "timskmod.h"
+
+int register_channel_attributes(struct visor_device *dev);
+void unregister_channel_attributes(struct visor_device *dev);
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.c b/drivers/staging/unisys/visorbus/devmajorminor_attr.c
new file mode 100644
index 0000000..ceb4bb7
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/devmajorminor_attr.c
@@ -0,0 +1,192 @@
+/* devmajorminor_attr.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/* Implement publishing of device node attributes under:
+ *
+ *     /sys/bus/visorbus<x>/dev<y>/devmajorminor
+ *
+ */
+
+#include "devmajorminor_attr.h"
+#define CURRENT_FILE_PC VISOR_BUS_PC_devmajorminor_attr_c
+
+#define to_devmajorminor_attr(_attr) \
+	container_of(_attr, struct devmajorminor_attribute, attr)
+#define to_visor_device_from_kobjdevmajorminor(obj) \
+	container_of(obj, struct visor_device, kobjdevmajorminor)
+
+struct devmajorminor_attribute {
+	struct attribute attr;
+	int slot;
+	 ssize_t (*show)(struct visor_device *, int slot, char *buf);
+	 ssize_t (*store)(struct visor_device *, int slot, const char *buf,
+			  size_t count);
+};
+
+static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+	if (slot < 0 || slot >= maxdevnodes)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n",
+			dev->devnodes[slot].major, dev->devnodes[slot].minor);
+}
+
+static ssize_t
+devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+	struct devmajorminor_attribute *devmajorminor_attr =
+	    to_devmajorminor_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+	ssize_t ret = 0;
+
+	if (devmajorminor_attr->show)
+		ret = devmajorminor_attr->show(dev,
+					       devmajorminor_attr->slot, buf);
+	return ret;
+}
+
+static ssize_t
+devmajorminor_attr_store(struct kobject *kobj,
+			 struct attribute *attr, const char *buf, size_t count)
+{
+	struct devmajorminor_attribute *devmajorminor_attr =
+	    to_devmajorminor_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+	ssize_t ret = 0;
+
+	if (devmajorminor_attr->store)
+		ret = devmajorminor_attr->store(dev,
+						devmajorminor_attr->slot,
+						buf, count);
+	return ret;
+}
+
+int
+devmajorminor_create_file(struct visor_device *dev, const char *name,
+			  int major, int minor)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+	struct devmajorminor_attribute *myattr = NULL;
+	int x = -1, rc = 0, slot = -1;
+
+	register_devmajorminor_attributes(dev);
+	for (slot = 0; slot < maxdevnodes; slot++)
+		if (!dev->devnodes[slot].attr)
+			break;
+	if (slot == maxdevnodes) {
+		rc = -ENOMEM;
+		goto away;
+	}
+	myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
+	if (!myattr) {
+		rc = -ENOMEM;
+		goto away;
+	}
+	memset(myattr, 0, sizeof(struct devmajorminor_attribute));
+	myattr->show = DEVMAJORMINOR_ATTR;
+	myattr->store = NULL;
+	myattr->slot = slot;
+	myattr->attr.name = name;
+	myattr->attr.mode = S_IRUGO;
+	dev->devnodes[slot].attr = myattr;
+	dev->devnodes[slot].major = major;
+	dev->devnodes[slot].minor = minor;
+	x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr);
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+	kobject_uevent(&dev->device.kobj, KOBJ_ONLINE);
+away:
+	if (rc < 0) {
+		kfree(myattr);
+		myattr = NULL;
+		dev->devnodes[slot].attr = NULL;
+	}
+	return rc;
+}
+
+void
+devmajorminor_remove_file(struct visor_device *dev, int slot)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+	struct devmajorminor_attribute *myattr = NULL;
+
+	if (slot < 0 || slot >= maxdevnodes)
+		return;
+	myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
+	if (myattr)
+		return;
+	sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
+	kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
+	dev->devnodes[slot].attr = NULL;
+	kfree(myattr);
+}
+
+void
+devmajorminor_remove_all_files(struct visor_device *dev)
+{
+	int i = 0;
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+	for (i = 0; i < maxdevnodes; i++)
+		devmajorminor_remove_file(dev, i);
+}
+
+static const struct sysfs_ops devmajorminor_sysfs_ops = {
+	.show = devmajorminor_attr_show,
+	.store = devmajorminor_attr_store,
+};
+
+static struct kobj_type devmajorminor_kobj_type = {
+	.sysfs_ops = &devmajorminor_sysfs_ops
+};
+
+int
+register_devmajorminor_attributes(struct visor_device *dev)
+{
+	int rc = 0, x = 0;
+
+	if (dev->kobjdevmajorminor.parent)
+		goto away;	/* already registered */
+	x = kobject_init_and_add(&dev->kobjdevmajorminor,
+				 &devmajorminor_kobj_type, &dev->device.kobj,
+				 "devmajorminor");
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+
+	kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD);
+
+away:
+	return rc;
+}
+
+void
+unregister_devmajorminor_attributes(struct visor_device *dev)
+{
+	if (!dev->kobjdevmajorminor.parent)
+		return;		/* already unregistered */
+	devmajorminor_remove_all_files(dev);
+
+	kobject_del(&dev->kobjdevmajorminor);
+	kobject_put(&dev->kobjdevmajorminor);
+	dev->kobjdevmajorminor.parent = NULL;
+}
diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.h b/drivers/staging/unisys/visorbus/devmajorminor_attr.h
new file mode 100644
index 0000000..0b55cb1
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/devmajorminor_attr.h
@@ -0,0 +1,31 @@
+/* devmajorminor_attr.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __DEVMAJORMINOR_ATTR_H__
+#define __DEVMAJORMINOR_ATTR_H__
+
+#include "visorbus.h"		/* just to get visor_device declaration */
+#include "timskmod.h"
+
+int register_devmajorminor_attributes(struct visor_device *dev);
+void unregister_devmajorminor_attributes(struct visor_device *dev);
+int devmajorminor_create_file(struct visor_device *dev, const char *nam,
+			      int major, int minor);
+void devmajorminor_remove_file(struct visor_device *dev, int slot);
+void devmajorminor_remove_all_files(struct visor_device *dev);
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/visorbus/visorbus.h
new file mode 100644
index 0000000..856fa3f
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus.h
@@ -0,0 +1,166 @@
+/* visorbus.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ *  This header file is to be included by other kernel mode components that
+ *  implement a particular kind of visor_device.  Each of these other kernel
+ *  mode components is called a visor device driver.  Refer to visortemplate
+ *  for a minimal sample visor device driver.
+ *
+ *  There should be nothing in this file that is private to the visorbus
+ *  bus implementation itself.
+ *
+ */
+
+#ifndef __VISORBUS_H__
+#define __VISORBUS_H__
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/uuid.h>
+
+#include "periodic_work.h"
+#include "visorchannel.h"
+#include "channel.h"
+
+struct visor_driver;
+struct visor_device;
+
+typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
+					      int status);
+
+/** This struct describes a specific Supervisor channel, by providing its
+ *  GUID, name, and sizes.
+ */
+struct visor_channeltype_descriptor {
+	const uuid_le guid;
+	const char *name;
+	unsigned long min_size;
+	unsigned long max_size;
+};
+
+/** Information provided by each visor driver when it registers with the
+ *  visorbus driver.
+ */
+struct visor_driver {
+	const char *name;
+	const char *version;
+	const char *vertag;
+	const char *build_date;
+	const char *build_time;
+	struct module *owner;
+
+	/** Types of channels handled by this driver, ending with 0 GUID.
+	 *  Our specialized BUS.match() method knows about this list, and
+	 *  uses it to determine whether this driver will in fact handle a
+	 *  new device that it has detected.
+	 */
+	struct visor_channeltype_descriptor *channel_types;
+
+	/** Called when a new device comes online, by our probe() function
+	 *  specified by driver.probe() (triggered ultimately by some call
+	 *  to driver_register() / bus_add_driver() / driver_attach()).
+	 */
+	int (*probe)(struct visor_device *dev);
+
+	/** Called when a new device is removed, by our remove() function
+	 *  specified by driver.remove() (triggered ultimately by some call
+	 *  to device_release_driver()).
+	 */
+	void (*remove)(struct visor_device *dev);
+
+	/** Called periodically, whenever there is a possibility that
+	 *  "something interesting" may have happened to the channel state.
+	 */
+	void (*channel_interrupt)(struct visor_device *dev);
+
+	/** Called to initiate a change of the device's state.  If the return
+	 *  valu`e is < 0, there was an error and the state transition will NOT
+	 *  occur.  If the return value is >= 0, then the state transition was
+	 *  INITIATED successfully, and complete_func() will be called (or was
+	 *  just called) with the final status when either the state transition
+	 *  fails or completes successfully.
+	 */
+	int (*pause)(struct visor_device *dev,
+		     visorbus_state_complete_func complete_func);
+	int (*resume)(struct visor_device *dev,
+		      visorbus_state_complete_func complete_func);
+
+	/** These fields are for private use by the bus driver only. */
+	struct device_driver driver;
+	struct driver_attribute version_attr;
+};
+
+#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
+
+/** A device type for things "plugged" into the visorbus bus */
+
+struct visor_device {
+	/** visor driver can use the visorchannel member with the functions
+	 *  defined in visorchannel.h to access the channel
+	 */
+	struct visorchannel *visorchannel;
+	uuid_le channel_type_guid;
+	u64 channel_bytes;
+
+	/** These fields are for private use by the bus driver only.
+	 *  A notable exception is that the visor driver can use
+	 *  visor_get_drvdata() and visor_set_drvdata() to retrieve or stash
+	 *  private visor driver specific data within the device member.
+	 */
+	struct device device;
+	struct list_head list_all;
+	struct periodic_work *periodic_work;
+	bool being_removed;
+	bool responded_to_device_create;
+	struct kobject kobjchannel;	/* visorbus<x>/dev<y>/channel/ */
+	struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
+	struct {
+		int major, minor;
+		void *attr;	/* private use by devmajorminor_attr.c you can
+				   * change this constant to whatever you
+				   * want; */
+	} devnodes[5];
+	/* the code will detect and behave appropriately) */
+	struct semaphore visordriver_callback_lock;
+	bool pausing;
+	bool resuming;
+	unsigned long chipset_bus_no;
+	unsigned long chipset_dev_no;
+};
+
+#define to_visor_device(x) container_of(x, struct visor_device, device)
+
+#ifndef STANDALONE_CLIENT
+int visorbus_register_visor_driver(struct visor_driver *);
+void visorbus_unregister_visor_driver(struct visor_driver *);
+int visorbus_read_channel(struct visor_device *dev,
+			  unsigned long offset, void *dest,
+			  unsigned long nbytes);
+int visorbus_write_channel(struct visor_device *dev,
+			   unsigned long offset, void *src,
+			   unsigned long nbytes);
+int visorbus_clear_channel(struct visor_device *dev,
+			   unsigned long offset, u8 ch, unsigned long nbytes);
+int visorbus_registerdevnode(struct visor_device *dev,
+			     const char *name, int major, int minor);
+void visorbus_enable_channel_interrupts(struct visor_device *dev);
+void visorbus_disable_channel_interrupts(struct visor_device *dev);
+#endif
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
new file mode 100644
index 0000000..d717e35
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -0,0 +1,1643 @@
+/* visorbus_main.c
+ *
+ * Copyright � 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#include <linux/uuid.h>
+
+#include "visorbus_private.h"
+#include "businst_attr.h"
+#include "channel_attr.h"
+#include "devmajorminor_attr.h"
+#include "periodic_work.h"
+#include "vbuschannel.h"
+#include "guestlinuxdebug.h"
+#include "vbusdeviceinfo.h"
+/* These forward declarations are required since our drivers are out-of-tree.
+ * The structures referenced are kernel-private and are not in the headers, but
+ * it is impossible to make a functioning bus driver without them.
+ */
+struct subsys_private {
+	struct kset subsys;
+	struct kset *devices_kset;
+
+	struct kset *drivers_kset;
+	struct klist klist_devices;
+	struct klist klist_drivers;
+	struct blocking_notifier_head bus_notifier;
+	unsigned int drivers_autoprobe:1;
+	struct bus_type *bus;
+
+	struct list_head class_interfaces;
+	struct kset glue_dirs;
+	struct mutex class_mutex; /* ignore */
+	struct class *class;
+};
+
+struct bus_type_private {
+	struct kset subsys;
+	struct kset *drivers_kset;
+	struct kset *devices_kset;
+	struct klist klist_devices;
+	struct klist klist_drivers;
+	struct blocking_notifier_head bus_notifier;
+	unsigned int drivers_autoprobe:1;
+	struct bus_type *bus;
+};
+
+#define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
+#define POLLJIFFIES_TESTWORK         100
+#define POLLJIFFIES_NORMALCHANNEL     10
+
+static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
+static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
+static void fix_vbus_dev_info(struct visor_device *visordev);
+
+/** This describes the TYPE of bus.
+ *  (Don't confuse this with an INSTANCE of the bus.)
+ */
+static struct bus_type visorbus_type = {
+	.name = "visorbus",
+	.match = visorbus_match,
+	.uevent = visorbus_uevent,
+};
+
+static struct delayed_work periodic_work;
+
+/* YES, we need 2 workqueues.
+ * The reason is, workitems on the test queue may need to cancel
+ * workitems on the other queue.  You will be in for trouble if you try to
+ * do this with workitems queued on the same workqueue.
+ */
+static struct workqueue_struct *periodic_test_workqueue;
+static struct workqueue_struct *periodic_dev_workqueue;
+static long long bus_count;	/** number of bus instances */
+static long long total_devices_created;
+					/** ever-increasing */
+
+static void chipset_bus_create(u32 bus_no);
+static void chipset_bus_destroy(u32 bus_no);
+static void chipset_device_create(u32 bus_no, u32 dev_no);
+static void chipset_device_destroy(u32 bus_no, u32 dev_no);
+static void chipset_device_pause(u32 bus_no, u32 dev_no);
+static void chipset_device_resume(u32 bus_no, u32 dev_no);
+
+/** These functions are implemented herein, and are called by the chipset
+ *  driver to notify us about specific events.
+ */
+static struct visorchipset_busdev_notifiers chipset_notifiers = {
+	.bus_create = chipset_bus_create,
+	.bus_destroy = chipset_bus_destroy,
+	.device_create = chipset_device_create,
+	.device_destroy = chipset_device_destroy,
+	.device_pause = chipset_device_pause,
+	.device_resume = chipset_device_resume,
+};
+
+/** These functions are implemented in the chipset driver, and we call them
+ *  herein when we want to acknowledge a specific event.
+ */
+static struct visorchipset_busdev_responders chipset_responders;
+
+/* filled in with info about parent chipset driver when we register with it */
+static struct ultra_vbus_deviceinfo chipset_driverinfo;
+/* filled in with info about this driver, wrt it servicing client busses */
+static struct ultra_vbus_deviceinfo clientbus_driverinfo;
+
+/** list of visorbus_devdata structs, linked via .list_all */
+static LIST_HEAD(list_all_bus_instances);
+/** list of visor_device structs, linked via .list_all */
+static LIST_HEAD(list_all_device_instances);
+
+static int
+visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env)
+{
+	if (add_uevent_var(env, "VERSION=%s", VERSION))
+		return -ENOMEM;
+	return 0;
+}
+
+/* This is called automatically upon adding a visor_device (device_add), or
+ * adding a visor_driver (visorbus_register_visor_driver), and returns 1 iff the
+ * provided driver can control the specified device.
+ */
+static int
+visorbus_match(struct device *xdev, struct device_driver *xdrv)
+{
+	uuid_le channel_type;
+	int rc = 0;
+	int i;
+	struct visor_device *dev;
+	struct visor_driver *drv;
+
+	dev = to_visor_device(xdev);
+	drv = to_visor_driver(xdrv);
+	channel_type = visorchannel_get_uuid(dev->visorchannel);
+	if (visorbus_forcematch) {
+		rc = 1;
+		goto away;
+	}
+	if (visorbus_forcenomatch)
+		goto away;
+
+	if (!drv->channel_types)
+		goto away;
+	for (i = 0;
+	     (uuid_le_cmp(drv->channel_types[i].guid, NULL_UUID_LE) != 0) ||
+	     (drv->channel_types[i].name);
+	     i++)
+		if (uuid_le_cmp(drv->channel_types[i].guid,
+				channel_type) == 0) {
+			rc = i + 1;
+			goto away;
+		}
+away:
+	return rc;
+}
+
+/** This is called when device_unregister() is called for the bus device
+ *  instance, after all other tasks involved with destroying the device
+ *  are complete.
+ */
+static void
+visorbus_release_busdevice(struct device *xdev)
+{
+	struct visorbus_devdata *devdata = dev_get_drvdata(xdev);
+
+	dev_set_drvdata(xdev, NULL);
+	kfree(devdata);
+	kfree(xdev);
+}
+
+/** This is called when device_unregister() is called for each child
+ *  device instance.
+ */
+static void
+visorbus_release_device(struct device *xdev)
+{
+	struct visor_device *dev = to_visor_device(xdev);
+
+	if (dev->periodic_work) {
+		visor_periodic_work_destroy(dev->periodic_work);
+		dev->periodic_work = NULL;
+	}
+	if (dev->visorchannel) {
+		visorchannel_destroy(dev->visorchannel);
+		dev->visorchannel = NULL;
+	}
+	kfree(dev);
+}
+
+static const struct sysfs_ops businst_sysfs_ops = {
+	.show = businst_attr_show,
+	.store = businst_attr_store,
+};
+
+static struct kobj_type businst_kobj_type = {
+	.sysfs_ops = &businst_sysfs_ops
+};
+
+static struct kset businstances = { /* should actually be a member of
+				     * bus_type */
+};
+
+/*  BUS type attributes
+ *
+ *  define & implement display of bus attributes under
+ *  /sys/bus/visorbus.
+ *
+ */
+
+static ssize_t
+BUSTYPE_ATTR_version(struct bus_type *bus, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%s\n", VERSION);
+}
+
+static struct bus_attribute bustype_attr_version =
+__ATTR(version, S_IRUGO, BUSTYPE_ATTR_version, NULL);
+
+static int
+register_bustype_attributes(void)
+{
+	int rc = 0;
+
+	rc = bus_create_file(&visorbus_type, &bustype_attr_version);
+	if (rc < 0)
+			goto away;
+
+	/* Here we make up for the fact that bus_type does not yet have a
+	 * member to keep track of multiple bus instances for a given bus
+	 * type.  This is useful for stashing properties for each bus
+	 * instance.
+	 */
+	kobject_set_name(&businstances.kobj, "busses");
+	businstances.kobj.ktype = &businst_kobj_type;
+	businstances.kobj.parent = &visorbus_type.p->subsys.kobj;
+	rc = kset_register(&businstances);
+	if (rc < 0)
+			goto away;
+
+	rc = 0;
+away:
+	return rc;
+}
+
+static void
+unregister_bustype_attributes(void)
+{
+	bus_remove_file(&visorbus_type, &bustype_attr_version);
+	kset_unregister(&businstances);
+}
+
+/*  BUS instance attributes
+ *
+ *  define & implement display of bus attributes under
+ *  /sys/bus/visorbus/busses/visorbus<n>.
+ *
+ *  This is a bit hoaky because the kernel does not yet have the infrastructure
+ *  to separate bus INSTANCE attributes from bus TYPE attributes...
+ *  so we roll our own.  See businst.c / businst.h.
+ *
+ */
+
+static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst,
+					     char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int len = 0;
+
+	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
+		len = snprintf(buf, PAGE_SIZE,
+			       "0x%Lx\n",
+			       (unsigned long long)bus_info.partition_handle);
+	return len;
+}
+
+static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst,
+					   char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int len = 0;
+
+	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
+		len = snprintf(buf, PAGE_SIZE, "{%pUb}\n",
+			       &bus_info.partition_uuid);
+	return len;
+}
+
+static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst,
+					   char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int len = 0;
+
+	if (businst &&
+	    visorchipset_get_bus_info(businst->devno, &bus_info) &&
+	    bus_info.name)
+		len = snprintf(buf, PAGE_SIZE, "%s\n", bus_info.name);
+	return len;
+}
+
+static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst,
+					 char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int len = 0;
+
+	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
+		len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
+			       bus_info.chan_info.channel_addr);
+	return len;
+}
+
+static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst,
+					   char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int len = 0;
+
+	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
+		len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
+			       bus_info.chan_info.n_channel_bytes);
+	return len;
+}
+
+static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst,
+				       char *buf) {
+	int len = 0;
+
+	if (businst && businst->chan) {
+		visorchannel_id(businst->chan, buf);
+		len = strlen(buf);
+		buf[len++] = '\n';
+	}
+	return len;
+}
+
+static ssize_t businst_attr_client_bus_info(struct visorbus_devdata *businst,
+					    char *buf) {
+	struct visorchipset_bus_info bus_info;
+	int i, x, remain = PAGE_SIZE;
+	unsigned long off;
+	char *p = buf;
+	u8 *partition_name;
+	struct ultra_vbus_deviceinfo dev_info;
+
+	partition_name = "";
+	if (businst && businst->chan) {
+		if (visorchipset_get_bus_info(businst->devno, &bus_info) &&
+		    bus_info.name)
+			partition_name = bus_info.name;
+		x = snprintf(p, remain,
+			     "Client device / client driver info for %s partition (vbus #%d):\n",
+			     partition_name, businst->devno);
+		p += x;
+		remain -= x;
+		x = visorchannel_read(businst->chan,
+				      offsetof(struct
+					       spar_vbus_channel_protocol,
+					       chp_info),
+				      &dev_info, sizeof(dev_info));
+		if (x >= 0) {
+			x = vbuschannel_devinfo_to_string(&dev_info, p,
+							  remain, -1);
+			p += x;
+			remain -= x;
+		}
+		x = visorchannel_read(businst->chan,
+				      offsetof(struct
+					       spar_vbus_channel_protocol,
+					       bus_info),
+				      &dev_info, sizeof(dev_info));
+		if (x >= 0) {
+			x = vbuschannel_devinfo_to_string(&dev_info, p,
+							  remain, -1);
+			p += x;
+			remain -= x;
+		}
+		off = offsetof(struct spar_vbus_channel_protocol, dev_info);
+		i = 0;
+		while (off + sizeof(dev_info) <=
+		       visorchannel_get_nbytes(businst->chan)) {
+			x = visorchannel_read(businst->chan,
+					      off, &dev_info, sizeof(dev_info));
+			if (x >= 0) {
+				x = vbuschannel_devinfo_to_string
+				    (&dev_info, p, remain, i);
+				p += x;
+				remain -= x;
+			}
+			off += sizeof(dev_info);
+			i++;
+		}
+	}
+	return PAGE_SIZE - remain;
+}
+
+static struct businst_attribute ba_partition_handle =
+	__ATTR(partition_handle, S_IRUGO, businst_attr_partition_handle, NULL);
+static struct businst_attribute ba_partition_guid =
+	__ATTR(partition_guid, S_IRUGO, businst_attr_partition_guid, NULL);
+static struct businst_attribute ba_partition_name =
+	__ATTR(partition_name, S_IRUGO, businst_attr_partition_name, NULL);
+static struct businst_attribute ba_channel_addr =
+	__ATTR(channel_addr, S_IRUGO, businst_attr_channel_addr, NULL);
+static struct businst_attribute ba_nchannel_bytes =
+	__ATTR(nchannel_bytes, S_IRUGO, businst_attr_nchannel_bytes, NULL);
+static struct businst_attribute ba_channel_id =
+	__ATTR(channel_id, S_IRUGO, businst_attr_channel_id, NULL);
+static struct businst_attribute ba_client_bus_info =
+	__ATTR(client_bus_info, S_IRUGO, businst_attr_client_bus_info, NULL);
+
+static int
+register_businst_attributes(struct visorbus_devdata *businst)
+{
+	int rc = 0;
+
+	businst->kobj.kset = &businstances;	/* identify parent sysfs dir */
+	rc = kobject_init_and_add(&businst->kobj, &businst_kobj_type,
+				  NULL, "visorbus%d", businst->devno);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_partition_handle);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_partition_guid);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_partition_name);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_channel_addr);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_nchannel_bytes);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_channel_id);
+	if (rc < 0)
+			goto away;
+
+	rc = businst_create_file(businst, &ba_client_bus_info);
+	if (rc < 0)
+			goto away;
+
+	kobject_uevent(&businst->kobj, KOBJ_ADD);
+
+	rc = 0;
+away:
+	return rc;
+}
+
+static void
+unregister_businst_attributes(struct visorbus_devdata *businst)
+{
+	businst_remove_file(businst, &ba_partition_handle);
+	businst_remove_file(businst, &ba_partition_guid);
+	businst_remove_file(businst, &ba_partition_name);
+	businst_remove_file(businst, &ba_channel_addr);
+	businst_remove_file(businst, &ba_nchannel_bytes);
+	businst_remove_file(businst, &ba_channel_id);
+	businst_remove_file(businst, &ba_client_bus_info);
+	kobject_put(&businst->kobj);
+}
+
+/*  DRIVER attributes
+ *
+ *  define & implement display of driver attributes under
+ *  /sys/bus/visorbus/drivers/<drivername>.
+ *
+ */
+
+static ssize_t
+DRIVER_ATTR_version(struct device_driver *xdrv, char *buf)
+{
+	struct visor_driver *drv = to_visor_driver(xdrv);
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", drv->version);
+}
+
+static int
+register_driver_attributes(struct visor_driver *drv)
+{
+	int rc;
+	struct driver_attribute version =
+	    __ATTR(version, S_IRUGO, DRIVER_ATTR_version, NULL);
+	drv->version_attr = version;
+	rc = driver_create_file(&drv->driver, &drv->version_attr);
+	return rc;
+}
+
+static void
+unregister_driver_attributes(struct visor_driver *drv)
+{
+	driver_remove_file(&drv->driver, &drv->version_attr);
+}
+
+/*  DEVICE attributes
+ *
+ *  define & implement display of device attributes under
+ *  /sys/bus/visorbus/devices/<devicename>.
+ *
+ */
+
+#define DEVATTR(nam, func) { \
+	.attr = { .name = __stringify(nam), \
+		  .mode = 0444, \
+		  .owner = THIS_MODULE },	\
+	.show = func, \
+}
+
+static struct device_attribute visor_device_attrs[] = {
+	/* DEVATTR(channel_nbytes, DEVICE_ATTR_channel_nbytes), */
+	__ATTR_NULL
+};
+
+static void
+dev_periodic_work(void *xdev)
+{
+	struct visor_device *dev = (struct visor_device *)xdev;
+	struct visor_driver *drv = to_visor_driver(dev->device.driver);
+
+	down(&dev->visordriver_callback_lock);
+	if (drv->channel_interrupt)
+		drv->channel_interrupt(dev);
+	up(&dev->visordriver_callback_lock);
+	if (!visor_periodic_work_nextperiod(dev->periodic_work))
+		put_device(&dev->device);
+}
+
+static void
+dev_start_periodic_work(struct visor_device *dev)
+{
+	if (dev->being_removed)
+		return;
+	/* now up by at least 2 */
+	get_device(&dev->device);
+	if (!visor_periodic_work_start(dev->periodic_work))
+		put_device(&dev->device);
+}
+
+static void
+dev_stop_periodic_work(struct visor_device *dev)
+{
+	if (visor_periodic_work_stop(dev->periodic_work))
+		put_device(&dev->device);
+}
+
+/** This is called automatically upon adding a visor_device (device_add), or
+ *  adding a visor_driver (visorbus_register_visor_driver), but only after
+ *  visorbus_match has returned 1 to indicate a successful match between
+ *  driver and device.
+ */
+static int
+visordriver_probe_device(struct device *xdev)
+{
+	int rc;
+	struct visor_driver *drv;
+	struct visor_device *dev;
+
+	drv = to_visor_driver(xdev->driver);
+	dev = to_visor_device(xdev);
+	down(&dev->visordriver_callback_lock);
+	dev->being_removed = FALSE;
+	/*
+	 * ensure that the dev->being_removed flag is cleared before
+	 * we start the probe
+	 */
+	wmb();
+	get_device(&dev->device);
+	if (!drv->probe) {
+		up(&dev->visordriver_callback_lock);
+		rc = -1;
+		goto away;
+	}
+	rc = drv->probe(dev);
+	if (rc < 0)
+		goto away;
+
+	fix_vbus_dev_info(dev);
+	up(&dev->visordriver_callback_lock);
+	rc = 0;
+away:
+	if (rc != 0)
+		put_device(&dev->device);
+	/*  We could get here more than once if the child driver module is
+	 *  unloaded and re-loaded while devices are present.  That's why we
+	 *  need a flag to be sure that we only respond to the device_create
+	 *  once.  We cannot respond to the device_create prior to here,
+	 *  because until we call drv->probe() above, the channel has not been
+	 *  initialized.
+	 */
+	if (!dev->responded_to_device_create) {
+		dev->responded_to_device_create = TRUE;
+		if (chipset_responders.device_create)
+			(*chipset_responders.device_create)(dev->chipset_bus_no,
+							    dev->chipset_dev_no,
+							    rc);
+	}
+	return rc;
+}
+
+/** This is called when device_unregister() is called for each child device
+ *  instance, to notify the appropriate visorbus_driver that the device is
+ *  going away, and to decrease the reference count of the device.
+ */
+static int
+visordriver_remove_device(struct device *xdev)
+{
+	int rc = 0;
+	struct visor_device *dev;
+	struct visor_driver *drv;
+
+	dev = to_visor_device(xdev);
+	drv = to_visor_driver(xdev->driver);
+	down(&dev->visordriver_callback_lock);
+	dev->being_removed = TRUE;
+	/*
+	 * ensure that the dev->being_removed flag is set before we start the
+	 * actual removal
+	 */
+	wmb();
+	if (drv) {
+		if (drv->remove)
+			drv->remove(dev);
+	}
+	up(&dev->visordriver_callback_lock);
+	dev_stop_periodic_work(dev);
+	devmajorminor_remove_all_files(dev);
+
+	put_device(&dev->device);
+
+	return rc;
+}
+
+/** A particular type of visor driver calls this function to register
+ *  the driver.  The caller MUST fill in the following fields within the
+ *  #drv structure:
+ *      name, version, owner, channel_types, probe, remove
+ *
+ *  Here's how the whole Linux bus / driver / device model works.
+ *
+ *  At system start-up, the visorbus kernel module is loaded, which registers
+ *  visorbus_type as a bus type, using bus_register().
+ *
+ *  All kernel modules that support particular device types on a
+ *  visorbus bus are loaded.  Each of these kernel modules calls
+ *  visorbus_register_visor_driver() in their init functions, passing a
+ *  visor_driver struct.  visorbus_register_visor_driver() in turn calls
+ *  register_driver(&visor_driver.driver).  This .driver member is
+ *  initialized with generic methods (like probe), whose sole responsibility
+ *  is to act as a broker for the real methods, which are within the
+ *  visor_driver struct.  (This is the way the subclass behavior is
+ *  implemented, since visor_driver is essentially a subclass of the
+ *  generic driver.)  Whenever a driver_register() happens, core bus code in
+ *  the kernel does (see device_attach() in drivers/base/dd.c):
+ *
+ *      for each dev associated with the bus (the bus that driver is on) that
+ *      does not yet have a driver
+ *          if bus.match(dev,newdriver) == yes_matched  ** .match specified
+ *                                                 ** during bus_register().
+ *              newdriver.probe(dev)  ** for visor drivers, this will call
+ *                    ** the generic driver.probe implemented in visorbus.c,
+ *                    ** which in turn calls the probe specified within the
+ *                    ** struct visor_driver (which was specified by the
+ *                    ** actual device driver as part of
+ *                    ** visorbus_register_visor_driver()).
+ *
+ *  The above dance also happens when a new device appears.
+ *  So the question is, how are devices created within the system?
+ *  Basically, just call device_add(dev).  See pci_bus_add_devices().
+ *  pci_scan_device() shows an example of how to build a device struct.  It
+ *  returns the newly-created struct to pci_scan_single_device(), who adds it
+ *  to the list of devices at PCIBUS.devices.  That list of devices is what
+ *  is traversed by pci_bus_add_devices().
+ *
+ */
+int visorbus_register_visor_driver(struct visor_driver *drv)
+{
+	int rc = 0;
+
+	drv->driver.name = drv->name;
+	drv->driver.bus = &visorbus_type;
+	drv->driver.probe = visordriver_probe_device;
+	drv->driver.remove = visordriver_remove_device;
+	drv->driver.owner = drv->owner;
+
+	/* driver_register does this:
+	 *   bus_add_driver(drv)
+	 *   ->if (drv.bus)  ** (bus_type) **
+	 *       driver_attach(drv)
+	 *         for each dev with bus type of drv.bus
+	 *           if (!dev.drv)  ** no driver assigned yet **
+	 *             if (bus.match(dev,drv))  [visorbus_match]
+	 *               dev.drv = drv
+	 *               if (!drv.probe(dev))   [visordriver_probe_device]
+	 *                 dev.drv = NULL
+	 */
+
+	rc = driver_register(&drv->driver);
+	if (rc < 0)
+		return rc;
+	rc = register_driver_attributes(drv);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
+
+/** A particular type of visor driver calls this function to unregister
+ *  the driver, i.e., within its module_exit function.
+ */
+void
+visorbus_unregister_visor_driver(struct visor_driver *drv)
+{
+	unregister_driver_attributes(drv);
+	driver_unregister(&drv->driver);
+}
+EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver);
+
+int
+visorbus_read_channel(struct visor_device *dev, unsigned long offset,
+		      void *dest, unsigned long nbytes)
+{
+	return visorchannel_read(dev->visorchannel, offset, dest, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_read_channel);
+
+int
+visorbus_write_channel(struct visor_device *dev, unsigned long offset,
+		       void *src, unsigned long nbytes)
+{
+	return visorchannel_write(dev->visorchannel, offset, src, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_write_channel);
+
+int
+visorbus_clear_channel(struct visor_device *dev, unsigned long offset, u8 ch,
+		       unsigned long nbytes)
+{
+	return visorchannel_clear(dev->visorchannel, offset, ch, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_clear_channel);
+
+int
+visorbus_registerdevnode(struct visor_device *dev,
+			 const char *name, int major, int minor)
+{
+	return devmajorminor_create_file(dev, name, major, minor);
+}
+EXPORT_SYMBOL_GPL(visorbus_registerdevnode);
+
+/** We don't really have a real interrupt, so for now we just call the
+ *  interrupt function periodically...
+ */
+void
+visorbus_enable_channel_interrupts(struct visor_device *dev)
+{
+	dev_start_periodic_work(dev);
+}
+EXPORT_SYMBOL_GPL(visorbus_enable_channel_interrupts);
+
+void
+visorbus_disable_channel_interrupts(struct visor_device *dev)
+{
+	dev_stop_periodic_work(dev);
+}
+EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
+
+/** This is how everything starts from the device end.
+ *  This function is called when a channel first appears via a ControlVM
+ *  message.  In response, this function allocates a visor_device to
+ *  correspond to the new channel, and attempts to connect it the appropriate
+ *  driver.  If the appropriate driver is found, the visor_driver.probe()
+ *  function for that driver will be called, and will be passed the new
+ *  visor_device that we just created.
+ *
+ *  It's ok if the appropriate driver is not yet loaded, because in that case
+ *  the new device struct will just stick around in the bus' list of devices.
+ *  When the appropriate driver calls visorbus_register_visor_driver(), the
+ *  visor_driver.probe() for the new driver will be called with the new
+ *  device.
+ */
+static int
+create_visor_device(struct visorbus_devdata *devdata,
+		    unsigned long chipset_bus_no, unsigned long chipset_dev_no,
+		    struct visorchipset_channel_info chan_info,
+		    u64 partition_handle)
+{
+	int rc = -1;
+	struct visorchannel *visorchannel = NULL;
+	struct visor_device *dev = NULL;
+	bool gotten = FALSE, registered1 = FALSE, registered2 = FALSE;
+
+	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
+			 POSTCODE_SEVERITY_INFO);
+	/* prepare chan_hdr (abstraction to read/write channel memory) */
+	visorchannel = visorchannel_create(chan_info.channel_addr,
+					   (unsigned long)
+					   chan_info.n_channel_bytes,
+					   chan_info.channel_type_uuid);
+	if (!visorchannel) {
+		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev) {
+		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	memset(dev, 0, sizeof(struct visor_device));
+	dev->visorchannel = visorchannel;
+	dev->channel_type_guid = chan_info.channel_type_uuid;
+	dev->channel_bytes = chan_info.n_channel_bytes;
+	dev->chipset_bus_no = chipset_bus_no;
+	dev->chipset_dev_no = chipset_dev_no;
+	dev->device.parent = devdata->dev;
+	sema_init(&dev->visordriver_callback_lock, 1);	/* unlocked */
+	dev->device.bus = &visorbus_type;
+	device_initialize(&dev->device);
+	dev->device.release = visorbus_release_device;
+	/* keep a reference just for us (now 2) */
+	get_device(&dev->device);
+	gotten = TRUE;
+	dev->periodic_work =
+		visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL,
+					   periodic_dev_workqueue,
+					   dev_periodic_work,
+					   dev, dev_name(&dev->device));
+	if (!dev->periodic_work) {
+		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	/* bus_id must be a unique name with respect to this bus TYPE
+	 * (NOT bus instance).  That's why we need to include the bus
+	 * number within the name.
+	 */
+	dev_set_name(&dev->device, "vbus%lu:dev%lu",
+		     chipset_bus_no, chipset_dev_no);
+
+	/*  device_add does this:
+	 *    bus_add_device(dev)
+	 *    ->device_attach(dev)
+	 *      ->for each driver drv registered on the bus that dev is on
+	 *          if (dev.drv)  **  device already has a driver **
+	 *            ** not sure we could ever get here... **
+	 *          else
+	 *            if (bus.match(dev,drv)) [visorbus_match]
+	 *              dev.drv = drv
+	 *              if (!drv.probe(dev))  [visordriver_probe_device]
+	 *                dev.drv = NULL
+	 *
+	 *  Note that device_add does NOT fail if no driver failed to
+	 *  claim the device.  The device will be linked onto
+	 *  bus_type.klist_devices regardless (use bus_for_each_dev).
+	 */
+	rc = device_add(&dev->device);
+	if (rc < 0) {
+		POSTCODE_LINUX_3(DEVICE_ADD_PC, chipset_bus_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	/* note: device_register is simply device_initialize + device_add */
+	rc = register_channel_attributes(dev);
+	if (rc < 0) {
+		POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	registered1 = TRUE;
+
+	rc = register_devmajorminor_attributes(dev);
+	if (rc < 0) {
+		POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
+				 DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	registered2 = TRUE;
+	rc = 0;
+
+away:
+	if (rc < 0) {
+		if (registered2)
+			unregister_devmajorminor_attributes(dev);
+		if (registered1)
+			unregister_channel_attributes(dev);
+		if (gotten)
+			put_device(&dev->device);
+		if (visorchannel)
+			visorchannel_destroy(visorchannel);
+		kfree(dev);
+	} else {
+		total_devices_created++;
+		list_add_tail(&dev->list_all, &list_all_device_instances);
+	}
+	return rc;
+}
+
+static void
+remove_visor_device(struct visor_device *dev)
+{
+	list_del(&dev->list_all);
+	unregister_devmajorminor_attributes(dev);
+	unregister_channel_attributes(dev);
+	put_device(&dev->device);
+	device_unregister(&dev->device);
+}
+
+static struct visor_device *
+find_visor_device_by_channel(HOSTADDRESS channel_physaddr)
+{
+	struct list_head *listentry, *listtmp;
+
+	list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
+		struct visor_device *dev = list_entry(listentry,
+						      struct visor_device,
+						      list_all);
+		if (visorchannel_get_physaddr(dev->visorchannel) ==
+		    channel_physaddr)
+			return dev;
+	}
+	return NULL;
+}
+
+static int
+init_vbus_channel(struct visorchannel *chan)
+{
+	int rc = -1;
+	unsigned long allocated_bytes = visorchannel_get_nbytes(chan);
+	struct spar_vbus_channel_protocol *x =
+		kmalloc(sizeof(struct spar_vbus_channel_protocol),
+			GFP_KERNEL);
+
+	POSTCODE_LINUX_3(VBUS_CHANNEL_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
+
+	if (x) {
+		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
+		goto away;
+	}
+	if (visorchannel_clear(chan, 0, 0, allocated_bytes) < 0) {
+		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		goto away;
+	}
+	if (visorchannel_read
+	    (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
+		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		goto away;
+	}
+	if (!SPAR_VBUS_CHANNEL_OK_SERVER(allocated_bytes)) {
+		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		goto away;
+	}
+
+	if (visorchannel_write
+	    (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
+		POSTCODE_LINUX_3(VBUS_CHANNEL_FAILURE_PC, chan,
+				 POSTCODE_SEVERITY_ERR);
+		goto away;
+	}
+
+	POSTCODE_LINUX_3(VBUS_CHANNEL_EXIT_PC, chan, POSTCODE_SEVERITY_INFO);
+	rc = 0;
+
+away:
+	kfree(x);
+	x = NULL;
+	return rc;
+}
+
+static int
+get_vbus_header_info(struct visorchannel *chan,
+		     struct spar_vbus_headerinfo *hdr_info)
+{
+	int rc = -1;
+
+	if (!SPAR_VBUS_CHANNEL_OK_CLIENT(visorchannel_get_header(chan)))
+		goto away;
+	if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info,
+			      sizeof(*hdr_info)) < 0) {
+		goto away;
+	}
+	if (hdr_info->struct_bytes < sizeof(struct spar_vbus_headerinfo))
+		goto away;
+	if (hdr_info->device_info_struct_bytes <
+	    sizeof(struct ultra_vbus_deviceinfo)) {
+		goto away;
+	}
+	rc = 0;
+away:
+	return rc;
+}
+
+/* Write the contents of <info> to the struct
+ * spar_vbus_channel_protocol.chp_info. */
+
+static int
+write_vbus_chp_info(struct visorchannel *chan,
+		    struct spar_vbus_headerinfo *hdr_info,
+		    struct ultra_vbus_deviceinfo *info)
+{
+	int off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
+
+	if (hdr_info->chp_info_offset == 0)
+			return -1;
+
+	if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+			return -1;
+	return 0;
+}
+
+/* Write the contents of <info> to the struct
+ * spar_vbus_channel_protocol.bus_info. */
+
+static int
+write_vbus_bus_info(struct visorchannel *chan,
+		    struct spar_vbus_headerinfo *hdr_info,
+		    struct ultra_vbus_deviceinfo *info)
+{
+	int off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
+
+	if (hdr_info->bus_info_offset == 0)
+			return -1;
+
+	if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+			return -1;
+	return 0;
+}
+
+/* Write the contents of <info> to the
+ * struct spar_vbus_channel_protocol.dev_info[<devix>].
+ */
+static int
+write_vbus_dev_info(struct visorchannel *chan,
+		    struct spar_vbus_headerinfo *hdr_info,
+		    struct ultra_vbus_deviceinfo *info, int devix)
+{
+	int off =
+	    (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
+	    (hdr_info->device_info_struct_bytes * devix);
+
+	if (hdr_info->dev_info_offset == 0)
+			return -1;
+
+	if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+			return -1;
+	return 0;
+}
+
+/* For a child device just created on a client bus, fill in
+ * information about the driver that is controlling this device into
+ * the the appropriate slot within the vbus channel of the bus
+ * instance.
+ */
+static void
+fix_vbus_dev_info(struct visor_device *visordev)
+{
+	int i;
+	struct visorchipset_bus_info bus_info;
+	struct visorbus_devdata *devdata = NULL;
+	struct visor_driver *visordrv;
+	int bus_no = visordev->chipset_bus_no;
+	int dev_no = visordev->chipset_dev_no;
+	struct ultra_vbus_deviceinfo dev_info;
+	const char *chan_type_name = NULL;
+
+	if (!visordev->device.driver)
+			return;
+
+	visordrv = to_visor_driver(visordev->device.driver);
+	if (!visorchipset_get_bus_info(bus_no, &bus_info))
+			return;
+
+	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+	if (!devdata)
+			return;
+
+	if (!devdata->vbus_valid)
+			return;
+
+	/* Within the list of device types (by GUID) that the driver
+	 * says it supports, find out which one of those types matches
+	 * the type of this device, so that we can include the device
+	 * type name
+	 */
+	for (i = 0; visordrv->channel_types[i].name; i++) {
+		if (STRUCTSEQUAL(visordrv->channel_types[i].guid,
+				 visordev->channel_type_guid)) {
+			chan_type_name = visordrv->channel_types[i].name;
+			break;
+		}
+	}
+
+	bus_device_info_init(&dev_info, chan_type_name,
+			     visordrv->name, visordrv->version,
+			     visordrv->vertag);
+	write_vbus_dev_info(devdata->chan,
+			    &devdata->vbus_hdr_info, &dev_info, dev_no);
+
+	/* Re-write bus+chipset info, because it is possible that this
+	* was previously written by our evil counterpart, virtpci.
+	*/
+	write_vbus_chp_info(devdata->chan, &devdata->vbus_hdr_info,
+			    &chipset_driverinfo);
+	write_vbus_bus_info(devdata->chan, &devdata->vbus_hdr_info,
+			    &clientbus_driverinfo);
+}
+
+/** Create a device instance for the visor bus itself.
+ */
+static struct visorbus_devdata *
+create_bus_instance(int id)
+{
+	struct visorbus_devdata *rc = NULL;
+	struct visorbus_devdata *devdata = NULL;
+	struct device *dev;
+	struct visorchipset_bus_info bus_info;
+
+	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev) {
+		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
+		rc = NULL;
+		goto away;
+	}
+	memset(dev, 0, sizeof(struct device));
+	dev_set_name(dev, "visorbus%d", id);
+	dev->release = visorbus_release_busdevice;
+	if (device_register(dev) < 0) {
+		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
+				 POSTCODE_SEVERITY_ERR);
+		rc = NULL;
+		goto away;
+	}
+	devdata = kmalloc(sizeof(*devdata), GFP_KERNEL);
+	if (!devdata) {
+		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
+		rc = NULL;
+		goto away;
+	}
+	memset(devdata, 0, sizeof(struct visorbus_devdata));
+	devdata->devno = id;
+	devdata->dev = dev;
+	if ((visorchipset_get_bus_info(id, &bus_info)) &&
+	    (bus_info.chan_info.channel_addr > 0) &&
+	    (bus_info.chan_info.n_channel_bytes > 0)) {
+		HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr;
+		unsigned long n_channel_bytes =
+				(unsigned long)
+				bus_info.chan_info.n_channel_bytes;
+		uuid_le channel_type_guid =
+				bus_info.chan_info.channel_type_uuid;
+
+		devdata->chan = visorchannel_create(channel_addr,
+						    n_channel_bytes,
+						    channel_type_guid);
+		if (!devdata->chan) {
+			POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr,
+					 POSTCODE_SEVERITY_ERR);
+		} else {
+			if (bus_info.flags.server) {
+				init_vbus_channel(devdata->chan);
+			} else {
+				if (get_vbus_header_info(devdata->chan,
+							 &devdata->
+							 vbus_hdr_info) >= 0) {
+					devdata->vbus_valid = TRUE;
+					write_vbus_chp_info(devdata->chan,
+							    &devdata->
+							    vbus_hdr_info,
+							    &chipset_driverinfo
+							    );
+					write_vbus_bus_info(devdata->chan,
+							    &devdata->
+								vbus_hdr_info,
+							&clientbus_driverinfo);
+				}
+			}
+		}
+	}
+	register_businst_attributes(devdata);
+	bus_count++;
+	list_add_tail(&devdata->list_all, &list_all_bus_instances);
+	if (id == 0)
+			devdata = devdata;	/* for testing ONLY */
+	dev_set_drvdata(dev, devdata);
+	rc = devdata;
+away:
+	return rc;
+}
+
+/** Remove a device instance for the visor bus itself.
+ */
+static void
+remove_bus_instance(struct visorbus_devdata *devdata)
+{
+	/* Note that this will result in the release method for
+	 * devdata->dev being called, which will call
+	 * visorbus_release_busdevice().  This has something to do with
+	 * the put_device() done in device_unregister(), but I have never
+	 * successfully been able to trace thru the code to see where/how
+	 * release() gets called.  But I know it does.
+	 */
+	unregister_businst_attributes(devdata);
+	bus_count--;
+	if (devdata->chan) {
+		visorchannel_destroy(devdata->chan);
+		devdata->chan = NULL;
+	}
+	list_del(&devdata->list_all);
+	device_unregister(devdata->dev);
+}
+
+/** Create and register the one-and-only one instance of
+ *  the visor bus type (visorbus_type).
+ */
+static int
+create_bus_type(void)
+{
+	int rc = 0;
+
+	visorbus_type.dev_attrs = visor_device_attrs;
+	rc = bus_register(&visorbus_type);
+	if (rc < 0)
+			return rc;
+
+	rc = register_bustype_attributes();
+	return rc;
+}
+
+/** Remove the one-and-only one instance of the visor bus type (visorbus_type).
+ */
+static void
+remove_bus_type(void)
+{
+	unregister_bustype_attributes();
+	bus_unregister(&visorbus_type);
+}
+
+/** Remove all child visor bus device instances.
+ */
+static void
+remove_all_visor_devices(void)
+{
+	struct list_head *listentry, *listtmp;
+
+	list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
+		struct visor_device *dev = list_entry(listentry,
+						      struct visor_device,
+						      list_all);
+		remove_visor_device(dev);
+	}
+}
+
+static bool entered_testing_mode = FALSE;
+static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST];
+static unsigned long test_bus_nos[MAXDEVICETEST];
+static unsigned long test_dev_nos[MAXDEVICETEST];
+
+static void
+chipset_bus_create(u32 bus_no)
+{
+	struct visorchipset_bus_info bus_info;
+	struct visorbus_devdata *devdata;
+	int rc = -1;
+
+	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
+	if (!visorchipset_get_bus_info(bus_no, &bus_info))
+		goto away;
+	devdata = create_bus_instance(bus_no);
+	if (!devdata)
+		goto away;
+	if (!visorchipset_set_bus_context(bus_no, devdata))
+		goto away;
+	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
+	rc = 0;
+away:
+	if (rc < 0) {
+		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+	POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+	if (chipset_responders.bus_create)
+		(*chipset_responders.bus_create) (bus_no, rc);
+}
+
+static void
+chipset_bus_destroy(u32 bus_no)
+{
+	struct visorchipset_bus_info bus_info;
+	struct visorbus_devdata *devdata;
+	int rc = -1;
+
+	if (!visorchipset_get_bus_info(bus_no, &bus_info))
+		goto away;
+	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+	if (!devdata)
+		goto away;
+	remove_bus_instance(devdata);
+	if (!visorchipset_set_bus_context(bus_no, NULL))
+		goto away;
+	rc = 0;
+away:
+	if (rc < 0)
+		return;
+	if (chipset_responders.bus_destroy)
+		(*chipset_responders.bus_destroy)(bus_no, rc);
+}
+
+static void
+chipset_device_create(u32 bus_no, u32 dev_no)
+{
+	struct visorchipset_device_info dev_info;
+	struct visorchipset_bus_info bus_info;
+	struct visorbus_devdata *devdata = NULL;
+	int rc = -1;
+
+	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+
+	if (entered_testing_mode)
+		return;
+	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
+		goto away;
+	if (!visorchipset_get_bus_info(bus_no, &bus_info))
+		goto away;
+	if (visorbus_devicetest)
+		if (total_devices_created < MAXDEVICETEST) {
+			test_channel_infos[total_devices_created] =
+			    dev_info.chan_info;
+			test_bus_nos[total_devices_created] = bus_no;
+			test_dev_nos[total_devices_created] = dev_no;
+		}
+	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+	rc = 0;
+away:
+	if (rc < 0) {
+		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+	rc = create_visor_device(devdata, bus_no, dev_no,
+				 dev_info.chan_info, bus_info.partition_handle);
+	POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+	if (rc < 0)
+		if (chipset_responders.device_create)
+			(*chipset_responders.device_create)(bus_no, dev_no, rc);
+}
+
+static void
+chipset_device_destroy(u32 bus_no, u32 dev_no)
+{
+	struct visorchipset_device_info dev_info;
+	struct visor_device *dev;
+	int rc = -1;
+
+	if (entered_testing_mode)
+		return;
+	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
+		goto away;
+	dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
+	if (!dev)
+		goto away;
+	rc = 0;
+away:
+	if (rc < 0)
+			return;
+
+	if (chipset_responders.device_destroy)
+		(*chipset_responders.device_destroy) (bus_no, dev_no, rc);
+	remove_visor_device(dev);
+}
+
+/* This is the callback function specified for a function driver, to
+ * be called when a pending "pause device" operation has been
+ * completed.
+ */
+static void
+pause_state_change_complete(struct visor_device *dev, int status)
+{
+	if (!dev->pausing)
+			return;
+
+	dev->pausing = FALSE;
+	if (!chipset_responders.device_pause) /* this can never happen! */
+			return;
+
+	/* Notify the chipset driver that the pause is complete, which
+	* will presumably want to send some sort of response to the
+	* initiator. */
+	(*chipset_responders.device_pause) (dev->chipset_bus_no,
+					    dev->chipset_dev_no, status);
+}
+
+/* This is the callback function specified for a function driver, to
+ * be called when a pending "resume device" operation has been
+ * completed.
+ */
+static void
+resume_state_change_complete(struct visor_device *dev, int status)
+{
+	if (!dev->resuming)
+			return;
+
+	dev->resuming = FALSE;
+	if (!chipset_responders.device_resume) /* this can never happen! */
+			return;
+
+	/* Notify the chipset driver that the resume is complete,
+	 * which will presumably want to send some sort of response to
+	 * the initiator. */
+	(*chipset_responders.device_resume) (dev->chipset_bus_no,
+					     dev->chipset_dev_no, status);
+}
+
+/* Tell the subordinate function driver for a specific device to pause
+ * or resume that device.  Result is returned asynchronously via a
+ * callback function.
+ */
+static void
+initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
+{
+	struct visorchipset_device_info dev_info;
+	struct visor_device *dev = NULL;
+	int rc = -1, x;
+	struct visor_driver *drv = NULL;
+	void (*notify_func)(u32 bus_no, u32 dev_no, int response) = NULL;
+
+	if (is_pause)
+		notify_func = chipset_responders.device_pause;
+	else
+		notify_func = chipset_responders.device_resume;
+	if (!notify_func)
+			goto away;
+
+	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
+			goto away;
+
+	dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
+	if (!dev)
+			goto away;
+
+	drv = to_visor_driver(dev->device.driver);
+	if (!drv)
+			goto away;
+
+	if (dev->pausing || dev->resuming)
+			goto away;
+
+	/* Note that even though both drv->pause() and drv->resume
+	 * specify a callback function, it is NOT necessary for us to
+	 * increment our local module usage count.  Reason is, there
+	 * is already a linkage dependency between child function
+	 * drivers and visorbus, so it is already IMPOSSIBLE to unload
+	 * visorbus while child function drivers are still running.
+	 */
+	if (is_pause) {
+		if (!drv->pause)
+				goto away;
+
+		dev->pausing = TRUE;
+		x = drv->pause(dev, pause_state_change_complete);
+	} else {
+		/* This should be done at BUS resume time, but an
+		 * existing problem prevents us from ever getting a bus
+		 * resume...  This hack would fail to work should we
+		 * ever have a bus that contains NO devices, since we
+		 * would never even get here in that case. */
+		fix_vbus_dev_info(dev);
+		if (!drv->resume)
+				goto away;
+
+		dev->resuming = TRUE;
+		x = drv->resume(dev, resume_state_change_complete);
+	}
+	if (x < 0) {
+		if (is_pause)
+			dev->pausing = FALSE;
+		else
+			dev->resuming = FALSE;
+		goto away;
+	}
+	rc = 0;
+away:
+	if (rc < 0) {
+		if (notify_func)
+				(*notify_func)(bus_no, dev_no, rc);
+	}
+}
+
+static void
+chipset_device_pause(u32 bus_no, u32 dev_no)
+{
+	initiate_chipset_device_pause_resume(bus_no, dev_no, TRUE);
+}
+
+static void
+chipset_device_resume(u32 bus_no, u32 dev_no)
+{
+	initiate_chipset_device_pause_resume(bus_no, dev_no, FALSE);
+}
+
+struct channel_size_info {
+	uuid_le guid;
+	unsigned long min_size;
+	unsigned long max_size;
+};
+
+static int __init
+visorbus_init(void)
+{
+	int rc = 0;
+
+	POSTCODE_LINUX_3(DRIVER_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
+	bus_device_info_init(&clientbus_driverinfo,
+			     "clientbus", MYDRVNAME,
+			     VERSION, NULL);
+
+	/* process module options */
+
+	if (visorbus_devicetest > MAXDEVICETEST)
+			visorbus_devicetest = MAXDEVICETEST;
+
+	rc = create_bus_type();
+	if (rc < 0) {
+		POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, DIAG_SEVERITY_ERR);
+		goto away;
+	}
+
+	periodic_dev_workqueue = create_singlethread_workqueue("visorbus_dev");
+	if (!periodic_dev_workqueue) {
+		POSTCODE_LINUX_2(CREATE_WORKQUEUE_PC, DIAG_SEVERITY_ERR);
+		rc = -ENOMEM;
+		goto away;
+	}
+
+	/* This enables us to receive notifications when devices appear for
+	 * which this service partition is to be a server for.
+	 */
+	visorchipset_register_busdev_server(&chipset_notifiers,
+					    &chipset_responders,
+					    &chipset_driverinfo);
+
+	rc = 0;
+
+away:
+	if (rc)
+			POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
+					 POSTCODE_SEVERITY_ERR);
+	return rc;
+}
+
+static void
+visorbus_exit(void)
+{
+	struct list_head *listentry, *listtmp;
+
+	visorchipset_register_busdev_server(NULL, NULL, NULL);
+	remove_all_visor_devices();
+
+	flush_workqueue(periodic_dev_workqueue); /* better not be any work! */
+	destroy_workqueue(periodic_dev_workqueue);
+	periodic_dev_workqueue = NULL;
+
+	if (periodic_test_workqueue) {
+		cancel_delayed_work(&periodic_work);
+		flush_workqueue(periodic_test_workqueue);
+		destroy_workqueue(periodic_test_workqueue);
+		periodic_test_workqueue = NULL;
+	}
+
+	list_for_each_safe(listentry, listtmp, &list_all_bus_instances) {
+		struct visorbus_devdata *devdata = list_entry(listentry,
+							      struct
+							      visorbus_devdata,
+							      list_all);
+		remove_bus_instance(devdata);
+	}
+	remove_bus_type();
+}
+
+module_param_named(debug, visorbus_debug, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_debug, "1 to debug");
+int visorbus_debug = 0;
+
+module_param_named(forcematch, visorbus_forcematch, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_forcematch,
+		 "1 to force a successful dev <--> drv match");
+int visorbus_forcematch = 0;
+
+module_param_named(forcenomatch, visorbus_forcenomatch, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_forcenomatch,
+		 "1 to force an UNsuccessful dev <--> drv match");
+int visorbus_forcenomatch = 0;
+
+module_param_named(devicetest, visorbus_devicetest, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_devicetest,
+		 "non-0 to just test device creation and destruction");
+int visorbus_devicetest = 0;
+
+module_param_named(debugref, visorbus_debugref, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting");
+int visorbus_debugref = 0;
+
+module_param_named(serialloopbacktest, visorbus_serialloopbacktest,
+		   int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_serialloopbacktest,
+		 "non-0 to just create 2 serial devices on the same channel");
+int visorbus_serialloopbacktest = 0;
+
+module_init(visorbus_init);
+module_exit(visorbus_exit);
+
+MODULE_AUTHOR("Unisys");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION);
+MODULE_VERSION(VERSION);
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
new file mode 100644
index 0000000..2b61312
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -0,0 +1,50 @@
+/* visorbus_private.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VISORBUS_PRIVATE_H__
+#define __VISORBUS_PRIVATE_H__
+
+#include "timskmod.h"
+#include "visorbus.h"
+#include "visorchipset.h"
+#include "visorchannel.h"
+#include "version.h"
+#include "vbuschannel.h"
+
+/* module parameters */
+extern int visorbus_debug;
+extern int visorbus_forcematch;
+extern int visorbus_forcenomatch;
+#define MAXDEVICETEST 4
+extern int visorbus_devicetest;
+extern int visorbus_debugref;
+extern int visorbus_serialloopbacktest;
+#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
+
+/** This is the private data that we store for each bus device instance.
+ */
+struct visorbus_devdata {
+	int devno;		/* this is the chipset busNo */
+	struct list_head list_all;
+	struct device *dev;
+	struct kobject kobj;
+	struct visorchannel *chan;	/* channel area for bus itself */
+	bool vbus_valid;
+	struct spar_vbus_headerinfo vbus_hdr_info;
+};
+
+#endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 024/141] staging: unisys: Move visorchannel into visorbus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (22 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 023/141] staging: unisys: add visorbus driver Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-06 10:00   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 025/141] staging: unisys: Dissolve visorchannel.h Benjamin Romer
                   ` (119 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

visorchannel seems to be a necessary component to visorbus and can never
function as a standalone module.  Let's treat it like a visorbus feature
that is always enabled.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Kconfig                     |   1 -
 drivers/staging/unisys/Makefile                    |   1 -
 drivers/staging/unisys/visorbus/Kconfig            |   3 +-
 drivers/staging/unisys/visorbus/Makefile           |   2 +-
 drivers/staging/unisys/visorbus/globals.h          |  27 +
 drivers/staging/unisys/visorbus/visorchannel.h     |  76 +++
 .../staging/unisys/visorbus/visorchannel_funcs.c   | 663 +++++++++++++++++++++
 drivers/staging/unisys/visorchannel/visorchannel.h |  76 ---
 .../unisys/visorchannel/visorchannel_funcs.c       | 663 ---------------------
 drivers/staging/unisys/visorchipset/Kconfig        |   1 +
 drivers/staging/unisys/visorchipset/Makefile       |   2 +-
 11 files changed, 770 insertions(+), 745 deletions(-)
 create mode 100644 drivers/staging/unisys/visorbus/globals.h
 create mode 100644 drivers/staging/unisys/visorbus/visorchannel.h
 create mode 100644 drivers/staging/unisys/visorbus/visorchannel_funcs.c
 delete mode 100644 drivers/staging/unisys/visorchannel/visorchannel.h
 delete mode 100644 drivers/staging/unisys/visorchannel/visorchannel_funcs.c

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index 8d056b5..dbdd449 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -10,7 +10,6 @@ menuconfig UNISYSSPAR
 if UNISYSSPAR
 
 source "drivers/staging/unisys/visorutil/Kconfig"
-source "drivers/staging/unisys/visorchannel/Kconfig"
 source "drivers/staging/unisys/visorchipset/Kconfig"
 source "drivers/staging/unisys/visorbus/Kconfig"
 
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index 1ed9d39..b14a477 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -2,6 +2,5 @@
 # Makefile for Unisys SPAR drivers
 #
 obj-$(CONFIG_UNISYS_VISORUTIL)		+= visorutil/
-obj-$(CONFIG_UNISYS_VISORCHANNEL)	+= visorchannel/
 obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset/
 obj-$(CONFIG_UNISYS_VISORBUS)		+= visorbus/
diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig
index 0141528..12cf8f0 100644
--- a/drivers/staging/unisys/visorbus/Kconfig
+++ b/drivers/staging/unisys/visorbus/Kconfig
@@ -4,7 +4,6 @@
 
 config UNISYS_VISORBUS
 	tristate "Unisys visorbus driver"
-	depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && UNISYS_VISORCHIPSET
+	depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHIPSET
 	---help---
 	If you say Y here, you will enable the Unisys visorbus driver.
-
diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 60bb96b..20d87da 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -5,9 +5,9 @@
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
 visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o
+visorbus-y	+= visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/visorchannel
 ccflags-y += -Idrivers/staging/unisys/visorchipset
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
 ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
diff --git a/drivers/staging/unisys/visorbus/globals.h b/drivers/staging/unisys/visorbus/globals.h
new file mode 100644
index 0000000..0ed8e1d
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/globals.h
@@ -0,0 +1,27 @@
+/* globals.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VISORCHANNEL_GLOBALS_H__
+#define __VISORCHANNEL_GLOBALS_H__
+
+#include "timskmod.h"
+#include "memregion.h"
+#include "version.h"
+
+#define MYDRVNAME "visorchannel"
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorchannel.h b/drivers/staging/unisys/visorbus/visorchannel.h
new file mode 100644
index 0000000..63f1b97
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorchannel.h
@@ -0,0 +1,76 @@
+/* visorchannel.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VISORCHANNEL_H__
+#define __VISORCHANNEL_H__
+
+#include <linux/uuid.h>
+
+#include "memregion.h"
+#include "channel.h"
+#ifndef HOSTADDRESS
+#define HOSTADDRESS u64
+#endif
+#ifndef BOOL
+#define BOOL int
+#endif
+
+/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
+ * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
+ * In this case, the values can simply be read from the channel header.
+ */
+struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
+					 ulong channel_bytes, uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
+						    struct visorchannel *parent,
+						    ulong off, uuid_le guid);
+struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
+						   ulong channel_bytes,
+						   uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped_with_lock(
+				ulong channel_bytes,
+				struct visorchannel *parent,
+				ulong off, uuid_le guid);
+void visorchannel_destroy(struct visorchannel *channel);
+int visorchannel_read(struct visorchannel *channel, ulong offset,
+		      void *local, ulong nbytes);
+int visorchannel_write(struct visorchannel *channel, ulong offset,
+		       void *local, ulong nbytes);
+int visorchannel_clear(struct visorchannel *channel, ulong offset,
+		       u8 ch, ulong nbytes);
+BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
+			       void *msg);
+BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
+			       void *msg);
+int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
+					 u32 queue);
+int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
+HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
+ulong visorchannel_get_nbytes(struct visorchannel *channel);
+char *visorchannel_id(struct visorchannel *channel, char *s);
+char *visorchannel_zoneid(struct visorchannel *channel, char *s);
+u64 visorchannel_get_clientpartition(struct visorchannel *channel);
+uuid_le visorchannel_get_uuid(struct visorchannel *channel);
+struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
+char *visorchannel_uuid_id(uuid_le *guid, char *s);
+void visorchannel_debug(struct visorchannel *channel, int num_queues,
+			struct seq_file *seq, u32 off);
+void visorchannel_dump_section(struct visorchannel *chan, char *s,
+			       int off, int len, struct seq_file *seq);
+void __iomem *visorchannel_get_header(struct visorchannel *channel);
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel_funcs.c
new file mode 100644
index 0000000..9ae5f75
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorchannel_funcs.c
@@ -0,0 +1,663 @@
+/* visorchannel_funcs.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ *  This provides Supervisor channel communication primitives, which are
+ *  independent of the mechanism used to access the channel data.  All channel
+ *  data is accessed using the memregion abstraction.  (memregion has both
+ *  a CM2 implementation and a direct memory implementation.)
+ */
+
+#include "globals.h"
+#include "visorchannel.h"
+#include <linux/uuid.h>
+
+#define MYDRVNAME "visorchannel"
+
+struct visorchannel {
+	struct memregion *memregion;	/* from visor_memregion_create() */
+	struct channel_header chan_hdr;
+	uuid_le guid;
+	ulong size;
+	BOOL needs_lock;	/* channel creator knows if more than one
+				 * thread will be inserting or removing */
+	spinlock_t insert_lock; /* protect head writes in chan_hdr */
+	spinlock_t remove_lock;	/* protect tail writes in chan_hdr */
+
+	struct {
+		struct signal_queue_header req_queue;
+		struct signal_queue_header rsp_queue;
+		struct signal_queue_header event_queue;
+		struct signal_queue_header ack_queue;
+	} safe_uis_queue;
+};
+
+/* Creates the struct visorchannel abstraction for a data area in memory,
+ * but does NOT modify this data area.
+ */
+static struct visorchannel *
+visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
+			 struct visorchannel *parent, ulong off, uuid_le guid,
+			 BOOL needs_lock)
+{
+	struct visorchannel *p = NULL;
+	void *rc = NULL;
+
+	p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
+	if (!p) {
+		rc = NULL;
+		goto cleanup;
+	}
+	p->memregion = NULL;
+	p->needs_lock = needs_lock;
+	spin_lock_init(&p->insert_lock);
+	spin_lock_init(&p->remove_lock);
+
+	/* prepare chan_hdr (abstraction to read/write channel memory) */
+	if (!parent)
+		p->memregion =
+		    visor_memregion_create(physaddr,
+					   sizeof(struct channel_header));
+	else
+		p->memregion =
+		    visor_memregion_create_overlapped(parent->memregion,
+				off, sizeof(struct channel_header));
+	if (!p->memregion) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
+				 sizeof(struct channel_header)) < 0) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (channel_bytes == 0)
+		/* we had better be a CLIENT of this channel */
+		channel_bytes = (ulong)p->chan_hdr.size;
+	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
+		/* we had better be a CLIENT of this channel */
+		guid = p->chan_hdr.chtype;
+	if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
+		rc = NULL;
+		goto cleanup;
+	}
+	p->size = channel_bytes;
+	p->guid = guid;
+
+	rc = p;
+cleanup:
+
+	if (!rc) {
+		if (!p) {
+			visorchannel_destroy(p);
+			p = NULL;
+		}
+	}
+	return rc;
+}
+
+struct visorchannel *
+visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
+{
+	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+					FALSE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create);
+
+struct visorchannel *
+visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
+			      uuid_le guid)
+{
+	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+					TRUE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
+
+struct visorchannel *
+visorchannel_create_overlapped(ulong channel_bytes,
+			       struct visorchannel *parent, ulong off,
+			       uuid_le guid)
+{
+	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
+					FALSE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
+
+struct visorchannel *
+visorchannel_create_overlapped_with_lock(ulong channel_bytes,
+					 struct visorchannel *parent, ulong off,
+					 uuid_le guid)
+{
+	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
+					TRUE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
+
+void
+visorchannel_destroy(struct visorchannel *channel)
+{
+	if (!channel)
+		return;
+	if (channel->memregion) {
+		visor_memregion_destroy(channel->memregion);
+		channel->memregion = NULL;
+	}
+	kfree(channel);
+}
+EXPORT_SYMBOL_GPL(visorchannel_destroy);
+
+HOSTADDRESS
+visorchannel_get_physaddr(struct visorchannel *channel)
+{
+	return visor_memregion_get_physaddr(channel->memregion);
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
+
+ulong
+visorchannel_get_nbytes(struct visorchannel *channel)
+{
+	return channel->size;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_nbytes);
+
+char *
+visorchannel_uuid_id(uuid_le *guid, char *s)
+{
+	sprintf(s, "%pUL", guid);
+	return s;
+}
+EXPORT_SYMBOL_GPL(visorchannel_uuid_id);
+
+char *
+visorchannel_id(struct visorchannel *channel, char *s)
+{
+	return visorchannel_uuid_id(&channel->guid, s);
+}
+EXPORT_SYMBOL_GPL(visorchannel_id);
+
+char *
+visorchannel_zoneid(struct visorchannel *channel, char *s)
+{
+	return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s);
+}
+EXPORT_SYMBOL_GPL(visorchannel_zoneid);
+
+HOSTADDRESS
+visorchannel_get_clientpartition(struct visorchannel *channel)
+{
+	return channel->chan_hdr.partition_handle;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
+
+uuid_le
+visorchannel_get_uuid(struct visorchannel *channel)
+{
+	return channel->guid;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
+
+struct memregion *
+visorchannel_get_memregion(struct visorchannel *channel)
+{
+	return channel->memregion;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
+
+int
+visorchannel_read(struct visorchannel *channel, ulong offset,
+		  void *local, ulong nbytes)
+{
+	int rc = visor_memregion_read(channel->memregion, offset,
+				      local, nbytes);
+	if ((rc >= 0) && (offset == 0) &&
+	    (nbytes >= sizeof(struct channel_header))) {
+		memcpy(&channel->chan_hdr, local,
+		       sizeof(struct channel_header));
+	}
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_read);
+
+int
+visorchannel_write(struct visorchannel *channel, ulong offset,
+		   void *local, ulong nbytes)
+{
+	if (offset == 0 && nbytes >= sizeof(struct channel_header))
+		memcpy(&channel->chan_hdr, local,
+		       sizeof(struct channel_header));
+	return visor_memregion_write(channel->memregion, offset, local, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorchannel_write);
+
+int
+visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
+		   ulong nbytes)
+{
+	int rc = -1;
+	int bufsize = 65536;
+	int written = 0;
+	u8 *buf = vmalloc(bufsize);
+
+	if (!buf)
+		goto cleanup;
+
+	memset(buf, ch, bufsize);
+	while (nbytes > 0) {
+		ulong thisbytes = bufsize;
+		int x = -1;
+
+		if (nbytes < thisbytes)
+			thisbytes = nbytes;
+		x = visor_memregion_write(channel->memregion, offset + written,
+					  buf, thisbytes);
+		if (x < 0) {
+			rc = x;
+			goto cleanup;
+		}
+		written += thisbytes;
+		nbytes -= thisbytes;
+	}
+	rc = 0;
+
+cleanup:
+	if (buf) {
+		vfree(buf);
+		buf = NULL;
+	}
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_clear);
+
+void __iomem  *
+visorchannel_get_header(struct visorchannel *channel)
+{
+	return (void __iomem *)&channel->chan_hdr;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_header);
+
+/** Return offset of a specific SIGNAL_QUEUE_HEADER from the beginning of a
+ *  channel header
+ */
+#define SIG_QUEUE_OFFSET(chan_hdr, q) \
+	((chan_hdr)->ch_space_offset + \
+	 ((q) * sizeof(struct signal_queue_header)))
+
+/** Return offset of a specific queue entry (data) from the beginning of a
+ *  channel header
+ */
+#define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
+	(SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
+	    ((slot) * (sig_hdr)->signal_size))
+
+/** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
+ *  into host memory
+ */
+#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
+	(visor_memregion_write(channel->memregion,			\
+			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
+			       offsetof(struct signal_queue_header, FIELD),\
+			       &((sig_hdr)->FIELD),			\
+			       sizeof((sig_hdr)->FIELD)) >= 0)
+
+static BOOL
+sig_read_header(struct visorchannel *channel, u32 queue,
+		struct signal_queue_header *sig_hdr)
+{
+	BOOL rc = FALSE;
+
+	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
+		goto cleanup;
+
+	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
+
+	if (visor_memregion_read(channel->memregion,
+				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+				 sig_hdr,
+				 sizeof(struct signal_queue_header)) < 0) {
+		goto cleanup;
+	}
+	rc = TRUE;
+cleanup:
+	return rc;
+}
+
+static BOOL
+sig_do_data(struct visorchannel *channel, u32 queue,
+	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
+	    BOOL is_write)
+{
+	BOOL rc = FALSE;
+	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+						 sig_hdr, slot);
+	if (is_write) {
+		if (visor_memregion_write(channel->memregion,
+					  signal_data_offset,
+					  data, sig_hdr->signal_size) < 0) {
+			goto cleanup;
+		}
+	} else {
+		if (visor_memregion_read(channel->memregion, signal_data_offset,
+					 data, sig_hdr->signal_size) < 0) {
+			goto cleanup;
+		}
+	}
+	rc = TRUE;
+cleanup:
+	return rc;
+}
+
+static inline BOOL
+sig_read_data(struct visorchannel *channel, u32 queue,
+	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
+{
+	return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
+}
+
+static inline BOOL
+sig_write_data(struct visorchannel *channel, u32 queue,
+	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
+{
+	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
+}
+
+static inline unsigned char
+safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
+			struct signal_queue_header *punsafe_sqh,
+			u32 *phead, u32 *ptail)
+{
+	if ((*phead >= psafe_sqh->max_slots) ||
+	    (*ptail >= psafe_sqh->max_slots)) {
+		/* Choose 0 or max, maybe based on current tail value */
+		*phead = 0;
+		*ptail = 0;
+
+		/* Sync with client as necessary */
+		punsafe_sqh->head = *phead;
+		punsafe_sqh->tail = *ptail;
+
+		return 0;
+	}
+	return 1;
+}				/* end safe_sig_queue_validate */
+
+static BOOL
+signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return FALSE;
+	if (sig_hdr.head == sig_hdr.tail)
+		return FALSE;	/* no signals to remove */
+
+	sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
+	if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
+		return FALSE;
+	sig_hdr.num_received++;
+
+	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
+	 * update host memory.
+	 */
+	mb(); /* required for channel synch */
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
+		return FALSE;
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
+		return FALSE;
+	return TRUE;
+}
+
+BOOL
+visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
+{
+	BOOL rc;
+
+	if (channel->needs_lock) {
+		spin_lock(&channel->remove_lock);
+		rc = signalremove_inner(channel, queue, msg);
+		spin_unlock(&channel->remove_lock);
+	} else {
+		rc = signalremove_inner(channel, queue, msg);
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalremove);
+
+static BOOL
+signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return FALSE;
+
+	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
+	if (sig_hdr.head == sig_hdr.tail) {
+		sig_hdr.num_overflows++;
+		visor_memregion_write(channel->memregion,
+				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
+						       queue) +
+				      offsetof(struct signal_queue_header,
+					       num_overflows),
+				      &(sig_hdr.num_overflows),
+				      sizeof(sig_hdr.num_overflows));
+		return FALSE;
+	}
+
+	if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
+		return FALSE;
+
+	sig_hdr.num_sent++;
+
+	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
+	 * update host memory.
+	 */
+	mb(); /* required for channel synch */
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
+		return FALSE;
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
+		return FALSE;
+
+	return TRUE;
+}
+
+BOOL
+visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
+{
+	BOOL rc;
+
+	if (channel->needs_lock) {
+		spin_lock(&channel->insert_lock);
+		rc = signalinsert_inner(channel, queue, msg);
+		spin_unlock(&channel->insert_lock);
+	} else {
+		rc = signalinsert_inner(channel, queue, msg);
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
+
+int
+visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue)
+{
+	struct signal_queue_header sig_hdr;
+	u32 slots_avail, slots_used;
+	u32 head, tail;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return 0;
+	head = sig_hdr.head;
+	tail = sig_hdr.tail;
+	if (head < tail)
+		head = head + sig_hdr.max_slots;
+	slots_used = (head - tail);
+	slots_avail = sig_hdr.max_signals - slots_used;
+	return (int)slots_avail;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
+
+int
+visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return 0;
+	return (int)sig_hdr.max_signals;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
+
+static void
+sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq)
+{
+	seq_printf(seq, "Signal Queue #%d\n", which);
+	seq_printf(seq, "   VersionId          = %lu\n", (ulong)q->version);
+	seq_printf(seq, "   Type               = %lu\n", (ulong)q->chtype);
+	seq_printf(seq, "   oSignalBase        = %llu\n",
+		   (long long)q->sig_base_offset);
+	seq_printf(seq, "   SignalSize         = %lu\n", (ulong)q->signal_size);
+	seq_printf(seq, "   MaxSignalSlots     = %lu\n",
+		   (ulong)q->max_slots);
+	seq_printf(seq, "   MaxSignals         = %lu\n", (ulong)q->max_signals);
+	seq_printf(seq, "   FeatureFlags       = %-16.16Lx\n",
+		   (long long)q->features);
+	seq_printf(seq, "   NumSignalsSent     = %llu\n",
+		   (long long)q->num_sent);
+	seq_printf(seq, "   NumSignalsReceived = %llu\n",
+		   (long long)q->num_received);
+	seq_printf(seq, "   NumOverflows       = %llu\n",
+		   (long long)q->num_overflows);
+	seq_printf(seq, "   Head               = %lu\n", (ulong)q->head);
+	seq_printf(seq, "   Tail               = %lu\n", (ulong)q->tail);
+}
+
+void
+visorchannel_debug(struct visorchannel *channel, int num_queues,
+		   struct seq_file *seq, u32 off)
+{
+	HOSTADDRESS addr = 0;
+	ulong nbytes = 0, nbytes_region = 0;
+	struct memregion *memregion = NULL;
+	struct channel_header hdr;
+	struct channel_header *phdr = &hdr;
+	int i = 0;
+	int errcode = 0;
+
+	if (!channel)
+		return;
+	memregion = channel->memregion;
+	if (!memregion)
+		return;
+
+	addr = visor_memregion_get_physaddr(memregion);
+	nbytes_region = visor_memregion_get_nbytes(memregion);
+	errcode = visorchannel_read(channel, off,
+				    phdr, sizeof(struct channel_header));
+	if (errcode < 0) {
+		seq_printf(seq,
+			   "Read of channel header failed with errcode=%d)\n",
+			   errcode);
+		if (off == 0) {
+			phdr = &channel->chan_hdr;
+			seq_puts(seq, "(following data may be stale)\n");
+		} else {
+			return;
+		}
+	}
+	nbytes = (ulong)(phdr->size);
+	seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n",
+		   addr + off, nbytes, nbytes_region);
+	seq_printf(seq, "Type            = %pUL\n", &phdr->chtype);
+	seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->zone_uuid);
+	seq_printf(seq, "Signature       = 0x%-16.16Lx\n",
+		   (long long)phdr->signature);
+	seq_printf(seq, "LegacyState     = %lu\n", (ulong)phdr->legacy_state);
+	seq_printf(seq, "SrvState        = %lu\n", (ulong)phdr->srv_state);
+	seq_printf(seq, "CliStateBoot    = %lu\n", (ulong)phdr->cli_state_boot);
+	seq_printf(seq, "CliStateOS      = %lu\n", (ulong)phdr->cli_state_os);
+	seq_printf(seq, "HeaderSize      = %lu\n", (ulong)phdr->header_size);
+	seq_printf(seq, "Size            = %llu\n", (long long)phdr->size);
+	seq_printf(seq, "Features        = 0x%-16.16llx\n",
+		   (long long)phdr->features);
+	seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n",
+		   (long long)phdr->partition_handle);
+	seq_printf(seq, "Handle          = 0x%-16.16llx\n",
+		   (long long)phdr->handle);
+	seq_printf(seq, "VersionId       = %lu\n", (ulong)phdr->version_id);
+	seq_printf(seq, "oChannelSpace   = %llu\n",
+		   (long long)phdr->ch_space_offset);
+	if ((phdr->ch_space_offset == 0) || (errcode < 0))
+		;
+	else
+		for (i = 0; i < num_queues; i++) {
+			struct signal_queue_header q;
+
+			errcode = visorchannel_read(channel,
+						    off +
+						    phdr->ch_space_offset +
+						    (i * sizeof(q)),
+						    &q, sizeof(q));
+			if (errcode < 0) {
+				seq_printf(seq,
+					   "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n",
+					   i, addr, errcode);
+				continue;
+			}
+			sigqueue_debug(&q, i, seq);
+		}
+	seq_printf(seq, "--- End   channel @0x%-16.16Lx for 0x%lx bytes ---\n",
+		   addr + off, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorchannel_debug);
+
+void
+visorchannel_dump_section(struct visorchannel *chan, char *s,
+			  int off, int len, struct seq_file *seq)
+{
+	char *buf, *tbuf, *fmtbuf;
+	int fmtbufsize = 0;
+	int i;
+	int errcode = 0;
+
+	fmtbufsize = 100 * COVQ(len, 16);
+	buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
+	if (!buf)
+		return;
+	fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
+	if (!fmtbuf)
+		goto fmt_failed;
+
+	errcode = visorchannel_read(chan, off, buf, len);
+	if (errcode < 0)
+		goto read_failed;
+	seq_printf(seq, "channel %s:\n", s);
+	tbuf = buf;
+	while (len > 0) {
+		i = (len < 16) ? len : 16;
+		hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
+		seq_printf(seq, "%s\n", fmtbuf);
+		tbuf += 16;
+		len -= 16;
+	}
+
+read_failed:
+	kfree(fmtbuf);
+fmt_failed:
+	kfree(buf);
+}
+EXPORT_SYMBOL_GPL(visorchannel_dump_section);
diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h
deleted file mode 100644
index 63f1b97..0000000
--- a/drivers/staging/unisys/visorchannel/visorchannel.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* visorchannel.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHANNEL_H__
-#define __VISORCHANNEL_H__
-
-#include <linux/uuid.h>
-
-#include "memregion.h"
-#include "channel.h"
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-#ifndef BOOL
-#define BOOL int
-#endif
-
-/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
- * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
- * In this case, the values can simply be read from the channel header.
- */
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
-					 ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
-						    struct visorchannel *parent,
-						    ulong off, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
-						   ulong channel_bytes,
-						   uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped_with_lock(
-				ulong channel_bytes,
-				struct visorchannel *parent,
-				ulong off, uuid_le guid);
-void visorchannel_destroy(struct visorchannel *channel);
-int visorchannel_read(struct visorchannel *channel, ulong offset,
-		      void *local, ulong nbytes);
-int visorchannel_write(struct visorchannel *channel, ulong offset,
-		       void *local, ulong nbytes);
-int visorchannel_clear(struct visorchannel *channel, ulong offset,
-		       u8 ch, ulong nbytes);
-BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
-			       void *msg);
-BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
-			       void *msg);
-int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
-					 u32 queue);
-int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
-ulong visorchannel_get_nbytes(struct visorchannel *channel);
-char *visorchannel_id(struct visorchannel *channel, char *s);
-char *visorchannel_zoneid(struct visorchannel *channel, char *s);
-u64 visorchannel_get_clientpartition(struct visorchannel *channel);
-uuid_le visorchannel_get_uuid(struct visorchannel *channel);
-struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
-char *visorchannel_uuid_id(uuid_le *guid, char *s);
-void visorchannel_debug(struct visorchannel *channel, int num_queues,
-			struct seq_file *seq, u32 off);
-void visorchannel_dump_section(struct visorchannel *chan, char *s,
-			       int off, int len, struct seq_file *seq);
-void __iomem *visorchannel_get_header(struct visorchannel *channel);
-
-#endif
diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
deleted file mode 100644
index 9ae5f75..0000000
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ /dev/null
@@ -1,663 +0,0 @@
-/* visorchannel_funcs.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  This provides Supervisor channel communication primitives, which are
- *  independent of the mechanism used to access the channel data.  All channel
- *  data is accessed using the memregion abstraction.  (memregion has both
- *  a CM2 implementation and a direct memory implementation.)
- */
-
-#include "globals.h"
-#include "visorchannel.h"
-#include <linux/uuid.h>
-
-#define MYDRVNAME "visorchannel"
-
-struct visorchannel {
-	struct memregion *memregion;	/* from visor_memregion_create() */
-	struct channel_header chan_hdr;
-	uuid_le guid;
-	ulong size;
-	BOOL needs_lock;	/* channel creator knows if more than one
-				 * thread will be inserting or removing */
-	spinlock_t insert_lock; /* protect head writes in chan_hdr */
-	spinlock_t remove_lock;	/* protect tail writes in chan_hdr */
-
-	struct {
-		struct signal_queue_header req_queue;
-		struct signal_queue_header rsp_queue;
-		struct signal_queue_header event_queue;
-		struct signal_queue_header ack_queue;
-	} safe_uis_queue;
-};
-
-/* Creates the struct visorchannel abstraction for a data area in memory,
- * but does NOT modify this data area.
- */
-static struct visorchannel *
-visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
-			 struct visorchannel *parent, ulong off, uuid_le guid,
-			 BOOL needs_lock)
-{
-	struct visorchannel *p = NULL;
-	void *rc = NULL;
-
-	p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
-	if (!p) {
-		rc = NULL;
-		goto cleanup;
-	}
-	p->memregion = NULL;
-	p->needs_lock = needs_lock;
-	spin_lock_init(&p->insert_lock);
-	spin_lock_init(&p->remove_lock);
-
-	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	if (!parent)
-		p->memregion =
-		    visor_memregion_create(physaddr,
-					   sizeof(struct channel_header));
-	else
-		p->memregion =
-		    visor_memregion_create_overlapped(parent->memregion,
-				off, sizeof(struct channel_header));
-	if (!p->memregion) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
-				 sizeof(struct channel_header)) < 0) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (channel_bytes == 0)
-		/* we had better be a CLIENT of this channel */
-		channel_bytes = (ulong)p->chan_hdr.size;
-	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
-		/* we had better be a CLIENT of this channel */
-		guid = p->chan_hdr.chtype;
-	if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
-		rc = NULL;
-		goto cleanup;
-	}
-	p->size = channel_bytes;
-	p->guid = guid;
-
-	rc = p;
-cleanup:
-
-	if (!rc) {
-		if (!p) {
-			visorchannel_destroy(p);
-			p = NULL;
-		}
-	}
-	return rc;
-}
-
-struct visorchannel *
-visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
-{
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
-					FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create);
-
-struct visorchannel *
-visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
-			      uuid_le guid)
-{
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
-					TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
-
-struct visorchannel *
-visorchannel_create_overlapped(ulong channel_bytes,
-			       struct visorchannel *parent, ulong off,
-			       uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
-
-struct visorchannel *
-visorchannel_create_overlapped_with_lock(ulong channel_bytes,
-					 struct visorchannel *parent, ulong off,
-					 uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
-
-void
-visorchannel_destroy(struct visorchannel *channel)
-{
-	if (!channel)
-		return;
-	if (channel->memregion) {
-		visor_memregion_destroy(channel->memregion);
-		channel->memregion = NULL;
-	}
-	kfree(channel);
-}
-EXPORT_SYMBOL_GPL(visorchannel_destroy);
-
-HOSTADDRESS
-visorchannel_get_physaddr(struct visorchannel *channel)
-{
-	return visor_memregion_get_physaddr(channel->memregion);
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
-
-ulong
-visorchannel_get_nbytes(struct visorchannel *channel)
-{
-	return channel->size;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_nbytes);
-
-char *
-visorchannel_uuid_id(uuid_le *guid, char *s)
-{
-	sprintf(s, "%pUL", guid);
-	return s;
-}
-EXPORT_SYMBOL_GPL(visorchannel_uuid_id);
-
-char *
-visorchannel_id(struct visorchannel *channel, char *s)
-{
-	return visorchannel_uuid_id(&channel->guid, s);
-}
-EXPORT_SYMBOL_GPL(visorchannel_id);
-
-char *
-visorchannel_zoneid(struct visorchannel *channel, char *s)
-{
-	return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s);
-}
-EXPORT_SYMBOL_GPL(visorchannel_zoneid);
-
-HOSTADDRESS
-visorchannel_get_clientpartition(struct visorchannel *channel)
-{
-	return channel->chan_hdr.partition_handle;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
-
-uuid_le
-visorchannel_get_uuid(struct visorchannel *channel)
-{
-	return channel->guid;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
-
-struct memregion *
-visorchannel_get_memregion(struct visorchannel *channel)
-{
-	return channel->memregion;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
-
-int
-visorchannel_read(struct visorchannel *channel, ulong offset,
-		  void *local, ulong nbytes)
-{
-	int rc = visor_memregion_read(channel->memregion, offset,
-				      local, nbytes);
-	if ((rc >= 0) && (offset == 0) &&
-	    (nbytes >= sizeof(struct channel_header))) {
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
-	}
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_read);
-
-int
-visorchannel_write(struct visorchannel *channel, ulong offset,
-		   void *local, ulong nbytes)
-{
-	if (offset == 0 && nbytes >= sizeof(struct channel_header))
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
-	return visor_memregion_write(channel->memregion, offset, local, nbytes);
-}
-EXPORT_SYMBOL_GPL(visorchannel_write);
-
-int
-visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
-		   ulong nbytes)
-{
-	int rc = -1;
-	int bufsize = 65536;
-	int written = 0;
-	u8 *buf = vmalloc(bufsize);
-
-	if (!buf)
-		goto cleanup;
-
-	memset(buf, ch, bufsize);
-	while (nbytes > 0) {
-		ulong thisbytes = bufsize;
-		int x = -1;
-
-		if (nbytes < thisbytes)
-			thisbytes = nbytes;
-		x = visor_memregion_write(channel->memregion, offset + written,
-					  buf, thisbytes);
-		if (x < 0) {
-			rc = x;
-			goto cleanup;
-		}
-		written += thisbytes;
-		nbytes -= thisbytes;
-	}
-	rc = 0;
-
-cleanup:
-	if (buf) {
-		vfree(buf);
-		buf = NULL;
-	}
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_clear);
-
-void __iomem  *
-visorchannel_get_header(struct visorchannel *channel)
-{
-	return (void __iomem *)&channel->chan_hdr;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_header);
-
-/** Return offset of a specific SIGNAL_QUEUE_HEADER from the beginning of a
- *  channel header
- */
-#define SIG_QUEUE_OFFSET(chan_hdr, q) \
-	((chan_hdr)->ch_space_offset + \
-	 ((q) * sizeof(struct signal_queue_header)))
-
-/** Return offset of a specific queue entry (data) from the beginning of a
- *  channel header
- */
-#define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
-	(SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
-	    ((slot) * (sig_hdr)->signal_size))
-
-/** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
- *  into host memory
- */
-#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
-	(visor_memregion_write(channel->memregion,			\
-			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
-			       offsetof(struct signal_queue_header, FIELD),\
-			       &((sig_hdr)->FIELD),			\
-			       sizeof((sig_hdr)->FIELD)) >= 0)
-
-static BOOL
-sig_read_header(struct visorchannel *channel, u32 queue,
-		struct signal_queue_header *sig_hdr)
-{
-	BOOL rc = FALSE;
-
-	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
-		goto cleanup;
-
-	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
-
-	if (visor_memregion_read(channel->memregion,
-				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
-				 sig_hdr,
-				 sizeof(struct signal_queue_header)) < 0) {
-		goto cleanup;
-	}
-	rc = TRUE;
-cleanup:
-	return rc;
-}
-
-static BOOL
-sig_do_data(struct visorchannel *channel, u32 queue,
-	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
-	    BOOL is_write)
-{
-	BOOL rc = FALSE;
-	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
-						 sig_hdr, slot);
-	if (is_write) {
-		if (visor_memregion_write(channel->memregion,
-					  signal_data_offset,
-					  data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
-	} else {
-		if (visor_memregion_read(channel->memregion, signal_data_offset,
-					 data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
-	}
-	rc = TRUE;
-cleanup:
-	return rc;
-}
-
-static inline BOOL
-sig_read_data(struct visorchannel *channel, u32 queue,
-	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
-	return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
-}
-
-static inline BOOL
-sig_write_data(struct visorchannel *channel, u32 queue,
-	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
-	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
-}
-
-static inline unsigned char
-safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
-			struct signal_queue_header *punsafe_sqh,
-			u32 *phead, u32 *ptail)
-{
-	if ((*phead >= psafe_sqh->max_slots) ||
-	    (*ptail >= psafe_sqh->max_slots)) {
-		/* Choose 0 or max, maybe based on current tail value */
-		*phead = 0;
-		*ptail = 0;
-
-		/* Sync with client as necessary */
-		punsafe_sqh->head = *phead;
-		punsafe_sqh->tail = *ptail;
-
-		return 0;
-	}
-	return 1;
-}				/* end safe_sig_queue_validate */
-
-static BOOL
-signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
-	if (sig_hdr.head == sig_hdr.tail)
-		return FALSE;	/* no signals to remove */
-
-	sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
-	if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
-		return FALSE;
-	sig_hdr.num_received++;
-
-	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
-	 * update host memory.
-	 */
-	mb(); /* required for channel synch */
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
-		return FALSE;
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
-		return FALSE;
-	return TRUE;
-}
-
-BOOL
-visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
-{
-	BOOL rc;
-
-	if (channel->needs_lock) {
-		spin_lock(&channel->remove_lock);
-		rc = signalremove_inner(channel, queue, msg);
-		spin_unlock(&channel->remove_lock);
-	} else {
-		rc = signalremove_inner(channel, queue, msg);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalremove);
-
-static BOOL
-signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
-
-	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
-	if (sig_hdr.head == sig_hdr.tail) {
-		sig_hdr.num_overflows++;
-		visor_memregion_write(channel->memregion,
-				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
-						       queue) +
-				      offsetof(struct signal_queue_header,
-					       num_overflows),
-				      &(sig_hdr.num_overflows),
-				      sizeof(sig_hdr.num_overflows));
-		return FALSE;
-	}
-
-	if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
-		return FALSE;
-
-	sig_hdr.num_sent++;
-
-	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
-	 * update host memory.
-	 */
-	mb(); /* required for channel synch */
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
-		return FALSE;
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
-		return FALSE;
-
-	return TRUE;
-}
-
-BOOL
-visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
-{
-	BOOL rc;
-
-	if (channel->needs_lock) {
-		spin_lock(&channel->insert_lock);
-		rc = signalinsert_inner(channel, queue, msg);
-		spin_unlock(&channel->insert_lock);
-	} else {
-		rc = signalinsert_inner(channel, queue, msg);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
-
-int
-visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue)
-{
-	struct signal_queue_header sig_hdr;
-	u32 slots_avail, slots_used;
-	u32 head, tail;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return 0;
-	head = sig_hdr.head;
-	tail = sig_hdr.tail;
-	if (head < tail)
-		head = head + sig_hdr.max_slots;
-	slots_used = (head - tail);
-	slots_avail = sig_hdr.max_signals - slots_used;
-	return (int)slots_avail;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
-
-int
-visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return 0;
-	return (int)sig_hdr.max_signals;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
-
-static void
-sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq)
-{
-	seq_printf(seq, "Signal Queue #%d\n", which);
-	seq_printf(seq, "   VersionId          = %lu\n", (ulong)q->version);
-	seq_printf(seq, "   Type               = %lu\n", (ulong)q->chtype);
-	seq_printf(seq, "   oSignalBase        = %llu\n",
-		   (long long)q->sig_base_offset);
-	seq_printf(seq, "   SignalSize         = %lu\n", (ulong)q->signal_size);
-	seq_printf(seq, "   MaxSignalSlots     = %lu\n",
-		   (ulong)q->max_slots);
-	seq_printf(seq, "   MaxSignals         = %lu\n", (ulong)q->max_signals);
-	seq_printf(seq, "   FeatureFlags       = %-16.16Lx\n",
-		   (long long)q->features);
-	seq_printf(seq, "   NumSignalsSent     = %llu\n",
-		   (long long)q->num_sent);
-	seq_printf(seq, "   NumSignalsReceived = %llu\n",
-		   (long long)q->num_received);
-	seq_printf(seq, "   NumOverflows       = %llu\n",
-		   (long long)q->num_overflows);
-	seq_printf(seq, "   Head               = %lu\n", (ulong)q->head);
-	seq_printf(seq, "   Tail               = %lu\n", (ulong)q->tail);
-}
-
-void
-visorchannel_debug(struct visorchannel *channel, int num_queues,
-		   struct seq_file *seq, u32 off)
-{
-	HOSTADDRESS addr = 0;
-	ulong nbytes = 0, nbytes_region = 0;
-	struct memregion *memregion = NULL;
-	struct channel_header hdr;
-	struct channel_header *phdr = &hdr;
-	int i = 0;
-	int errcode = 0;
-
-	if (!channel)
-		return;
-	memregion = channel->memregion;
-	if (!memregion)
-		return;
-
-	addr = visor_memregion_get_physaddr(memregion);
-	nbytes_region = visor_memregion_get_nbytes(memregion);
-	errcode = visorchannel_read(channel, off,
-				    phdr, sizeof(struct channel_header));
-	if (errcode < 0) {
-		seq_printf(seq,
-			   "Read of channel header failed with errcode=%d)\n",
-			   errcode);
-		if (off == 0) {
-			phdr = &channel->chan_hdr;
-			seq_puts(seq, "(following data may be stale)\n");
-		} else {
-			return;
-		}
-	}
-	nbytes = (ulong)(phdr->size);
-	seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n",
-		   addr + off, nbytes, nbytes_region);
-	seq_printf(seq, "Type            = %pUL\n", &phdr->chtype);
-	seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->zone_uuid);
-	seq_printf(seq, "Signature       = 0x%-16.16Lx\n",
-		   (long long)phdr->signature);
-	seq_printf(seq, "LegacyState     = %lu\n", (ulong)phdr->legacy_state);
-	seq_printf(seq, "SrvState        = %lu\n", (ulong)phdr->srv_state);
-	seq_printf(seq, "CliStateBoot    = %lu\n", (ulong)phdr->cli_state_boot);
-	seq_printf(seq, "CliStateOS      = %lu\n", (ulong)phdr->cli_state_os);
-	seq_printf(seq, "HeaderSize      = %lu\n", (ulong)phdr->header_size);
-	seq_printf(seq, "Size            = %llu\n", (long long)phdr->size);
-	seq_printf(seq, "Features        = 0x%-16.16llx\n",
-		   (long long)phdr->features);
-	seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n",
-		   (long long)phdr->partition_handle);
-	seq_printf(seq, "Handle          = 0x%-16.16llx\n",
-		   (long long)phdr->handle);
-	seq_printf(seq, "VersionId       = %lu\n", (ulong)phdr->version_id);
-	seq_printf(seq, "oChannelSpace   = %llu\n",
-		   (long long)phdr->ch_space_offset);
-	if ((phdr->ch_space_offset == 0) || (errcode < 0))
-		;
-	else
-		for (i = 0; i < num_queues; i++) {
-			struct signal_queue_header q;
-
-			errcode = visorchannel_read(channel,
-						    off +
-						    phdr->ch_space_offset +
-						    (i * sizeof(q)),
-						    &q, sizeof(q));
-			if (errcode < 0) {
-				seq_printf(seq,
-					   "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n",
-					   i, addr, errcode);
-				continue;
-			}
-			sigqueue_debug(&q, i, seq);
-		}
-	seq_printf(seq, "--- End   channel @0x%-16.16Lx for 0x%lx bytes ---\n",
-		   addr + off, nbytes);
-}
-EXPORT_SYMBOL_GPL(visorchannel_debug);
-
-void
-visorchannel_dump_section(struct visorchannel *chan, char *s,
-			  int off, int len, struct seq_file *seq)
-{
-	char *buf, *tbuf, *fmtbuf;
-	int fmtbufsize = 0;
-	int i;
-	int errcode = 0;
-
-	fmtbufsize = 100 * COVQ(len, 16);
-	buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
-	if (!buf)
-		return;
-	fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
-	if (!fmtbuf)
-		goto fmt_failed;
-
-	errcode = visorchannel_read(chan, off, buf, len);
-	if (errcode < 0)
-		goto read_failed;
-	seq_printf(seq, "channel %s:\n", s);
-	tbuf = buf;
-	while (len > 0) {
-		i = (len < 16) ? len : 16;
-		hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
-		seq_printf(seq, "%s\n", fmtbuf);
-		tbuf += 16;
-		len -= 16;
-	}
-
-read_failed:
-	kfree(fmtbuf);
-fmt_failed:
-	kfree(buf);
-}
-EXPORT_SYMBOL_GPL(visorchannel_dump_section);
diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig
index b03bfc5..2030592 100644
--- a/drivers/staging/unisys/visorchipset/Kconfig
+++ b/drivers/staging/unisys/visorchipset/Kconfig
@@ -6,6 +6,7 @@ config UNISYS_VISORCHIPSET
 	tristate "Unisys visorchipset driver"
 	select UNISYS_VISORUTIL
 	select UNISYS_VISORCHANNEL
+	select UNISYS_VISORBUS
 	---help---
 	If you say Y here, you will enable the Unisys visorchipset driver.
 
diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
index 1268690..1bf6699 100644
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ b/drivers/staging/unisys/visorchipset/Makefile
@@ -8,8 +8,8 @@ visorchipset-y := visorchipset_main.o file.o parser.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/visorchannel
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
 ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
 ccflags-y += -Idrivers/staging/unisys/visorutil
+ccflags-y += -Idrivers/staging/unisys/visorbus
 ccflags-y += -Iinclude/generated
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 025/141] staging: unisys: Dissolve visorchannel.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (23 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 024/141] staging: unisys: Move visorchannel into visorbus Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 026/141] staging: unisys: Move visorbus.h to public namespace Benjamin Romer
                   ` (118 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This header is needed by other drivers and should be in a global namespace.
In addition, functionally it is part of visorbus, so roll the contents
into that header file.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus.h         | 50 +++++++++++++-
 drivers/staging/unisys/visorbus/visorbus_private.h |  2 +-
 drivers/staging/unisys/visorbus/visorchannel.h     | 76 ----------------------
 .../staging/unisys/visorbus/visorchannel_funcs.c   |  2 +-
 drivers/staging/unisys/visorchipset/file.c         |  2 +-
 .../unisys/visorchipset/visorchipset_main.c        |  2 +-
 6 files changed, 53 insertions(+), 81 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/visorchannel.h

diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/visorbus/visorbus.h
index 856fa3f..3956a3d 100644
--- a/drivers/staging/unisys/visorbus/visorbus.h
+++ b/drivers/staging/unisys/visorbus/visorbus.h
@@ -35,8 +35,12 @@
 #include <linux/uuid.h>
 
 #include "periodic_work.h"
-#include "visorchannel.h"
 #include "channel.h"
+#include "memregion.h"
+
+#ifndef HOSTADDRESS
+#define HOSTADDRESS u64
+#endif
 
 struct visor_driver;
 struct visor_device;
@@ -163,4 +167,48 @@ void visorbus_enable_channel_interrupts(struct visor_device *dev);
 void visorbus_disable_channel_interrupts(struct visor_device *dev);
 #endif
 
+/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
+ * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
+ * In this case, the values can simply be read from the channel header.
+ */
+struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
+					 ulong channel_bytes, uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
+						    struct visorchannel *parent,
+						    ulong off, uuid_le guid);
+struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
+						   ulong channel_bytes,
+						   uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped_with_lock(
+				ulong channel_bytes,
+				struct visorchannel *parent,
+				ulong off, uuid_le guid);
+void visorchannel_destroy(struct visorchannel *channel);
+int visorchannel_read(struct visorchannel *channel, ulong offset,
+		      void *local, ulong nbytes);
+int visorchannel_write(struct visorchannel *channel, ulong offset,
+		       void *local, ulong nbytes);
+int visorchannel_clear(struct visorchannel *channel, ulong offset,
+		       u8 ch, ulong nbytes);
+BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
+			       void *msg);
+BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
+			       void *msg);
+int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
+					 u32 queue);
+int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
+HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
+ulong visorchannel_get_nbytes(struct visorchannel *channel);
+char *visorchannel_id(struct visorchannel *channel, char *s);
+char *visorchannel_zoneid(struct visorchannel *channel, char *s);
+u64 visorchannel_get_clientpartition(struct visorchannel *channel);
+uuid_le visorchannel_get_uuid(struct visorchannel *channel);
+struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
+char *visorchannel_uuid_id(uuid_le *guid, char *s);
+void visorchannel_debug(struct visorchannel *channel, int num_queues,
+			struct seq_file *seq, u32 off);
+void visorchannel_dump_section(struct visorchannel *chan, char *s,
+			       int off, int len, struct seq_file *seq);
+void __iomem *visorchannel_get_header(struct visorchannel *channel);
+
 #endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 2b61312..47ab488 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -21,7 +21,7 @@
 #include "timskmod.h"
 #include "visorbus.h"
 #include "visorchipset.h"
-#include "visorchannel.h"
+#include "visorbus.h"
 #include "version.h"
 #include "vbuschannel.h"
 
diff --git a/drivers/staging/unisys/visorbus/visorchannel.h b/drivers/staging/unisys/visorbus/visorchannel.h
deleted file mode 100644
index 63f1b97..0000000
--- a/drivers/staging/unisys/visorbus/visorchannel.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* visorchannel.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHANNEL_H__
-#define __VISORCHANNEL_H__
-
-#include <linux/uuid.h>
-
-#include "memregion.h"
-#include "channel.h"
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-#ifndef BOOL
-#define BOOL int
-#endif
-
-/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
- * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
- * In this case, the values can simply be read from the channel header.
- */
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
-					 ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
-						    struct visorchannel *parent,
-						    ulong off, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
-						   ulong channel_bytes,
-						   uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped_with_lock(
-				ulong channel_bytes,
-				struct visorchannel *parent,
-				ulong off, uuid_le guid);
-void visorchannel_destroy(struct visorchannel *channel);
-int visorchannel_read(struct visorchannel *channel, ulong offset,
-		      void *local, ulong nbytes);
-int visorchannel_write(struct visorchannel *channel, ulong offset,
-		       void *local, ulong nbytes);
-int visorchannel_clear(struct visorchannel *channel, ulong offset,
-		       u8 ch, ulong nbytes);
-BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
-			       void *msg);
-BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
-			       void *msg);
-int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
-					 u32 queue);
-int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
-ulong visorchannel_get_nbytes(struct visorchannel *channel);
-char *visorchannel_id(struct visorchannel *channel, char *s);
-char *visorchannel_zoneid(struct visorchannel *channel, char *s);
-u64 visorchannel_get_clientpartition(struct visorchannel *channel);
-uuid_le visorchannel_get_uuid(struct visorchannel *channel);
-struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
-char *visorchannel_uuid_id(uuid_le *guid, char *s);
-void visorchannel_debug(struct visorchannel *channel, int num_queues,
-			struct seq_file *seq, u32 off);
-void visorchannel_dump_section(struct visorchannel *chan, char *s,
-			       int off, int len, struct seq_file *seq);
-void __iomem *visorchannel_get_header(struct visorchannel *channel);
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel_funcs.c
index 9ae5f75..b61f954 100644
--- a/drivers/staging/unisys/visorbus/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorbus/visorchannel_funcs.c
@@ -23,7 +23,7 @@
  */
 
 #include "globals.h"
-#include "visorchannel.h"
+#include "visorbus.h"
 #include <linux/uuid.h>
 
 #define MYDRVNAME "visorchannel"
diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index a17027c..9822e9d 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -24,7 +24,7 @@
 #include "version.h"
 #include "visorchipset.h"
 #include "visorchipset_umode.h"
-#include "visorchannel.h"
+#include "visorbus.h"
 #include "uisutils.h"
 #include "file.h"
 
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 5ea6f9e..a8448c2 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -18,7 +18,7 @@
 #include "version.h"
 #include "visorchipset.h"
 #include "procobjecttree.h"
-#include "visorchannel.h"
+#include "visorbus.h"
 #include "periodic_work.h"
 #include "file.h"
 #include "parser.h"
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 026/141] staging: unisys: Move visorbus.h to public namespace
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (24 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 025/141] staging: unisys: Dissolve visorchannel.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 027/141] staging: unisys: Remove unused driver Benjamin Romer
                   ` (117 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Turn visorbus.h into a public header that all visor* drivers will
include.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h  | 214 +++++++++++++++++++++++++++++
 drivers/staging/unisys/visorbus/visorbus.h | 214 -----------------------------
 2 files changed, 214 insertions(+), 214 deletions(-)
 create mode 100644 drivers/staging/unisys/include/visorbus.h
 delete mode 100644 drivers/staging/unisys/visorbus/visorbus.h

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
new file mode 100644
index 0000000..3956a3d
--- /dev/null
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -0,0 +1,214 @@
+/* visorbus.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ *  This header file is to be included by other kernel mode components that
+ *  implement a particular kind of visor_device.  Each of these other kernel
+ *  mode components is called a visor device driver.  Refer to visortemplate
+ *  for a minimal sample visor device driver.
+ *
+ *  There should be nothing in this file that is private to the visorbus
+ *  bus implementation itself.
+ *
+ */
+
+#ifndef __VISORBUS_H__
+#define __VISORBUS_H__
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/uuid.h>
+
+#include "periodic_work.h"
+#include "channel.h"
+#include "memregion.h"
+
+#ifndef HOSTADDRESS
+#define HOSTADDRESS u64
+#endif
+
+struct visor_driver;
+struct visor_device;
+
+typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
+					      int status);
+
+/** This struct describes a specific Supervisor channel, by providing its
+ *  GUID, name, and sizes.
+ */
+struct visor_channeltype_descriptor {
+	const uuid_le guid;
+	const char *name;
+	unsigned long min_size;
+	unsigned long max_size;
+};
+
+/** Information provided by each visor driver when it registers with the
+ *  visorbus driver.
+ */
+struct visor_driver {
+	const char *name;
+	const char *version;
+	const char *vertag;
+	const char *build_date;
+	const char *build_time;
+	struct module *owner;
+
+	/** Types of channels handled by this driver, ending with 0 GUID.
+	 *  Our specialized BUS.match() method knows about this list, and
+	 *  uses it to determine whether this driver will in fact handle a
+	 *  new device that it has detected.
+	 */
+	struct visor_channeltype_descriptor *channel_types;
+
+	/** Called when a new device comes online, by our probe() function
+	 *  specified by driver.probe() (triggered ultimately by some call
+	 *  to driver_register() / bus_add_driver() / driver_attach()).
+	 */
+	int (*probe)(struct visor_device *dev);
+
+	/** Called when a new device is removed, by our remove() function
+	 *  specified by driver.remove() (triggered ultimately by some call
+	 *  to device_release_driver()).
+	 */
+	void (*remove)(struct visor_device *dev);
+
+	/** Called periodically, whenever there is a possibility that
+	 *  "something interesting" may have happened to the channel state.
+	 */
+	void (*channel_interrupt)(struct visor_device *dev);
+
+	/** Called to initiate a change of the device's state.  If the return
+	 *  valu`e is < 0, there was an error and the state transition will NOT
+	 *  occur.  If the return value is >= 0, then the state transition was
+	 *  INITIATED successfully, and complete_func() will be called (or was
+	 *  just called) with the final status when either the state transition
+	 *  fails or completes successfully.
+	 */
+	int (*pause)(struct visor_device *dev,
+		     visorbus_state_complete_func complete_func);
+	int (*resume)(struct visor_device *dev,
+		      visorbus_state_complete_func complete_func);
+
+	/** These fields are for private use by the bus driver only. */
+	struct device_driver driver;
+	struct driver_attribute version_attr;
+};
+
+#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
+
+/** A device type for things "plugged" into the visorbus bus */
+
+struct visor_device {
+	/** visor driver can use the visorchannel member with the functions
+	 *  defined in visorchannel.h to access the channel
+	 */
+	struct visorchannel *visorchannel;
+	uuid_le channel_type_guid;
+	u64 channel_bytes;
+
+	/** These fields are for private use by the bus driver only.
+	 *  A notable exception is that the visor driver can use
+	 *  visor_get_drvdata() and visor_set_drvdata() to retrieve or stash
+	 *  private visor driver specific data within the device member.
+	 */
+	struct device device;
+	struct list_head list_all;
+	struct periodic_work *periodic_work;
+	bool being_removed;
+	bool responded_to_device_create;
+	struct kobject kobjchannel;	/* visorbus<x>/dev<y>/channel/ */
+	struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
+	struct {
+		int major, minor;
+		void *attr;	/* private use by devmajorminor_attr.c you can
+				   * change this constant to whatever you
+				   * want; */
+	} devnodes[5];
+	/* the code will detect and behave appropriately) */
+	struct semaphore visordriver_callback_lock;
+	bool pausing;
+	bool resuming;
+	unsigned long chipset_bus_no;
+	unsigned long chipset_dev_no;
+};
+
+#define to_visor_device(x) container_of(x, struct visor_device, device)
+
+#ifndef STANDALONE_CLIENT
+int visorbus_register_visor_driver(struct visor_driver *);
+void visorbus_unregister_visor_driver(struct visor_driver *);
+int visorbus_read_channel(struct visor_device *dev,
+			  unsigned long offset, void *dest,
+			  unsigned long nbytes);
+int visorbus_write_channel(struct visor_device *dev,
+			   unsigned long offset, void *src,
+			   unsigned long nbytes);
+int visorbus_clear_channel(struct visor_device *dev,
+			   unsigned long offset, u8 ch, unsigned long nbytes);
+int visorbus_registerdevnode(struct visor_device *dev,
+			     const char *name, int major, int minor);
+void visorbus_enable_channel_interrupts(struct visor_device *dev);
+void visorbus_disable_channel_interrupts(struct visor_device *dev);
+#endif
+
+/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
+ * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
+ * In this case, the values can simply be read from the channel header.
+ */
+struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
+					 ulong channel_bytes, uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
+						    struct visorchannel *parent,
+						    ulong off, uuid_le guid);
+struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
+						   ulong channel_bytes,
+						   uuid_le guid);
+struct visorchannel *visorchannel_create_overlapped_with_lock(
+				ulong channel_bytes,
+				struct visorchannel *parent,
+				ulong off, uuid_le guid);
+void visorchannel_destroy(struct visorchannel *channel);
+int visorchannel_read(struct visorchannel *channel, ulong offset,
+		      void *local, ulong nbytes);
+int visorchannel_write(struct visorchannel *channel, ulong offset,
+		       void *local, ulong nbytes);
+int visorchannel_clear(struct visorchannel *channel, ulong offset,
+		       u8 ch, ulong nbytes);
+BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
+			       void *msg);
+BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
+			       void *msg);
+int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
+					 u32 queue);
+int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
+HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
+ulong visorchannel_get_nbytes(struct visorchannel *channel);
+char *visorchannel_id(struct visorchannel *channel, char *s);
+char *visorchannel_zoneid(struct visorchannel *channel, char *s);
+u64 visorchannel_get_clientpartition(struct visorchannel *channel);
+uuid_le visorchannel_get_uuid(struct visorchannel *channel);
+struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
+char *visorchannel_uuid_id(uuid_le *guid, char *s);
+void visorchannel_debug(struct visorchannel *channel, int num_queues,
+			struct seq_file *seq, u32 off);
+void visorchannel_dump_section(struct visorchannel *chan, char *s,
+			       int off, int len, struct seq_file *seq);
+void __iomem *visorchannel_get_header(struct visorchannel *channel);
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus.h b/drivers/staging/unisys/visorbus/visorbus.h
deleted file mode 100644
index 3956a3d..0000000
--- a/drivers/staging/unisys/visorbus/visorbus.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* visorbus.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  This header file is to be included by other kernel mode components that
- *  implement a particular kind of visor_device.  Each of these other kernel
- *  mode components is called a visor device driver.  Refer to visortemplate
- *  for a minimal sample visor device driver.
- *
- *  There should be nothing in this file that is private to the visorbus
- *  bus implementation itself.
- *
- */
-
-#ifndef __VISORBUS_H__
-#define __VISORBUS_H__
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/uuid.h>
-
-#include "periodic_work.h"
-#include "channel.h"
-#include "memregion.h"
-
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-
-struct visor_driver;
-struct visor_device;
-
-typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
-					      int status);
-
-/** This struct describes a specific Supervisor channel, by providing its
- *  GUID, name, and sizes.
- */
-struct visor_channeltype_descriptor {
-	const uuid_le guid;
-	const char *name;
-	unsigned long min_size;
-	unsigned long max_size;
-};
-
-/** Information provided by each visor driver when it registers with the
- *  visorbus driver.
- */
-struct visor_driver {
-	const char *name;
-	const char *version;
-	const char *vertag;
-	const char *build_date;
-	const char *build_time;
-	struct module *owner;
-
-	/** Types of channels handled by this driver, ending with 0 GUID.
-	 *  Our specialized BUS.match() method knows about this list, and
-	 *  uses it to determine whether this driver will in fact handle a
-	 *  new device that it has detected.
-	 */
-	struct visor_channeltype_descriptor *channel_types;
-
-	/** Called when a new device comes online, by our probe() function
-	 *  specified by driver.probe() (triggered ultimately by some call
-	 *  to driver_register() / bus_add_driver() / driver_attach()).
-	 */
-	int (*probe)(struct visor_device *dev);
-
-	/** Called when a new device is removed, by our remove() function
-	 *  specified by driver.remove() (triggered ultimately by some call
-	 *  to device_release_driver()).
-	 */
-	void (*remove)(struct visor_device *dev);
-
-	/** Called periodically, whenever there is a possibility that
-	 *  "something interesting" may have happened to the channel state.
-	 */
-	void (*channel_interrupt)(struct visor_device *dev);
-
-	/** Called to initiate a change of the device's state.  If the return
-	 *  valu`e is < 0, there was an error and the state transition will NOT
-	 *  occur.  If the return value is >= 0, then the state transition was
-	 *  INITIATED successfully, and complete_func() will be called (or was
-	 *  just called) with the final status when either the state transition
-	 *  fails or completes successfully.
-	 */
-	int (*pause)(struct visor_device *dev,
-		     visorbus_state_complete_func complete_func);
-	int (*resume)(struct visor_device *dev,
-		      visorbus_state_complete_func complete_func);
-
-	/** These fields are for private use by the bus driver only. */
-	struct device_driver driver;
-	struct driver_attribute version_attr;
-};
-
-#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
-
-/** A device type for things "plugged" into the visorbus bus */
-
-struct visor_device {
-	/** visor driver can use the visorchannel member with the functions
-	 *  defined in visorchannel.h to access the channel
-	 */
-	struct visorchannel *visorchannel;
-	uuid_le channel_type_guid;
-	u64 channel_bytes;
-
-	/** These fields are for private use by the bus driver only.
-	 *  A notable exception is that the visor driver can use
-	 *  visor_get_drvdata() and visor_set_drvdata() to retrieve or stash
-	 *  private visor driver specific data within the device member.
-	 */
-	struct device device;
-	struct list_head list_all;
-	struct periodic_work *periodic_work;
-	bool being_removed;
-	bool responded_to_device_create;
-	struct kobject kobjchannel;	/* visorbus<x>/dev<y>/channel/ */
-	struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
-	struct {
-		int major, minor;
-		void *attr;	/* private use by devmajorminor_attr.c you can
-				   * change this constant to whatever you
-				   * want; */
-	} devnodes[5];
-	/* the code will detect and behave appropriately) */
-	struct semaphore visordriver_callback_lock;
-	bool pausing;
-	bool resuming;
-	unsigned long chipset_bus_no;
-	unsigned long chipset_dev_no;
-};
-
-#define to_visor_device(x) container_of(x, struct visor_device, device)
-
-#ifndef STANDALONE_CLIENT
-int visorbus_register_visor_driver(struct visor_driver *);
-void visorbus_unregister_visor_driver(struct visor_driver *);
-int visorbus_read_channel(struct visor_device *dev,
-			  unsigned long offset, void *dest,
-			  unsigned long nbytes);
-int visorbus_write_channel(struct visor_device *dev,
-			   unsigned long offset, void *src,
-			   unsigned long nbytes);
-int visorbus_clear_channel(struct visor_device *dev,
-			   unsigned long offset, u8 ch, unsigned long nbytes);
-int visorbus_registerdevnode(struct visor_device *dev,
-			     const char *name, int major, int minor);
-void visorbus_enable_channel_interrupts(struct visor_device *dev);
-void visorbus_disable_channel_interrupts(struct visor_device *dev);
-#endif
-
-/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
- * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
- * In this case, the values can simply be read from the channel header.
- */
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
-					 ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
-						    struct visorchannel *parent,
-						    ulong off, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
-						   ulong channel_bytes,
-						   uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped_with_lock(
-				ulong channel_bytes,
-				struct visorchannel *parent,
-				ulong off, uuid_le guid);
-void visorchannel_destroy(struct visorchannel *channel);
-int visorchannel_read(struct visorchannel *channel, ulong offset,
-		      void *local, ulong nbytes);
-int visorchannel_write(struct visorchannel *channel, ulong offset,
-		       void *local, ulong nbytes);
-int visorchannel_clear(struct visorchannel *channel, ulong offset,
-		       u8 ch, ulong nbytes);
-BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
-			       void *msg);
-BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
-			       void *msg);
-int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
-					 u32 queue);
-int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
-ulong visorchannel_get_nbytes(struct visorchannel *channel);
-char *visorchannel_id(struct visorchannel *channel, char *s);
-char *visorchannel_zoneid(struct visorchannel *channel, char *s);
-u64 visorchannel_get_clientpartition(struct visorchannel *channel);
-uuid_le visorchannel_get_uuid(struct visorchannel *channel);
-struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
-char *visorchannel_uuid_id(uuid_le *guid, char *s);
-void visorchannel_debug(struct visorchannel *channel, int num_queues,
-			struct seq_file *seq, u32 off);
-void visorchannel_dump_section(struct visorchannel *chan, char *s,
-			       int off, int len, struct seq_file *seq);
-void __iomem *visorchannel_get_header(struct visorchannel *channel);
-
-#endif
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 027/141] staging: unisys: Remove unused driver
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (25 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 026/141] staging: unisys: Move visorbus.h to public namespace Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 028/141] staging: unisys: unify businst attributes into visorbus_main.c Benjamin Romer
                   ` (116 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The visorchannel feature is rolled into visorbus now and its headers
are public under visorbus.h.  Remove the unused driver, the old
header file and all the ccflag includes in the Makefile.

Also remove VISORCHANNEL from all Kconfigs as it is not needed.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig
index 2030592..01d9a9a 100644
--- a/drivers/staging/unisys/visorchipset/Kconfig
+++ b/drivers/staging/unisys/visorchipset/Kconfig
@@ -5,7 +5,6 @@
 config UNISYS_VISORCHIPSET
 	tristate "Unisys visorchipset driver"
 	select UNISYS_VISORUTIL
-	select UNISYS_VISORCHANNEL
 	select UNISYS_VISORBUS
 	---help---
 	If you say Y here, you will enable the Unisys visorchipset driver.
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 028/141] staging: unisys: unify businst attributes into visorbus_main.c
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (26 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 027/141] staging: unisys: Remove unused driver Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 029/141] staging: unisys: unify channel " Benjamin Romer
                   ` (115 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

The code in businst_attr.[ch] only creates sysfs files and is called
only in visorbus_main.c.  This code should be unified into
visorbus_main.c.  There are some functions that have been made static.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Makefile        |   2 +-
 drivers/staging/unisys/visorbus/businst_attr.c  | 103 ------------------------
 drivers/staging/unisys/visorbus/businst_attr.h  |  40 ---------
 drivers/staging/unisys/visorbus/visorbus_main.c |  97 +++++++++++++++++++++-
 4 files changed, 97 insertions(+), 145 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.c
 delete mode 100644 drivers/staging/unisys/visorbus/businst_attr.h

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 20d87da..e1b667d 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
-visorbus-y := visorbus_main.o devmajorminor_attr.o businst_attr.o channel_attr.o
+visorbus-y := visorbus_main.o devmajorminor_attr.o channel_attr.o
 visorbus-y	+= visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorbus/businst_attr.c b/drivers/staging/unisys/visorbus/businst_attr.c
deleted file mode 100644
index b3fea9d..0000000
--- a/drivers/staging/unisys/visorbus/businst_attr.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* businst_attr.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*   This is actually something they forgot to put in the kernel.
- *   struct bus_type in the kernel SHOULD have a "busses" member, which
- *   should be treated similarly to the "devices" and "drivers" members.
- *   There SHOULD be:
- *   - a "businst_attribute" analogous to the existing "bus_attribute"
- *   - a "businst_create_file" and "businst_remove_file" analogous to the
- *     existing "bus_create_file" and "bus_remove_file".
- *   That's what I created businst.c and businst.h to do.
- *
- *   We want to add the "busses" sub-tree in sysfs, where we will house the
- *   names and properties of each bus instance:
- *
- *       /sys/bus/<bustypename>/
- *           version
- *           devices
- *               <devname1> --> /sys/devices/<businstancename><devname1>
- *               <devname2> --> /sys/devices/<businstancename><devname2>
- *           drivers
- *               <driverinstancename1>
- *                   <driverinstance1property1>
- *                   <driverinstance1property2>
- *                   ...
- *               <driverinstancename2>
- *                   <driverinstance2property1>
- *                   <driverinstance2property2>
- *                   ...
- *   >>      busses
- *   >>          <businstancename1>
- *   >>              <businstance1property1>
- *   >>              <businstance1property2>
- *   >>              ...
- *   >>          <businstancename2>
- *   >>              <businstance2property1>
- *   >>              <businstance2property2>
- *   >>              ...
- *
- *   I considered adding bus instance properties under
- *   /sys/devices/<businstancename>.  But I thought there may be existing
- *   notions that ONLY device sub-trees should live under
- *   /sys/devices/<businstancename>.  So I stayed out of there.
- *
- */
-
-#include "businst_attr.h"
-
-#define to_businst_attr(_attr) \
-	container_of(_attr, struct businst_attribute, attr)
-#define to_visorbus_devdata(obj) \
-	container_of(obj, struct visorbus_devdata, kobj)
-#define CURRENT_FILE_PC VISOR_BUS_PC_businst_attr_c
-
-ssize_t businst_attr_show(struct kobject *kobj, struct attribute *attr,
-			  char *buf)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->show)
-		ret = businst_attr->show(bus, buf);
-	return ret;
-}
-
-ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
-			   const char *buf, size_t count)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->store)
-		ret = businst_attr->store(bus, buf, count);
-	return ret;
-}
-
-int businst_create_file(struct visorbus_devdata *bus,
-			struct businst_attribute *attr)
-{
-	return sysfs_create_file(&bus->kobj, &attr->attr);
-}
-
-void businst_remove_file(struct visorbus_devdata *bus,
-			 struct businst_attribute *attr)
-{
-	sysfs_remove_file(&bus->kobj, &attr->attr);
-}
diff --git a/drivers/staging/unisys/visorbus/businst_attr.h b/drivers/staging/unisys/visorbus/businst_attr.h
deleted file mode 100644
index e9fb36a..0000000
--- a/drivers/staging/unisys/visorbus/businst_attr.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* businst_attr.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __BUSINST_H__
-#define __BUSINST_H__
-
-#include "visorbus_private.h"	/* just to get visorbus_devdata declaration */
-#include "timskmod.h"
-
-struct businst_attribute {
-	struct attribute attr;
-	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
-	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
-			  size_t count);
-};
-
-ssize_t businst_attr_show(struct kobject *kobj,
-			  struct attribute *attr, char *buf);
-ssize_t businst_attr_store(struct kobject *kobj, struct attribute *attr,
-			   const char *buf, size_t count);
-int businst_create_file(struct visorbus_devdata *bus,
-			struct businst_attribute *attr);
-void businst_remove_file(struct visorbus_devdata *bus,
-			 struct businst_attribute *attr);
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d717e35..d178fcd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -18,7 +18,7 @@
 #include <linux/uuid.h>
 
 #include "visorbus_private.h"
-#include "businst_attr.h"
+#include "timskmod.h"
 #include "channel_attr.h"
 #include "devmajorminor_attr.h"
 #include "periodic_work.h"
@@ -200,6 +200,101 @@ visorbus_release_device(struct device *xdev)
 	kfree(dev);
 }
 
+/*   This is actually something they forgot to put in the kernel.
+ *   struct bus_type in the kernel SHOULD have a "busses" member, which
+ *   should be treated similarly to the "devices" and "drivers" members.
+ *   There SHOULD be:
+ *   - a "businst_attribute" analogous to the existing "bus_attribute"
+ *   - a "businst_create_file" and "businst_remove_file" analogous to the
+ *     existing "bus_create_file" and "bus_remove_file".
+ *   That's what I created businst.c and businst.h to do.
+ *
+ *   We want to add the "busses" sub-tree in sysfs, where we will house the
+ *   names and properties of each bus instance:
+ *
+ *       /sys/bus/<bustypename>/
+ *           version
+ *           devices
+ *               <devname1> --> /sys/devices/<businstancename><devname1>
+ *               <devname2> --> /sys/devices/<businstancename><devname2>
+ *           drivers
+ *               <driverinstancename1>
+ *                   <driverinstance1property1>
+ *                   <driverinstance1property2>
+ *                   ...
+ *               <driverinstancename2>
+ *                   <driverinstance2property1>
+ *                   <driverinstance2property2>
+ *                   ...
+ *   >>      busses
+ *   >>          <businstancename1>
+ *   >>              <businstance1property1>
+ *   >>              <businstance1property2>
+ *   >>              ...
+ *   >>          <businstancename2>
+ *   >>              <businstance2property1>
+ *   >>              <businstance2property2>
+ *   >>              ...
+ *
+ *   I considered adding bus instance properties under
+ *   /sys/devices/<businstancename>.  But I thought there may be existing
+ *   notions that ONLY device sub-trees should live under
+ *   /sys/devices/<businstancename>.  So I stayed out of there.
+ *
+ */
+
+struct businst_attribute {
+	struct attribute attr;
+	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
+	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
+			  size_t count);
+};
+
+#define to_businst_attr(_attr) \
+	container_of(_attr, struct businst_attribute, attr)
+#define to_visorbus_devdata(obj) \
+	container_of(obj, struct visorbus_devdata, kobj)
+
+static ssize_t
+businst_attr_show(struct kobject *kobj, struct attribute *attr,
+		  char *buf)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->show)
+		ret = businst_attr->show(bus, buf);
+	return ret;
+}
+
+static ssize_t
+businst_attr_store(struct kobject *kobj, struct attribute *attr,
+		   const char *buf, size_t count)
+{
+	struct businst_attribute *businst_attr = to_businst_attr(attr);
+	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
+	ssize_t ret = 0;
+
+	if (businst_attr->store)
+		ret = businst_attr->store(bus, buf, count);
+	return ret;
+}
+
+static int
+businst_create_file(struct visorbus_devdata *bus,
+		    struct businst_attribute *attr)
+{
+	return sysfs_create_file(&bus->kobj, &attr->attr);
+}
+
+static void
+businst_remove_file(struct visorbus_devdata *bus,
+		    struct businst_attribute *attr)
+{
+	sysfs_remove_file(&bus->kobj, &attr->attr);
+}
+
 static const struct sysfs_ops businst_sysfs_ops = {
 	.show = businst_attr_show,
 	.store = businst_attr_store,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 029/141] staging: unisys: unify channel attributes into visorbus_main.c
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (27 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 028/141] staging: unisys: unify businst attributes into visorbus_main.c Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 030/141] staging: unisys: unify devmajorminor " Benjamin Romer
                   ` (114 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

The code in channel_attr.[ch] only creates sysfs files and is called
only in visorbus_main.c.  This code should be unified into
visorbus_main.c.   There are some functions that have been made static.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Makefile        |   2 +-
 drivers/staging/unisys/visorbus/channel_attr.c  | 227 ------------------------
 drivers/staging/unisys/visorbus/channel_attr.h  |  27 ---
 drivers/staging/unisys/visorbus/visorbus_main.c | 209 +++++++++++++++++++++-
 4 files changed, 209 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/channel_attr.c
 delete mode 100644 drivers/staging/unisys/visorbus/channel_attr.h

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index e1b667d..d44fbf6 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
-visorbus-y := visorbus_main.o devmajorminor_attr.o channel_attr.o
+visorbus-y := visorbus_main.o devmajorminor_attr.o
 visorbus-y	+= visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorbus/channel_attr.c b/drivers/staging/unisys/visorbus/channel_attr.c
deleted file mode 100644
index 0d7184a..0000000
--- a/drivers/staging/unisys/visorbus/channel_attr.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* channel_attr.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* Implement publishing of channel attributes under:
- *
- *     /sys/bus/visorbus<x>/dev<y>/channel
- *
- */
-
-#include "channel_attr.h"
-#define CURRENT_FILE_PC VISOR_BUS_PC_channel_attr_c
-#define to_channel_attr(_attr) \
-	container_of(_attr, struct channel_attribute, attr)
-#define to_visor_device_from_kobjchannel(obj) \
-	container_of(obj, struct visor_device, kobjchannel)
-
-struct channel_attribute {
-	struct attribute attr;
-	 ssize_t (*show)(struct visor_device*, char *buf);
-	 ssize_t (*store)(struct visor_device*, const char *buf, size_t count);
-};
-
-/* begin implementation of specific channel attributes to appear under
-* /sys/bus/visorbus<x>/dev<y>/channel
-*/
-static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf)
-{
-	if (!dev->visorchannel)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
-			visorchannel_get_physaddr(dev->visorchannel));
-}
-
-static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf)
-{
-	if (!dev->visorchannel)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
-			visorchannel_get_nbytes(dev->visorchannel));
-}
-
-static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev,
-						  char *buf) {
-	if (!dev->visorchannel)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
-			visorchannel_get_clientpartition(dev->visorchannel));
-}
-
-static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf)
-{
-	char s[99];
-
-	if (!dev->visorchannel)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "%s\n",
-			visorchannel_id(dev->visorchannel, s));
-}
-
-static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf)
-{
-	char s[99];
-
-	if (!dev->visorchannel)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "%s\n",
-			visorchannel_zoneid(dev->visorchannel, s));
-}
-
-static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf)
-{
-	int i = 0;
-	struct bus_type *xbus = dev->device.bus;
-	struct device_driver *xdrv = dev->device.driver;
-	struct visor_driver *drv = NULL;
-
-	if (!dev->visorchannel || !xbus || !xdrv)
-		return 0;
-	i = xbus->match(&dev->device, xdrv);
-	if (!i)
-		return 0;
-	drv = to_visor_driver(xdrv);
-	return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
-}
-
-static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf)
-{
-	int count = 0;
-/* TODO: replace this with debugfs code
-	struct seq_file *m = NULL;
-	if (dev->visorchannel == NULL)
-		return 0;
-	m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
-	if (m == NULL)
-		return 0;
-	visorchannel_debug(dev->visorchannel, 1, m, 0);
-	count = m->count;
-	visor_seq_file_done_buffer(m);
-	m = NULL;
-*/
-	return count;
-}
-
-static struct channel_attribute all_channel_attrs[] = {
-	__ATTR(physaddr, S_IRUGO,
-	       devicechannel_attr_physaddr, NULL),
-	__ATTR(nbytes, S_IRUGO,
-	       devicechannel_attr_nbytes, NULL),
-	__ATTR(clientpartition, S_IRUGO,
-	       devicechannel_attr_clientpartition, NULL),
-	__ATTR(typeguid, S_IRUGO,
-	       devicechannel_attr_typeguid, NULL),
-	__ATTR(zoneguid, S_IRUGO,
-	       devicechannel_attr_zoneguid, NULL),
-	__ATTR(typename, S_IRUGO,
-	       devicechannel_attr_typename, NULL),
-	__ATTR(dump, S_IRUGO,
-	       devicechannel_attr_dump, NULL),
-};
-
-/* end implementation of specific channel attributes */
-
-static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr,
-				 char *buf)
-{
-	struct channel_attribute *channel_attr = to_channel_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
-	ssize_t ret = 0;
-
-	if (channel_attr->show)
-		ret = channel_attr->show(dev, buf);
-	return ret;
-}
-
-static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr,
-				  const char *buf, size_t count)
-{
-	struct channel_attribute *channel_attr = to_channel_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
-	ssize_t ret = 0;
-
-	if (channel_attr->store)
-		ret = channel_attr->store(dev, buf, count);
-	return ret;
-}
-
-static int channel_create_file(struct visor_device *dev,
-			       struct channel_attribute *attr)
-{
-	return sysfs_create_file(&dev->kobjchannel, &attr->attr);
-}
-
-static void channel_remove_file(struct visor_device *dev,
-				struct channel_attribute *attr)
-{
-	sysfs_remove_file(&dev->kobjchannel, &attr->attr);
-}
-
-static const struct sysfs_ops channel_sysfs_ops = {
-	.show = channel_attr_show,
-	.store = channel_attr_store,
-};
-
-static struct kobj_type channel_kobj_type = {
-	.sysfs_ops = &channel_sysfs_ops
-};
-
-int register_channel_attributes(struct visor_device *dev)
-{
-	int rc = 0, i = 0, x = 0;
-
-	if (dev->kobjchannel.parent)
-		goto away;	/* already registered */
-	x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type,
-				 &dev->device.kobj, "channel");
-	if (x < 0) {
-		rc = x;
-		goto away;
-	}
-
-	kobject_uevent(&dev->kobjchannel, KOBJ_ADD);
-
-	for (i = 0;
-	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
-	     i++)
-		x = channel_create_file(dev, &all_channel_attrs[i]);
-	if (x < 0) {
-		while (--i >= 0)
-			channel_remove_file(dev, &all_channel_attrs[i]);
-		kobject_del(&dev->kobjchannel);
-		kobject_put(&dev->kobjchannel);
-		rc = x;
-		goto away;
-	}
-away:
-	return rc;
-}
-
-void unregister_channel_attributes(struct visor_device *dev)
-{
-	int i = 0;
-
-	if (!dev->kobjchannel.parent)
-		return;		/* already unregistered */
-	for (i = 0;
-	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
-	     i++)
-		channel_remove_file(dev, &all_channel_attrs[i]);
-
-	kobject_del(&dev->kobjchannel);
-	kobject_put(&dev->kobjchannel);
-	dev->kobjchannel.parent = NULL;
-}
diff --git a/drivers/staging/unisys/visorbus/channel_attr.h b/drivers/staging/unisys/visorbus/channel_attr.h
deleted file mode 100644
index 00ae37c..0000000
--- a/drivers/staging/unisys/visorbus/channel_attr.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* channel_attr.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CHANNEL_ATTR_H__
-#define __CHANNEL_ATTR_H__
-
-#include "visorbus.h"		/* just to get visor_device declaration */
-#include "timskmod.h"
-
-int register_channel_attributes(struct visor_device *dev);
-void unregister_channel_attributes(struct visor_device *dev);
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d178fcd..c4eec2c 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -19,7 +19,6 @@
 
 #include "visorbus_private.h"
 #include "timskmod.h"
-#include "channel_attr.h"
 #include "devmajorminor_attr.h"
 #include "periodic_work.h"
 #include "vbuschannel.h"
@@ -200,6 +199,214 @@ visorbus_release_device(struct device *xdev)
 	kfree(dev);
 }
 
+/* Implement publishing of channel attributes under:
+ *
+ *     /sys/bus/visorbus<x>/dev<y>/channel
+ *
+ */
+
+#define to_channel_attr(_attr) \
+	container_of(_attr, struct channel_attribute, attr)
+#define to_visor_device_from_kobjchannel(obj) \
+	container_of(obj, struct visor_device, kobjchannel)
+
+struct channel_attribute {
+	struct attribute attr;
+	 ssize_t (*show)(struct visor_device*, char *buf);
+	 ssize_t (*store)(struct visor_device*, const char *buf, size_t count);
+};
+
+/* begin implementation of specific channel attributes to appear under
+* /sys/bus/visorbus<x>/dev<y>/channel
+*/
+static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf)
+{
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+			visorchannel_get_physaddr(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf)
+{
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+			visorchannel_get_nbytes(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev,
+						  char *buf) {
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+			visorchannel_get_clientpartition(dev->visorchannel));
+}
+
+static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf)
+{
+	char s[99];
+
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%s\n",
+			visorchannel_id(dev->visorchannel, s));
+}
+
+static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf)
+{
+	char s[99];
+
+	if (!dev->visorchannel)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%s\n",
+			visorchannel_zoneid(dev->visorchannel, s));
+}
+
+static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf)
+{
+	int i = 0;
+	struct bus_type *xbus = dev->device.bus;
+	struct device_driver *xdrv = dev->device.driver;
+	struct visor_driver *drv = NULL;
+
+	if (!dev->visorchannel || !xbus || !xdrv)
+		return 0;
+	i = xbus->match(&dev->device, xdrv);
+	if (!i)
+		return 0;
+	drv = to_visor_driver(xdrv);
+	return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
+}
+
+static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf)
+{
+	int count = 0;
+/* TODO: replace this with debugfs code
+	struct seq_file *m = NULL;
+	if (dev->visorchannel == NULL)
+		return 0;
+	m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
+	if (m == NULL)
+		return 0;
+	visorchannel_debug(dev->visorchannel, 1, m, 0);
+	count = m->count;
+	visor_seq_file_done_buffer(m);
+	m = NULL;
+*/
+	return count;
+}
+
+static struct channel_attribute all_channel_attrs[] = {
+	__ATTR(physaddr, S_IRUGO,
+	       devicechannel_attr_physaddr, NULL),
+	__ATTR(nbytes, S_IRUGO,
+	       devicechannel_attr_nbytes, NULL),
+	__ATTR(clientpartition, S_IRUGO,
+	       devicechannel_attr_clientpartition, NULL),
+	__ATTR(typeguid, S_IRUGO,
+	       devicechannel_attr_typeguid, NULL),
+	__ATTR(zoneguid, S_IRUGO,
+	       devicechannel_attr_zoneguid, NULL),
+	__ATTR(typename, S_IRUGO,
+	       devicechannel_attr_typename, NULL),
+	__ATTR(dump, S_IRUGO,
+	       devicechannel_attr_dump, NULL),
+};
+
+/* end implementation of specific channel attributes */
+
+static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr,
+				 char *buf)
+{
+	struct channel_attribute *channel_attr = to_channel_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
+	ssize_t ret = 0;
+
+	if (channel_attr->show)
+		ret = channel_attr->show(dev, buf);
+	return ret;
+}
+
+static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct channel_attribute *channel_attr = to_channel_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
+	ssize_t ret = 0;
+
+	if (channel_attr->store)
+		ret = channel_attr->store(dev, buf, count);
+	return ret;
+}
+
+static int channel_create_file(struct visor_device *dev,
+			       struct channel_attribute *attr)
+{
+	return sysfs_create_file(&dev->kobjchannel, &attr->attr);
+}
+
+static void channel_remove_file(struct visor_device *dev,
+				struct channel_attribute *attr)
+{
+	sysfs_remove_file(&dev->kobjchannel, &attr->attr);
+}
+
+static const struct sysfs_ops channel_sysfs_ops = {
+	.show = channel_attr_show,
+	.store = channel_attr_store,
+};
+
+static struct kobj_type channel_kobj_type = {
+	.sysfs_ops = &channel_sysfs_ops
+};
+
+int register_channel_attributes(struct visor_device *dev)
+{
+	int rc = 0, i = 0, x = 0;
+
+	if (dev->kobjchannel.parent)
+		goto away;	/* already registered */
+	x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type,
+				 &dev->device.kobj, "channel");
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+
+	kobject_uevent(&dev->kobjchannel, KOBJ_ADD);
+
+	for (i = 0;
+	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
+	     i++)
+		x = channel_create_file(dev, &all_channel_attrs[i]);
+	if (x < 0) {
+		while (--i >= 0)
+			channel_remove_file(dev, &all_channel_attrs[i]);
+		kobject_del(&dev->kobjchannel);
+		kobject_put(&dev->kobjchannel);
+		rc = x;
+		goto away;
+	}
+away:
+	return rc;
+}
+
+void unregister_channel_attributes(struct visor_device *dev)
+{
+	int i = 0;
+
+	if (!dev->kobjchannel.parent)
+		return;		/* already unregistered */
+	for (i = 0;
+	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
+	     i++)
+		channel_remove_file(dev, &all_channel_attrs[i]);
+
+	kobject_del(&dev->kobjchannel);
+	kobject_put(&dev->kobjchannel);
+	dev->kobjchannel.parent = NULL;
+}
 /*   This is actually something they forgot to put in the kernel.
  *   struct bus_type in the kernel SHOULD have a "busses" member, which
  *   should be treated similarly to the "devices" and "drivers" members.
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 030/141] staging: unisys: unify devmajorminor attributes into visorbus_main.c
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (28 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 029/141] staging: unisys: unify channel " Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-09  8:37   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 031/141] staging: unisys: rename visorchannel_funcs.c to visorchannel.c Benjamin Romer
                   ` (113 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

The code in devmajorminor_attr.[ch] only creates sysfs files and is
called only in visorbus_main.c.  This code should be unified into
visorbus_main.c.  The only changes are a forward declaration issue with
register_devmajorminor_attributes() and making the functions static.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Makefile           |   2 +-
 .../staging/unisys/visorbus/devmajorminor_attr.c   | 192 ---------------------
 .../staging/unisys/visorbus/devmajorminor_attr.h   |  31 ----
 drivers/staging/unisys/visorbus/visorbus_main.c    | 176 ++++++++++++++++++-
 4 files changed, 176 insertions(+), 225 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.c
 delete mode 100644 drivers/staging/unisys/visorbus/devmajorminor_attr.h

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index d44fbf6..0465fb9 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
-visorbus-y := visorbus_main.o devmajorminor_attr.o
+visorbus-y := visorbus_main.o
 visorbus-y	+= visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.c b/drivers/staging/unisys/visorbus/devmajorminor_attr.c
deleted file mode 100644
index ceb4bb7..0000000
--- a/drivers/staging/unisys/visorbus/devmajorminor_attr.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/* devmajorminor_attr.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* Implement publishing of device node attributes under:
- *
- *     /sys/bus/visorbus<x>/dev<y>/devmajorminor
- *
- */
-
-#include "devmajorminor_attr.h"
-#define CURRENT_FILE_PC VISOR_BUS_PC_devmajorminor_attr_c
-
-#define to_devmajorminor_attr(_attr) \
-	container_of(_attr, struct devmajorminor_attribute, attr)
-#define to_visor_device_from_kobjdevmajorminor(obj) \
-	container_of(obj, struct visor_device, kobjdevmajorminor)
-
-struct devmajorminor_attribute {
-	struct attribute attr;
-	int slot;
-	 ssize_t (*show)(struct visor_device *, int slot, char *buf);
-	 ssize_t (*store)(struct visor_device *, int slot, const char *buf,
-			  size_t count);
-};
-
-static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf)
-{
-	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
-
-	if (slot < 0 || slot >= maxdevnodes)
-		return 0;
-	return snprintf(buf, PAGE_SIZE, "%d:%d\n",
-			dev->devnodes[slot].major, dev->devnodes[slot].minor);
-}
-
-static ssize_t
-devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
-{
-	struct devmajorminor_attribute *devmajorminor_attr =
-	    to_devmajorminor_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
-	ssize_t ret = 0;
-
-	if (devmajorminor_attr->show)
-		ret = devmajorminor_attr->show(dev,
-					       devmajorminor_attr->slot, buf);
-	return ret;
-}
-
-static ssize_t
-devmajorminor_attr_store(struct kobject *kobj,
-			 struct attribute *attr, const char *buf, size_t count)
-{
-	struct devmajorminor_attribute *devmajorminor_attr =
-	    to_devmajorminor_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
-	ssize_t ret = 0;
-
-	if (devmajorminor_attr->store)
-		ret = devmajorminor_attr->store(dev,
-						devmajorminor_attr->slot,
-						buf, count);
-	return ret;
-}
-
-int
-devmajorminor_create_file(struct visor_device *dev, const char *name,
-			  int major, int minor)
-{
-	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
-	struct devmajorminor_attribute *myattr = NULL;
-	int x = -1, rc = 0, slot = -1;
-
-	register_devmajorminor_attributes(dev);
-	for (slot = 0; slot < maxdevnodes; slot++)
-		if (!dev->devnodes[slot].attr)
-			break;
-	if (slot == maxdevnodes) {
-		rc = -ENOMEM;
-		goto away;
-	}
-	myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
-	if (!myattr) {
-		rc = -ENOMEM;
-		goto away;
-	}
-	memset(myattr, 0, sizeof(struct devmajorminor_attribute));
-	myattr->show = DEVMAJORMINOR_ATTR;
-	myattr->store = NULL;
-	myattr->slot = slot;
-	myattr->attr.name = name;
-	myattr->attr.mode = S_IRUGO;
-	dev->devnodes[slot].attr = myattr;
-	dev->devnodes[slot].major = major;
-	dev->devnodes[slot].minor = minor;
-	x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr);
-	if (x < 0) {
-		rc = x;
-		goto away;
-	}
-	kobject_uevent(&dev->device.kobj, KOBJ_ONLINE);
-away:
-	if (rc < 0) {
-		kfree(myattr);
-		myattr = NULL;
-		dev->devnodes[slot].attr = NULL;
-	}
-	return rc;
-}
-
-void
-devmajorminor_remove_file(struct visor_device *dev, int slot)
-{
-	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
-	struct devmajorminor_attribute *myattr = NULL;
-
-	if (slot < 0 || slot >= maxdevnodes)
-		return;
-	myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
-	if (myattr)
-		return;
-	sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
-	kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
-	dev->devnodes[slot].attr = NULL;
-	kfree(myattr);
-}
-
-void
-devmajorminor_remove_all_files(struct visor_device *dev)
-{
-	int i = 0;
-	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
-
-	for (i = 0; i < maxdevnodes; i++)
-		devmajorminor_remove_file(dev, i);
-}
-
-static const struct sysfs_ops devmajorminor_sysfs_ops = {
-	.show = devmajorminor_attr_show,
-	.store = devmajorminor_attr_store,
-};
-
-static struct kobj_type devmajorminor_kobj_type = {
-	.sysfs_ops = &devmajorminor_sysfs_ops
-};
-
-int
-register_devmajorminor_attributes(struct visor_device *dev)
-{
-	int rc = 0, x = 0;
-
-	if (dev->kobjdevmajorminor.parent)
-		goto away;	/* already registered */
-	x = kobject_init_and_add(&dev->kobjdevmajorminor,
-				 &devmajorminor_kobj_type, &dev->device.kobj,
-				 "devmajorminor");
-	if (x < 0) {
-		rc = x;
-		goto away;
-	}
-
-	kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD);
-
-away:
-	return rc;
-}
-
-void
-unregister_devmajorminor_attributes(struct visor_device *dev)
-{
-	if (!dev->kobjdevmajorminor.parent)
-		return;		/* already unregistered */
-	devmajorminor_remove_all_files(dev);
-
-	kobject_del(&dev->kobjdevmajorminor);
-	kobject_put(&dev->kobjdevmajorminor);
-	dev->kobjdevmajorminor.parent = NULL;
-}
diff --git a/drivers/staging/unisys/visorbus/devmajorminor_attr.h b/drivers/staging/unisys/visorbus/devmajorminor_attr.h
deleted file mode 100644
index 0b55cb1..0000000
--- a/drivers/staging/unisys/visorbus/devmajorminor_attr.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* devmajorminor_attr.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __DEVMAJORMINOR_ATTR_H__
-#define __DEVMAJORMINOR_ATTR_H__
-
-#include "visorbus.h"		/* just to get visor_device declaration */
-#include "timskmod.h"
-
-int register_devmajorminor_attributes(struct visor_device *dev);
-void unregister_devmajorminor_attributes(struct visor_device *dev);
-int devmajorminor_create_file(struct visor_device *dev, const char *nam,
-			      int major, int minor);
-void devmajorminor_remove_file(struct visor_device *dev, int slot);
-void devmajorminor_remove_all_files(struct visor_device *dev);
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index c4eec2c..d5556e2 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -19,7 +19,6 @@
 
 #include "visorbus_private.h"
 #include "timskmod.h"
-#include "devmajorminor_attr.h"
 #include "periodic_work.h"
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
@@ -199,6 +198,181 @@ visorbus_release_device(struct device *xdev)
 	kfree(dev);
 }
 
+/* Implement publishing of device node attributes under:
+ *
+ *     /sys/bus/visorbus<x>/dev<y>/devmajorminor
+ *
+ */
+
+#define to_devmajorminor_attr(_attr) \
+	container_of(_attr, struct devmajorminor_attribute, attr)
+#define to_visor_device_from_kobjdevmajorminor(obj) \
+	container_of(obj, struct visor_device, kobjdevmajorminor)
+
+struct devmajorminor_attribute {
+	struct attribute attr;
+	int slot;
+	 ssize_t (*show)(struct visor_device *, int slot, char *buf);
+	 ssize_t (*store)(struct visor_device *, int slot, const char *buf,
+			  size_t count);
+};
+
+static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+	if (slot < 0 || slot >= maxdevnodes)
+		return 0;
+	return snprintf(buf, PAGE_SIZE, "%d:%d\n",
+			dev->devnodes[slot].major, dev->devnodes[slot].minor);
+}
+
+static ssize_t
+devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+	struct devmajorminor_attribute *devmajorminor_attr =
+	    to_devmajorminor_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+	ssize_t ret = 0;
+
+	if (devmajorminor_attr->show)
+		ret = devmajorminor_attr->show(dev,
+					       devmajorminor_attr->slot, buf);
+	return ret;
+}
+
+static ssize_t
+devmajorminor_attr_store(struct kobject *kobj,
+			 struct attribute *attr, const char *buf, size_t count)
+{
+	struct devmajorminor_attribute *devmajorminor_attr =
+	    to_devmajorminor_attr(attr);
+	struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+	ssize_t ret = 0;
+
+	if (devmajorminor_attr->store)
+		ret = devmajorminor_attr->store(dev,
+						devmajorminor_attr->slot,
+						buf, count);
+	return ret;
+}
+
+static int register_devmajorminor_attributes(struct visor_device *dev);
+
+int
+devmajorminor_create_file(struct visor_device *dev, const char *name,
+			  int major, int minor)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+	struct devmajorminor_attribute *myattr = NULL;
+	int x = -1, rc = 0, slot = -1;
+
+	register_devmajorminor_attributes(dev);
+	for (slot = 0; slot < maxdevnodes; slot++)
+		if (!dev->devnodes[slot].attr)
+			break;
+	if (slot == maxdevnodes) {
+		rc = -ENOMEM;
+		goto away;
+	}
+	myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
+	if (!myattr) {
+		rc = -ENOMEM;
+		goto away;
+	}
+	memset(myattr, 0, sizeof(struct devmajorminor_attribute));
+	myattr->show = DEVMAJORMINOR_ATTR;
+	myattr->store = NULL;
+	myattr->slot = slot;
+	myattr->attr.name = name;
+	myattr->attr.mode = S_IRUGO;
+	dev->devnodes[slot].attr = myattr;
+	dev->devnodes[slot].major = major;
+	dev->devnodes[slot].minor = minor;
+	x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr);
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+	kobject_uevent(&dev->device.kobj, KOBJ_ONLINE);
+away:
+	if (rc < 0) {
+		kfree(myattr);
+		myattr = NULL;
+		dev->devnodes[slot].attr = NULL;
+	}
+	return rc;
+}
+
+void
+devmajorminor_remove_file(struct visor_device *dev, int slot)
+{
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+	struct devmajorminor_attribute *myattr = NULL;
+
+	if (slot < 0 || slot >= maxdevnodes)
+		return;
+	myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
+	if (myattr)
+		return;
+	sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
+	kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
+	dev->devnodes[slot].attr = NULL;
+	kfree(myattr);
+}
+
+void
+devmajorminor_remove_all_files(struct visor_device *dev)
+{
+	int i = 0;
+	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+	for (i = 0; i < maxdevnodes; i++)
+		devmajorminor_remove_file(dev, i);
+}
+
+static const struct sysfs_ops devmajorminor_sysfs_ops = {
+	.show = devmajorminor_attr_show,
+	.store = devmajorminor_attr_store,
+};
+
+static struct kobj_type devmajorminor_kobj_type = {
+	.sysfs_ops = &devmajorminor_sysfs_ops
+};
+
+static int
+register_devmajorminor_attributes(struct visor_device *dev)
+{
+	int rc = 0, x = 0;
+
+	if (dev->kobjdevmajorminor.parent)
+		goto away;	/* already registered */
+	x = kobject_init_and_add(&dev->kobjdevmajorminor,
+				 &devmajorminor_kobj_type, &dev->device.kobj,
+				 "devmajorminor");
+	if (x < 0) {
+		rc = x;
+		goto away;
+	}
+
+	kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD);
+
+away:
+	return rc;
+}
+
+void
+unregister_devmajorminor_attributes(struct visor_device *dev)
+{
+	if (!dev->kobjdevmajorminor.parent)
+		return;		/* already unregistered */
+	devmajorminor_remove_all_files(dev);
+
+	kobject_del(&dev->kobjdevmajorminor);
+	kobject_put(&dev->kobjdevmajorminor);
+	dev->kobjdevmajorminor.parent = NULL;
+}
+
 /* Implement publishing of channel attributes under:
  *
  *     /sys/bus/visorbus<x>/dev<y>/channel
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 031/141] staging: unisys: rename visorchannel_funcs.c to visorchannel.c
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (29 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 030/141] staging: unisys: unify devmajorminor " Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 032/141] staging: unisys: remove globals.h Benjamin Romer
                   ` (112 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

visorchannel_funcs.c is a remnant of the separate visorchannel
directory.  It should be called visorchannel now.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Makefile           |   2 +-
 drivers/staging/unisys/visorbus/visorchannel.c     | 663 +++++++++++++++++++++
 .../staging/unisys/visorbus/visorchannel_funcs.c   | 663 ---------------------
 3 files changed, 664 insertions(+), 664 deletions(-)
 create mode 100644 drivers/staging/unisys/visorbus/visorchannel.c
 delete mode 100644 drivers/staging/unisys/visorbus/visorchannel_funcs.c

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 0465fb9..7151690 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -5,7 +5,7 @@
 obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
 visorbus-y := visorbus_main.o
-visorbus-y	+= visorchannel_funcs.o
+visorbus-y += visorchannel.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/visorchipset
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
new file mode 100644
index 0000000..b61f954
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -0,0 +1,663 @@
+/* visorchannel_funcs.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ *  This provides Supervisor channel communication primitives, which are
+ *  independent of the mechanism used to access the channel data.  All channel
+ *  data is accessed using the memregion abstraction.  (memregion has both
+ *  a CM2 implementation and a direct memory implementation.)
+ */
+
+#include "globals.h"
+#include "visorbus.h"
+#include <linux/uuid.h>
+
+#define MYDRVNAME "visorchannel"
+
+struct visorchannel {
+	struct memregion *memregion;	/* from visor_memregion_create() */
+	struct channel_header chan_hdr;
+	uuid_le guid;
+	ulong size;
+	BOOL needs_lock;	/* channel creator knows if more than one
+				 * thread will be inserting or removing */
+	spinlock_t insert_lock; /* protect head writes in chan_hdr */
+	spinlock_t remove_lock;	/* protect tail writes in chan_hdr */
+
+	struct {
+		struct signal_queue_header req_queue;
+		struct signal_queue_header rsp_queue;
+		struct signal_queue_header event_queue;
+		struct signal_queue_header ack_queue;
+	} safe_uis_queue;
+};
+
+/* Creates the struct visorchannel abstraction for a data area in memory,
+ * but does NOT modify this data area.
+ */
+static struct visorchannel *
+visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
+			 struct visorchannel *parent, ulong off, uuid_le guid,
+			 BOOL needs_lock)
+{
+	struct visorchannel *p = NULL;
+	void *rc = NULL;
+
+	p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
+	if (!p) {
+		rc = NULL;
+		goto cleanup;
+	}
+	p->memregion = NULL;
+	p->needs_lock = needs_lock;
+	spin_lock_init(&p->insert_lock);
+	spin_lock_init(&p->remove_lock);
+
+	/* prepare chan_hdr (abstraction to read/write channel memory) */
+	if (!parent)
+		p->memregion =
+		    visor_memregion_create(physaddr,
+					   sizeof(struct channel_header));
+	else
+		p->memregion =
+		    visor_memregion_create_overlapped(parent->memregion,
+				off, sizeof(struct channel_header));
+	if (!p->memregion) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
+				 sizeof(struct channel_header)) < 0) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (channel_bytes == 0)
+		/* we had better be a CLIENT of this channel */
+		channel_bytes = (ulong)p->chan_hdr.size;
+	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
+		/* we had better be a CLIENT of this channel */
+		guid = p->chan_hdr.chtype;
+	if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
+		rc = NULL;
+		goto cleanup;
+	}
+	p->size = channel_bytes;
+	p->guid = guid;
+
+	rc = p;
+cleanup:
+
+	if (!rc) {
+		if (!p) {
+			visorchannel_destroy(p);
+			p = NULL;
+		}
+	}
+	return rc;
+}
+
+struct visorchannel *
+visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
+{
+	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+					FALSE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create);
+
+struct visorchannel *
+visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
+			      uuid_le guid)
+{
+	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+					TRUE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
+
+struct visorchannel *
+visorchannel_create_overlapped(ulong channel_bytes,
+			       struct visorchannel *parent, ulong off,
+			       uuid_le guid)
+{
+	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
+					FALSE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
+
+struct visorchannel *
+visorchannel_create_overlapped_with_lock(ulong channel_bytes,
+					 struct visorchannel *parent, ulong off,
+					 uuid_le guid)
+{
+	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
+					TRUE);
+}
+EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
+
+void
+visorchannel_destroy(struct visorchannel *channel)
+{
+	if (!channel)
+		return;
+	if (channel->memregion) {
+		visor_memregion_destroy(channel->memregion);
+		channel->memregion = NULL;
+	}
+	kfree(channel);
+}
+EXPORT_SYMBOL_GPL(visorchannel_destroy);
+
+HOSTADDRESS
+visorchannel_get_physaddr(struct visorchannel *channel)
+{
+	return visor_memregion_get_physaddr(channel->memregion);
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
+
+ulong
+visorchannel_get_nbytes(struct visorchannel *channel)
+{
+	return channel->size;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_nbytes);
+
+char *
+visorchannel_uuid_id(uuid_le *guid, char *s)
+{
+	sprintf(s, "%pUL", guid);
+	return s;
+}
+EXPORT_SYMBOL_GPL(visorchannel_uuid_id);
+
+char *
+visorchannel_id(struct visorchannel *channel, char *s)
+{
+	return visorchannel_uuid_id(&channel->guid, s);
+}
+EXPORT_SYMBOL_GPL(visorchannel_id);
+
+char *
+visorchannel_zoneid(struct visorchannel *channel, char *s)
+{
+	return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s);
+}
+EXPORT_SYMBOL_GPL(visorchannel_zoneid);
+
+HOSTADDRESS
+visorchannel_get_clientpartition(struct visorchannel *channel)
+{
+	return channel->chan_hdr.partition_handle;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
+
+uuid_le
+visorchannel_get_uuid(struct visorchannel *channel)
+{
+	return channel->guid;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
+
+struct memregion *
+visorchannel_get_memregion(struct visorchannel *channel)
+{
+	return channel->memregion;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
+
+int
+visorchannel_read(struct visorchannel *channel, ulong offset,
+		  void *local, ulong nbytes)
+{
+	int rc = visor_memregion_read(channel->memregion, offset,
+				      local, nbytes);
+	if ((rc >= 0) && (offset == 0) &&
+	    (nbytes >= sizeof(struct channel_header))) {
+		memcpy(&channel->chan_hdr, local,
+		       sizeof(struct channel_header));
+	}
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_read);
+
+int
+visorchannel_write(struct visorchannel *channel, ulong offset,
+		   void *local, ulong nbytes)
+{
+	if (offset == 0 && nbytes >= sizeof(struct channel_header))
+		memcpy(&channel->chan_hdr, local,
+		       sizeof(struct channel_header));
+	return visor_memregion_write(channel->memregion, offset, local, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorchannel_write);
+
+int
+visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
+		   ulong nbytes)
+{
+	int rc = -1;
+	int bufsize = 65536;
+	int written = 0;
+	u8 *buf = vmalloc(bufsize);
+
+	if (!buf)
+		goto cleanup;
+
+	memset(buf, ch, bufsize);
+	while (nbytes > 0) {
+		ulong thisbytes = bufsize;
+		int x = -1;
+
+		if (nbytes < thisbytes)
+			thisbytes = nbytes;
+		x = visor_memregion_write(channel->memregion, offset + written,
+					  buf, thisbytes);
+		if (x < 0) {
+			rc = x;
+			goto cleanup;
+		}
+		written += thisbytes;
+		nbytes -= thisbytes;
+	}
+	rc = 0;
+
+cleanup:
+	if (buf) {
+		vfree(buf);
+		buf = NULL;
+	}
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_clear);
+
+void __iomem  *
+visorchannel_get_header(struct visorchannel *channel)
+{
+	return (void __iomem *)&channel->chan_hdr;
+}
+EXPORT_SYMBOL_GPL(visorchannel_get_header);
+
+/** Return offset of a specific SIGNAL_QUEUE_HEADER from the beginning of a
+ *  channel header
+ */
+#define SIG_QUEUE_OFFSET(chan_hdr, q) \
+	((chan_hdr)->ch_space_offset + \
+	 ((q) * sizeof(struct signal_queue_header)))
+
+/** Return offset of a specific queue entry (data) from the beginning of a
+ *  channel header
+ */
+#define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
+	(SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
+	    ((slot) * (sig_hdr)->signal_size))
+
+/** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
+ *  into host memory
+ */
+#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
+	(visor_memregion_write(channel->memregion,			\
+			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
+			       offsetof(struct signal_queue_header, FIELD),\
+			       &((sig_hdr)->FIELD),			\
+			       sizeof((sig_hdr)->FIELD)) >= 0)
+
+static BOOL
+sig_read_header(struct visorchannel *channel, u32 queue,
+		struct signal_queue_header *sig_hdr)
+{
+	BOOL rc = FALSE;
+
+	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
+		goto cleanup;
+
+	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
+
+	if (visor_memregion_read(channel->memregion,
+				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+				 sig_hdr,
+				 sizeof(struct signal_queue_header)) < 0) {
+		goto cleanup;
+	}
+	rc = TRUE;
+cleanup:
+	return rc;
+}
+
+static BOOL
+sig_do_data(struct visorchannel *channel, u32 queue,
+	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
+	    BOOL is_write)
+{
+	BOOL rc = FALSE;
+	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+						 sig_hdr, slot);
+	if (is_write) {
+		if (visor_memregion_write(channel->memregion,
+					  signal_data_offset,
+					  data, sig_hdr->signal_size) < 0) {
+			goto cleanup;
+		}
+	} else {
+		if (visor_memregion_read(channel->memregion, signal_data_offset,
+					 data, sig_hdr->signal_size) < 0) {
+			goto cleanup;
+		}
+	}
+	rc = TRUE;
+cleanup:
+	return rc;
+}
+
+static inline BOOL
+sig_read_data(struct visorchannel *channel, u32 queue,
+	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
+{
+	return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
+}
+
+static inline BOOL
+sig_write_data(struct visorchannel *channel, u32 queue,
+	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
+{
+	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
+}
+
+static inline unsigned char
+safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
+			struct signal_queue_header *punsafe_sqh,
+			u32 *phead, u32 *ptail)
+{
+	if ((*phead >= psafe_sqh->max_slots) ||
+	    (*ptail >= psafe_sqh->max_slots)) {
+		/* Choose 0 or max, maybe based on current tail value */
+		*phead = 0;
+		*ptail = 0;
+
+		/* Sync with client as necessary */
+		punsafe_sqh->head = *phead;
+		punsafe_sqh->tail = *ptail;
+
+		return 0;
+	}
+	return 1;
+}				/* end safe_sig_queue_validate */
+
+static BOOL
+signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return FALSE;
+	if (sig_hdr.head == sig_hdr.tail)
+		return FALSE;	/* no signals to remove */
+
+	sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
+	if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
+		return FALSE;
+	sig_hdr.num_received++;
+
+	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
+	 * update host memory.
+	 */
+	mb(); /* required for channel synch */
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
+		return FALSE;
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
+		return FALSE;
+	return TRUE;
+}
+
+BOOL
+visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
+{
+	BOOL rc;
+
+	if (channel->needs_lock) {
+		spin_lock(&channel->remove_lock);
+		rc = signalremove_inner(channel, queue, msg);
+		spin_unlock(&channel->remove_lock);
+	} else {
+		rc = signalremove_inner(channel, queue, msg);
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalremove);
+
+static BOOL
+signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return FALSE;
+
+	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
+	if (sig_hdr.head == sig_hdr.tail) {
+		sig_hdr.num_overflows++;
+		visor_memregion_write(channel->memregion,
+				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
+						       queue) +
+				      offsetof(struct signal_queue_header,
+					       num_overflows),
+				      &(sig_hdr.num_overflows),
+				      sizeof(sig_hdr.num_overflows));
+		return FALSE;
+	}
+
+	if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
+		return FALSE;
+
+	sig_hdr.num_sent++;
+
+	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
+	 * update host memory.
+	 */
+	mb(); /* required for channel synch */
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
+		return FALSE;
+	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
+		return FALSE;
+
+	return TRUE;
+}
+
+BOOL
+visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
+{
+	BOOL rc;
+
+	if (channel->needs_lock) {
+		spin_lock(&channel->insert_lock);
+		rc = signalinsert_inner(channel, queue, msg);
+		spin_unlock(&channel->insert_lock);
+	} else {
+		rc = signalinsert_inner(channel, queue, msg);
+	}
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
+
+int
+visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue)
+{
+	struct signal_queue_header sig_hdr;
+	u32 slots_avail, slots_used;
+	u32 head, tail;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return 0;
+	head = sig_hdr.head;
+	tail = sig_hdr.tail;
+	if (head < tail)
+		head = head + sig_hdr.max_slots;
+	slots_used = (head - tail);
+	slots_avail = sig_hdr.max_signals - slots_used;
+	return (int)slots_avail;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
+
+int
+visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue)
+{
+	struct signal_queue_header sig_hdr;
+
+	if (!sig_read_header(channel, queue, &sig_hdr))
+		return 0;
+	return (int)sig_hdr.max_signals;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
+
+static void
+sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq)
+{
+	seq_printf(seq, "Signal Queue #%d\n", which);
+	seq_printf(seq, "   VersionId          = %lu\n", (ulong)q->version);
+	seq_printf(seq, "   Type               = %lu\n", (ulong)q->chtype);
+	seq_printf(seq, "   oSignalBase        = %llu\n",
+		   (long long)q->sig_base_offset);
+	seq_printf(seq, "   SignalSize         = %lu\n", (ulong)q->signal_size);
+	seq_printf(seq, "   MaxSignalSlots     = %lu\n",
+		   (ulong)q->max_slots);
+	seq_printf(seq, "   MaxSignals         = %lu\n", (ulong)q->max_signals);
+	seq_printf(seq, "   FeatureFlags       = %-16.16Lx\n",
+		   (long long)q->features);
+	seq_printf(seq, "   NumSignalsSent     = %llu\n",
+		   (long long)q->num_sent);
+	seq_printf(seq, "   NumSignalsReceived = %llu\n",
+		   (long long)q->num_received);
+	seq_printf(seq, "   NumOverflows       = %llu\n",
+		   (long long)q->num_overflows);
+	seq_printf(seq, "   Head               = %lu\n", (ulong)q->head);
+	seq_printf(seq, "   Tail               = %lu\n", (ulong)q->tail);
+}
+
+void
+visorchannel_debug(struct visorchannel *channel, int num_queues,
+		   struct seq_file *seq, u32 off)
+{
+	HOSTADDRESS addr = 0;
+	ulong nbytes = 0, nbytes_region = 0;
+	struct memregion *memregion = NULL;
+	struct channel_header hdr;
+	struct channel_header *phdr = &hdr;
+	int i = 0;
+	int errcode = 0;
+
+	if (!channel)
+		return;
+	memregion = channel->memregion;
+	if (!memregion)
+		return;
+
+	addr = visor_memregion_get_physaddr(memregion);
+	nbytes_region = visor_memregion_get_nbytes(memregion);
+	errcode = visorchannel_read(channel, off,
+				    phdr, sizeof(struct channel_header));
+	if (errcode < 0) {
+		seq_printf(seq,
+			   "Read of channel header failed with errcode=%d)\n",
+			   errcode);
+		if (off == 0) {
+			phdr = &channel->chan_hdr;
+			seq_puts(seq, "(following data may be stale)\n");
+		} else {
+			return;
+		}
+	}
+	nbytes = (ulong)(phdr->size);
+	seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n",
+		   addr + off, nbytes, nbytes_region);
+	seq_printf(seq, "Type            = %pUL\n", &phdr->chtype);
+	seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->zone_uuid);
+	seq_printf(seq, "Signature       = 0x%-16.16Lx\n",
+		   (long long)phdr->signature);
+	seq_printf(seq, "LegacyState     = %lu\n", (ulong)phdr->legacy_state);
+	seq_printf(seq, "SrvState        = %lu\n", (ulong)phdr->srv_state);
+	seq_printf(seq, "CliStateBoot    = %lu\n", (ulong)phdr->cli_state_boot);
+	seq_printf(seq, "CliStateOS      = %lu\n", (ulong)phdr->cli_state_os);
+	seq_printf(seq, "HeaderSize      = %lu\n", (ulong)phdr->header_size);
+	seq_printf(seq, "Size            = %llu\n", (long long)phdr->size);
+	seq_printf(seq, "Features        = 0x%-16.16llx\n",
+		   (long long)phdr->features);
+	seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n",
+		   (long long)phdr->partition_handle);
+	seq_printf(seq, "Handle          = 0x%-16.16llx\n",
+		   (long long)phdr->handle);
+	seq_printf(seq, "VersionId       = %lu\n", (ulong)phdr->version_id);
+	seq_printf(seq, "oChannelSpace   = %llu\n",
+		   (long long)phdr->ch_space_offset);
+	if ((phdr->ch_space_offset == 0) || (errcode < 0))
+		;
+	else
+		for (i = 0; i < num_queues; i++) {
+			struct signal_queue_header q;
+
+			errcode = visorchannel_read(channel,
+						    off +
+						    phdr->ch_space_offset +
+						    (i * sizeof(q)),
+						    &q, sizeof(q));
+			if (errcode < 0) {
+				seq_printf(seq,
+					   "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n",
+					   i, addr, errcode);
+				continue;
+			}
+			sigqueue_debug(&q, i, seq);
+		}
+	seq_printf(seq, "--- End   channel @0x%-16.16Lx for 0x%lx bytes ---\n",
+		   addr + off, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorchannel_debug);
+
+void
+visorchannel_dump_section(struct visorchannel *chan, char *s,
+			  int off, int len, struct seq_file *seq)
+{
+	char *buf, *tbuf, *fmtbuf;
+	int fmtbufsize = 0;
+	int i;
+	int errcode = 0;
+
+	fmtbufsize = 100 * COVQ(len, 16);
+	buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
+	if (!buf)
+		return;
+	fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
+	if (!fmtbuf)
+		goto fmt_failed;
+
+	errcode = visorchannel_read(chan, off, buf, len);
+	if (errcode < 0)
+		goto read_failed;
+	seq_printf(seq, "channel %s:\n", s);
+	tbuf = buf;
+	while (len > 0) {
+		i = (len < 16) ? len : 16;
+		hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
+		seq_printf(seq, "%s\n", fmtbuf);
+		tbuf += 16;
+		len -= 16;
+	}
+
+read_failed:
+	kfree(fmtbuf);
+fmt_failed:
+	kfree(buf);
+}
+EXPORT_SYMBOL_GPL(visorchannel_dump_section);
diff --git a/drivers/staging/unisys/visorbus/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel_funcs.c
deleted file mode 100644
index b61f954..0000000
--- a/drivers/staging/unisys/visorbus/visorchannel_funcs.c
+++ /dev/null
@@ -1,663 +0,0 @@
-/* visorchannel_funcs.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  This provides Supervisor channel communication primitives, which are
- *  independent of the mechanism used to access the channel data.  All channel
- *  data is accessed using the memregion abstraction.  (memregion has both
- *  a CM2 implementation and a direct memory implementation.)
- */
-
-#include "globals.h"
-#include "visorbus.h"
-#include <linux/uuid.h>
-
-#define MYDRVNAME "visorchannel"
-
-struct visorchannel {
-	struct memregion *memregion;	/* from visor_memregion_create() */
-	struct channel_header chan_hdr;
-	uuid_le guid;
-	ulong size;
-	BOOL needs_lock;	/* channel creator knows if more than one
-				 * thread will be inserting or removing */
-	spinlock_t insert_lock; /* protect head writes in chan_hdr */
-	spinlock_t remove_lock;	/* protect tail writes in chan_hdr */
-
-	struct {
-		struct signal_queue_header req_queue;
-		struct signal_queue_header rsp_queue;
-		struct signal_queue_header event_queue;
-		struct signal_queue_header ack_queue;
-	} safe_uis_queue;
-};
-
-/* Creates the struct visorchannel abstraction for a data area in memory,
- * but does NOT modify this data area.
- */
-static struct visorchannel *
-visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
-			 struct visorchannel *parent, ulong off, uuid_le guid,
-			 BOOL needs_lock)
-{
-	struct visorchannel *p = NULL;
-	void *rc = NULL;
-
-	p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
-	if (!p) {
-		rc = NULL;
-		goto cleanup;
-	}
-	p->memregion = NULL;
-	p->needs_lock = needs_lock;
-	spin_lock_init(&p->insert_lock);
-	spin_lock_init(&p->remove_lock);
-
-	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	if (!parent)
-		p->memregion =
-		    visor_memregion_create(physaddr,
-					   sizeof(struct channel_header));
-	else
-		p->memregion =
-		    visor_memregion_create_overlapped(parent->memregion,
-				off, sizeof(struct channel_header));
-	if (!p->memregion) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
-				 sizeof(struct channel_header)) < 0) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (channel_bytes == 0)
-		/* we had better be a CLIENT of this channel */
-		channel_bytes = (ulong)p->chan_hdr.size;
-	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
-		/* we had better be a CLIENT of this channel */
-		guid = p->chan_hdr.chtype;
-	if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
-		rc = NULL;
-		goto cleanup;
-	}
-	p->size = channel_bytes;
-	p->guid = guid;
-
-	rc = p;
-cleanup:
-
-	if (!rc) {
-		if (!p) {
-			visorchannel_destroy(p);
-			p = NULL;
-		}
-	}
-	return rc;
-}
-
-struct visorchannel *
-visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
-{
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
-					FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create);
-
-struct visorchannel *
-visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
-			      uuid_le guid)
-{
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
-					TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
-
-struct visorchannel *
-visorchannel_create_overlapped(ulong channel_bytes,
-			       struct visorchannel *parent, ulong off,
-			       uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
-
-struct visorchannel *
-visorchannel_create_overlapped_with_lock(ulong channel_bytes,
-					 struct visorchannel *parent, ulong off,
-					 uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
-
-void
-visorchannel_destroy(struct visorchannel *channel)
-{
-	if (!channel)
-		return;
-	if (channel->memregion) {
-		visor_memregion_destroy(channel->memregion);
-		channel->memregion = NULL;
-	}
-	kfree(channel);
-}
-EXPORT_SYMBOL_GPL(visorchannel_destroy);
-
-HOSTADDRESS
-visorchannel_get_physaddr(struct visorchannel *channel)
-{
-	return visor_memregion_get_physaddr(channel->memregion);
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
-
-ulong
-visorchannel_get_nbytes(struct visorchannel *channel)
-{
-	return channel->size;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_nbytes);
-
-char *
-visorchannel_uuid_id(uuid_le *guid, char *s)
-{
-	sprintf(s, "%pUL", guid);
-	return s;
-}
-EXPORT_SYMBOL_GPL(visorchannel_uuid_id);
-
-char *
-visorchannel_id(struct visorchannel *channel, char *s)
-{
-	return visorchannel_uuid_id(&channel->guid, s);
-}
-EXPORT_SYMBOL_GPL(visorchannel_id);
-
-char *
-visorchannel_zoneid(struct visorchannel *channel, char *s)
-{
-	return visorchannel_uuid_id(&channel->chan_hdr.zone_uuid, s);
-}
-EXPORT_SYMBOL_GPL(visorchannel_zoneid);
-
-HOSTADDRESS
-visorchannel_get_clientpartition(struct visorchannel *channel)
-{
-	return channel->chan_hdr.partition_handle;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
-
-uuid_le
-visorchannel_get_uuid(struct visorchannel *channel)
-{
-	return channel->guid;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
-
-struct memregion *
-visorchannel_get_memregion(struct visorchannel *channel)
-{
-	return channel->memregion;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
-
-int
-visorchannel_read(struct visorchannel *channel, ulong offset,
-		  void *local, ulong nbytes)
-{
-	int rc = visor_memregion_read(channel->memregion, offset,
-				      local, nbytes);
-	if ((rc >= 0) && (offset == 0) &&
-	    (nbytes >= sizeof(struct channel_header))) {
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
-	}
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_read);
-
-int
-visorchannel_write(struct visorchannel *channel, ulong offset,
-		   void *local, ulong nbytes)
-{
-	if (offset == 0 && nbytes >= sizeof(struct channel_header))
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
-	return visor_memregion_write(channel->memregion, offset, local, nbytes);
-}
-EXPORT_SYMBOL_GPL(visorchannel_write);
-
-int
-visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
-		   ulong nbytes)
-{
-	int rc = -1;
-	int bufsize = 65536;
-	int written = 0;
-	u8 *buf = vmalloc(bufsize);
-
-	if (!buf)
-		goto cleanup;
-
-	memset(buf, ch, bufsize);
-	while (nbytes > 0) {
-		ulong thisbytes = bufsize;
-		int x = -1;
-
-		if (nbytes < thisbytes)
-			thisbytes = nbytes;
-		x = visor_memregion_write(channel->memregion, offset + written,
-					  buf, thisbytes);
-		if (x < 0) {
-			rc = x;
-			goto cleanup;
-		}
-		written += thisbytes;
-		nbytes -= thisbytes;
-	}
-	rc = 0;
-
-cleanup:
-	if (buf) {
-		vfree(buf);
-		buf = NULL;
-	}
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_clear);
-
-void __iomem  *
-visorchannel_get_header(struct visorchannel *channel)
-{
-	return (void __iomem *)&channel->chan_hdr;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_header);
-
-/** Return offset of a specific SIGNAL_QUEUE_HEADER from the beginning of a
- *  channel header
- */
-#define SIG_QUEUE_OFFSET(chan_hdr, q) \
-	((chan_hdr)->ch_space_offset + \
-	 ((q) * sizeof(struct signal_queue_header)))
-
-/** Return offset of a specific queue entry (data) from the beginning of a
- *  channel header
- */
-#define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
-	(SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
-	    ((slot) * (sig_hdr)->signal_size))
-
-/** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
- *  into host memory
- */
-#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
-	(visor_memregion_write(channel->memregion,			\
-			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
-			       offsetof(struct signal_queue_header, FIELD),\
-			       &((sig_hdr)->FIELD),			\
-			       sizeof((sig_hdr)->FIELD)) >= 0)
-
-static BOOL
-sig_read_header(struct visorchannel *channel, u32 queue,
-		struct signal_queue_header *sig_hdr)
-{
-	BOOL rc = FALSE;
-
-	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
-		goto cleanup;
-
-	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
-
-	if (visor_memregion_read(channel->memregion,
-				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
-				 sig_hdr,
-				 sizeof(struct signal_queue_header)) < 0) {
-		goto cleanup;
-	}
-	rc = TRUE;
-cleanup:
-	return rc;
-}
-
-static BOOL
-sig_do_data(struct visorchannel *channel, u32 queue,
-	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
-	    BOOL is_write)
-{
-	BOOL rc = FALSE;
-	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
-						 sig_hdr, slot);
-	if (is_write) {
-		if (visor_memregion_write(channel->memregion,
-					  signal_data_offset,
-					  data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
-	} else {
-		if (visor_memregion_read(channel->memregion, signal_data_offset,
-					 data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
-	}
-	rc = TRUE;
-cleanup:
-	return rc;
-}
-
-static inline BOOL
-sig_read_data(struct visorchannel *channel, u32 queue,
-	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
-	return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
-}
-
-static inline BOOL
-sig_write_data(struct visorchannel *channel, u32 queue,
-	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
-	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
-}
-
-static inline unsigned char
-safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
-			struct signal_queue_header *punsafe_sqh,
-			u32 *phead, u32 *ptail)
-{
-	if ((*phead >= psafe_sqh->max_slots) ||
-	    (*ptail >= psafe_sqh->max_slots)) {
-		/* Choose 0 or max, maybe based on current tail value */
-		*phead = 0;
-		*ptail = 0;
-
-		/* Sync with client as necessary */
-		punsafe_sqh->head = *phead;
-		punsafe_sqh->tail = *ptail;
-
-		return 0;
-	}
-	return 1;
-}				/* end safe_sig_queue_validate */
-
-static BOOL
-signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
-	if (sig_hdr.head == sig_hdr.tail)
-		return FALSE;	/* no signals to remove */
-
-	sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
-	if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
-		return FALSE;
-	sig_hdr.num_received++;
-
-	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
-	 * update host memory.
-	 */
-	mb(); /* required for channel synch */
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
-		return FALSE;
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
-		return FALSE;
-	return TRUE;
-}
-
-BOOL
-visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
-{
-	BOOL rc;
-
-	if (channel->needs_lock) {
-		spin_lock(&channel->remove_lock);
-		rc = signalremove_inner(channel, queue, msg);
-		spin_unlock(&channel->remove_lock);
-	} else {
-		rc = signalremove_inner(channel, queue, msg);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalremove);
-
-static BOOL
-signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
-
-	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
-	if (sig_hdr.head == sig_hdr.tail) {
-		sig_hdr.num_overflows++;
-		visor_memregion_write(channel->memregion,
-				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
-						       queue) +
-				      offsetof(struct signal_queue_header,
-					       num_overflows),
-				      &(sig_hdr.num_overflows),
-				      sizeof(sig_hdr.num_overflows));
-		return FALSE;
-	}
-
-	if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
-		return FALSE;
-
-	sig_hdr.num_sent++;
-
-	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
-	 * update host memory.
-	 */
-	mb(); /* required for channel synch */
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
-		return FALSE;
-	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
-		return FALSE;
-
-	return TRUE;
-}
-
-BOOL
-visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
-{
-	BOOL rc;
-
-	if (channel->needs_lock) {
-		spin_lock(&channel->insert_lock);
-		rc = signalinsert_inner(channel, queue, msg);
-		spin_unlock(&channel->insert_lock);
-	} else {
-		rc = signalinsert_inner(channel, queue, msg);
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
-
-int
-visorchannel_signalqueue_slots_avail(struct visorchannel *channel, u32 queue)
-{
-	struct signal_queue_header sig_hdr;
-	u32 slots_avail, slots_used;
-	u32 head, tail;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return 0;
-	head = sig_hdr.head;
-	tail = sig_hdr.tail;
-	if (head < tail)
-		head = head + sig_hdr.max_slots;
-	slots_used = (head - tail);
-	slots_avail = sig_hdr.max_signals - slots_used;
-	return (int)slots_avail;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
-
-int
-visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue)
-{
-	struct signal_queue_header sig_hdr;
-
-	if (!sig_read_header(channel, queue, &sig_hdr))
-		return 0;
-	return (int)sig_hdr.max_signals;
-}
-EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
-
-static void
-sigqueue_debug(struct signal_queue_header *q, int which, struct seq_file *seq)
-{
-	seq_printf(seq, "Signal Queue #%d\n", which);
-	seq_printf(seq, "   VersionId          = %lu\n", (ulong)q->version);
-	seq_printf(seq, "   Type               = %lu\n", (ulong)q->chtype);
-	seq_printf(seq, "   oSignalBase        = %llu\n",
-		   (long long)q->sig_base_offset);
-	seq_printf(seq, "   SignalSize         = %lu\n", (ulong)q->signal_size);
-	seq_printf(seq, "   MaxSignalSlots     = %lu\n",
-		   (ulong)q->max_slots);
-	seq_printf(seq, "   MaxSignals         = %lu\n", (ulong)q->max_signals);
-	seq_printf(seq, "   FeatureFlags       = %-16.16Lx\n",
-		   (long long)q->features);
-	seq_printf(seq, "   NumSignalsSent     = %llu\n",
-		   (long long)q->num_sent);
-	seq_printf(seq, "   NumSignalsReceived = %llu\n",
-		   (long long)q->num_received);
-	seq_printf(seq, "   NumOverflows       = %llu\n",
-		   (long long)q->num_overflows);
-	seq_printf(seq, "   Head               = %lu\n", (ulong)q->head);
-	seq_printf(seq, "   Tail               = %lu\n", (ulong)q->tail);
-}
-
-void
-visorchannel_debug(struct visorchannel *channel, int num_queues,
-		   struct seq_file *seq, u32 off)
-{
-	HOSTADDRESS addr = 0;
-	ulong nbytes = 0, nbytes_region = 0;
-	struct memregion *memregion = NULL;
-	struct channel_header hdr;
-	struct channel_header *phdr = &hdr;
-	int i = 0;
-	int errcode = 0;
-
-	if (!channel)
-		return;
-	memregion = channel->memregion;
-	if (!memregion)
-		return;
-
-	addr = visor_memregion_get_physaddr(memregion);
-	nbytes_region = visor_memregion_get_nbytes(memregion);
-	errcode = visorchannel_read(channel, off,
-				    phdr, sizeof(struct channel_header));
-	if (errcode < 0) {
-		seq_printf(seq,
-			   "Read of channel header failed with errcode=%d)\n",
-			   errcode);
-		if (off == 0) {
-			phdr = &channel->chan_hdr;
-			seq_puts(seq, "(following data may be stale)\n");
-		} else {
-			return;
-		}
-	}
-	nbytes = (ulong)(phdr->size);
-	seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n",
-		   addr + off, nbytes, nbytes_region);
-	seq_printf(seq, "Type            = %pUL\n", &phdr->chtype);
-	seq_printf(seq, "ZoneGuid        = %pUL\n", &phdr->zone_uuid);
-	seq_printf(seq, "Signature       = 0x%-16.16Lx\n",
-		   (long long)phdr->signature);
-	seq_printf(seq, "LegacyState     = %lu\n", (ulong)phdr->legacy_state);
-	seq_printf(seq, "SrvState        = %lu\n", (ulong)phdr->srv_state);
-	seq_printf(seq, "CliStateBoot    = %lu\n", (ulong)phdr->cli_state_boot);
-	seq_printf(seq, "CliStateOS      = %lu\n", (ulong)phdr->cli_state_os);
-	seq_printf(seq, "HeaderSize      = %lu\n", (ulong)phdr->header_size);
-	seq_printf(seq, "Size            = %llu\n", (long long)phdr->size);
-	seq_printf(seq, "Features        = 0x%-16.16llx\n",
-		   (long long)phdr->features);
-	seq_printf(seq, "PartitionHandle = 0x%-16.16llx\n",
-		   (long long)phdr->partition_handle);
-	seq_printf(seq, "Handle          = 0x%-16.16llx\n",
-		   (long long)phdr->handle);
-	seq_printf(seq, "VersionId       = %lu\n", (ulong)phdr->version_id);
-	seq_printf(seq, "oChannelSpace   = %llu\n",
-		   (long long)phdr->ch_space_offset);
-	if ((phdr->ch_space_offset == 0) || (errcode < 0))
-		;
-	else
-		for (i = 0; i < num_queues; i++) {
-			struct signal_queue_header q;
-
-			errcode = visorchannel_read(channel,
-						    off +
-						    phdr->ch_space_offset +
-						    (i * sizeof(q)),
-						    &q, sizeof(q));
-			if (errcode < 0) {
-				seq_printf(seq,
-					   "failed to read signal queue #%d from channel @0x%-16.16Lx errcode=%d\n",
-					   i, addr, errcode);
-				continue;
-			}
-			sigqueue_debug(&q, i, seq);
-		}
-	seq_printf(seq, "--- End   channel @0x%-16.16Lx for 0x%lx bytes ---\n",
-		   addr + off, nbytes);
-}
-EXPORT_SYMBOL_GPL(visorchannel_debug);
-
-void
-visorchannel_dump_section(struct visorchannel *chan, char *s,
-			  int off, int len, struct seq_file *seq)
-{
-	char *buf, *tbuf, *fmtbuf;
-	int fmtbufsize = 0;
-	int i;
-	int errcode = 0;
-
-	fmtbufsize = 100 * COVQ(len, 16);
-	buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
-	if (!buf)
-		return;
-	fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
-	if (!fmtbuf)
-		goto fmt_failed;
-
-	errcode = visorchannel_read(chan, off, buf, len);
-	if (errcode < 0)
-		goto read_failed;
-	seq_printf(seq, "channel %s:\n", s);
-	tbuf = buf;
-	while (len > 0) {
-		i = (len < 16) ? len : 16;
-		hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
-		seq_printf(seq, "%s\n", fmtbuf);
-		tbuf += 16;
-		len -= 16;
-	}
-
-read_failed:
-	kfree(fmtbuf);
-fmt_failed:
-	kfree(buf);
-}
-EXPORT_SYMBOL_GPL(visorchannel_dump_section);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 032/141] staging: unisys: remove globals.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (30 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 031/141] staging: unisys: rename visorchannel_funcs.c to visorchannel.c Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 033/141] staging: unisys: remove visorbus_private.h Benjamin Romer
                   ` (111 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

globals.h is only included in visorchannel.c and only contains 2 includes.
These can be included directly in visorchannel.c.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/globals.h      | 27 --------------------------
 drivers/staging/unisys/visorbus/visorchannel.c |  3 ++-
 2 files changed, 2 insertions(+), 28 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/globals.h

diff --git a/drivers/staging/unisys/visorbus/globals.h b/drivers/staging/unisys/visorbus/globals.h
deleted file mode 100644
index 0ed8e1d..0000000
--- a/drivers/staging/unisys/visorbus/globals.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* globals.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHANNEL_GLOBALS_H__
-#define __VISORCHANNEL_GLOBALS_H__
-
-#include "timskmod.h"
-#include "memregion.h"
-#include "version.h"
-
-#define MYDRVNAME "visorchannel"
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index b61f954..33a4360 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -22,7 +22,8 @@
  *  a CM2 implementation and a direct memory implementation.)
  */
 
-#include "globals.h"
+#include "memregion.h"
+#include "version.h"
 #include "visorbus.h"
 #include <linux/uuid.h>
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 033/141] staging: unisys: remove visorbus_private.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (31 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 032/141] staging: unisys: remove globals.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 034/141] staging: unisys: remove visorchipset_umode.h Benjamin Romer
                   ` (110 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

visorbus_private.h is only included from visorbus_main.c and has no
other purpose.  The code can be easily moved into visorbus_main.c.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    | 27 +++++++++++-
 drivers/staging/unisys/visorbus/visorbus_private.h | 50 ----------------------
 2 files changed, 26 insertions(+), 51 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d5556e2..13a270d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -17,12 +17,37 @@
 
 #include <linux/uuid.h>
 
-#include "visorbus_private.h"
+#include "visorbus.h"
+#include "visorchipset.h"
+#include "version.h"
 #include "timskmod.h"
 #include "periodic_work.h"
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
 #include "vbusdeviceinfo.h"
+
+/* module parameters */
+int visorbus_debug;
+int visorbus_forcematch;
+int visorbus_forcenomatch;
+#define MAXDEVICETEST 4
+int visorbus_devicetest;
+int visorbus_debugref;
+int visorbus_serialloopbacktest;
+#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
+
+/** This is the private data that we store for each bus device instance.
+ */
+struct visorbus_devdata {
+	int devno;		/* this is the chipset busNo */
+	struct list_head list_all;
+	struct device *dev;
+	struct kobject kobj;
+	struct visorchannel *chan;	/* channel area for bus itself */
+	bool vbus_valid;
+	struct spar_vbus_headerinfo vbus_hdr_info;
+};
+
 /* These forward declarations are required since our drivers are out-of-tree.
  * The structures referenced are kernel-private and are not in the headers, but
  * it is impossible to make a functioning bus driver without them.
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
deleted file mode 100644
index 47ab488..0000000
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* visorbus_private.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORBUS_PRIVATE_H__
-#define __VISORBUS_PRIVATE_H__
-
-#include "timskmod.h"
-#include "visorbus.h"
-#include "visorchipset.h"
-#include "visorbus.h"
-#include "version.h"
-#include "vbuschannel.h"
-
-/* module parameters */
-extern int visorbus_debug;
-extern int visorbus_forcematch;
-extern int visorbus_forcenomatch;
-#define MAXDEVICETEST 4
-extern int visorbus_devicetest;
-extern int visorbus_debugref;
-extern int visorbus_serialloopbacktest;
-#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
-
-/** This is the private data that we store for each bus device instance.
- */
-struct visorbus_devdata {
-	int devno;		/* this is the chipset busNo */
-	struct list_head list_all;
-	struct device *dev;
-	struct kobject kobj;
-	struct visorchannel *chan;	/* channel area for bus itself */
-	bool vbus_valid;
-	struct spar_vbus_headerinfo vbus_hdr_info;
-};
-
-#endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 034/141] staging: unisys: remove visorchipset_umode.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (32 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 033/141] staging: unisys: remove visorbus_private.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 035/141] staging: unisys: moving file.h functionality to visorchipset.h Benjamin Romer
                   ` (109 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

removes visorchipset_umode.h and pass functionality to
visorchipset.h

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/file.c         |  1 -
 drivers/staging/unisys/visorchipset/visorchipset.h |  1 +
 .../unisys/visorchipset/visorchipset_umode.h       | 35 ----------------------
 3 files changed, 1 insertion(+), 36 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset_umode.h

diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index 9822e9d..153f736 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -23,7 +23,6 @@
 #include <linux/fs.h>
 #include "version.h"
 #include "visorchipset.h"
-#include "visorchipset_umode.h"
 #include "visorbus.h"
 #include "uisutils.h"
 #include "file.h"
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 1d66c37..dcf8a23 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -28,6 +28,7 @@
 #include "vbushelper.h"
 
 #define MYDRVNAME "visorchipset"
+#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
 
 /** Describes the state from the perspective of which controlvm messages have
  *  been received for a bus or device.
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h
deleted file mode 100644
index 8af5bf3..0000000
--- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* visorchipset_umode.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/** @file *********************************************************************
- *
- *  This describes structures needed for the interface between the
- *  visorchipset driver and a user-mode component that opens the device.
- *
- ******************************************************************************
- */
-
-#ifndef __VISORCHIPSET_UMODE_H
-#define __VISORCHIPSET_UMODE_H
-
-/** The user-mode program can access the control channel buffer directly
- *  via this memory map.
- */
-#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
-#define VISORCHIPSET_MMAP_CONTROLCHANSIZE	0x00400000	/* 4MB */
-
-#endif /* __VISORCHIPSET_UMODE_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 035/141] staging: unisys: moving file.h functionality to visorchipset.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (33 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 034/141] staging: unisys: remove visorchipset_umode.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 036/141] staging: unisys: remove file.c and pass functionality to visorchipset Benjamin Romer
                   ` (108 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

this patch simply migrates file.h functionality to visorchipset.h

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/file.c         |  5 +++--
 drivers/staging/unisys/visorchipset/file.h         | 25 ----------------------
 drivers/staging/unisys/visorchipset/visorchipset.h |  4 +++-
 .../unisys/visorchipset/visorchipset_main.c        |  1 -
 4 files changed, 6 insertions(+), 29 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorchipset/file.h

diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
index 153f736..c0bd416 100644
--- a/drivers/staging/unisys/visorchipset/file.c
+++ b/drivers/staging/unisys/visorchipset/file.c
@@ -19,13 +19,14 @@
  * communicate with the visorchipset driver using a device/file interface.
  */
 
-#include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/mm.h>
+
 #include "version.h"
 #include "visorchipset.h"
 #include "visorbus.h"
 #include "uisutils.h"
-#include "file.h"
+#include "visorchipset.h"
 
 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c
 
diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h
deleted file mode 100644
index 6ff28a1..0000000
--- a/drivers/staging/unisys/visorchipset/file.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* file.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __FILE_H__
-#define __FILE_H__
-
-int visorchipset_file_init(dev_t majorDev,
-			   struct visorchannel **pControlVm_channel);
-void visorchipset_file_cleanup(dev_t major_dev);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index dcf8a23..93763ee 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -188,5 +188,7 @@ void *visorchipset_cache_alloc(struct kmem_cache *pool,
 			       bool ok_to_block, char *fn, int ln);
 void visorchipset_cache_free(struct kmem_cache *pool, void *p,
 			     char *fn, int ln);
-
+int visorchipset_file_init(dev_t majorDev,
+			   struct visorchannel **pControlVm_channel);
+void visorchipset_file_cleanup(dev_t major_dev);
 #endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index a8448c2..34ac17b 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -20,7 +20,6 @@
 #include "procobjecttree.h"
 #include "visorbus.h"
 #include "periodic_work.h"
-#include "file.h"
 #include "parser.h"
 #include "uisutils.h"
 #include "controlvmcompletionstatus.h"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 036/141] staging: unisys: remove file.c and pass functionality to visorchipset
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (34 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 035/141] staging: unisys: moving file.h functionality to visorchipset.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 037/141] staging: unisys: move parser.[ch] functionality into visorchipset Benjamin Romer
                   ` (107 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch trasitions the include files and functions from file.c
and places them into visorchipset_main.c

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorchipset/Makefile       |   2 +-
 drivers/staging/unisys/visorchipset/file.c         | 162 ---------------------
 .../unisys/visorchipset/visorchipset_main.c        | 136 ++++++++++++++++-
 3 files changed, 136 insertions(+), 164 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorchipset/file.c

diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
index 1bf6699..6886cb7 100644
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ b/drivers/staging/unisys/visorchipset/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset.o
 
-visorchipset-y := visorchipset_main.o file.o parser.o
+visorchipset-y := visorchipset_main.o parser.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/uislib
diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
deleted file mode 100644
index c0bd416..0000000
--- a/drivers/staging/unisys/visorchipset/file.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* file.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* This contains the implementation that allows a usermode program to
- * communicate with the visorchipset driver using a device/file interface.
- */
-
-#include <linux/fs.h>
-#include <linux/mm.h>
-
-#include "version.h"
-#include "visorchipset.h"
-#include "visorbus.h"
-#include "uisutils.h"
-#include "visorchipset.h"
-
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c
-
-static struct cdev file_cdev;
-static struct visorchannel **file_controlvm_channel;
-
-void
-visorchipset_file_cleanup(dev_t major_dev)
-{
-	if (file_cdev.ops)
-		cdev_del(&file_cdev);
-	file_cdev.ops = NULL;
-	unregister_chrdev_region(major_dev, 1);
-}
-
-static int
-visorchipset_open(struct inode *inode, struct file *file)
-{
-	unsigned minor_number = iminor(inode);
-
-	if (minor_number)
-		return -ENODEV;
-	file->private_data = NULL;
-	return 0;
-}
-
-static int
-visorchipset_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static int
-visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	unsigned long physaddr = 0;
-	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
-	GUEST_PHYSICAL_ADDRESS addr = 0;
-
-	/* sv_enable_dfp(); */
-	if (offset & (PAGE_SIZE - 1))
-		return -ENXIO;	/* need aligned offsets */
-
-	switch (offset) {
-	case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
-		vma->vm_flags |= VM_IO;
-		if (!*file_controlvm_channel)
-			return -ENXIO;
-
-		visorchannel_read(*file_controlvm_channel,
-			offsetof(struct spar_controlvm_channel_protocol,
-				 gp_control_channel),
-			&addr, sizeof(addr));
-		if (!addr)
-			return -ENXIO;
-
-		physaddr = (unsigned long)addr;
-		if (remap_pfn_range(vma, vma->vm_start,
-				    physaddr >> PAGE_SHIFT,
-				    vma->vm_end - vma->vm_start,
-				    /*pgprot_noncached */
-				    (vma->vm_page_prot))) {
-			return -EAGAIN;
-		}
-		break;
-	default:
-		return -ENOSYS;
-	}
-	return 0;
-}
-
-static long visorchipset_ioctl(struct file *file, unsigned int cmd,
-			       unsigned long arg)
-{
-	s64 adjustment;
-	s64 vrtc_offset;
-
-	switch (cmd) {
-	case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
-		/* get the physical rtc offset */
-		vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
-		if (copy_to_user((void __user *)arg, &vrtc_offset,
-				 sizeof(vrtc_offset))) {
-			return -EFAULT;
-		}
-		return SUCCESS;
-	case VMCALL_UPDATE_PHYSICAL_TIME:
-		if (copy_from_user(&adjustment, (void __user *)arg,
-				   sizeof(adjustment))) {
-			return -EFAULT;
-		}
-		return issue_vmcall_update_physical_time(adjustment);
-	default:
-		return -EFAULT;
-	}
-}
-
-static const struct file_operations visorchipset_fops = {
-	.owner = THIS_MODULE,
-	.open = visorchipset_open,
-	.read = NULL,
-	.write = NULL,
-	.unlocked_ioctl = visorchipset_ioctl,
-	.release = visorchipset_release,
-	.mmap = visorchipset_mmap,
-};
-
-int
-visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
-{
-	int rc = 0;
-
-	file_controlvm_channel = controlvm_channel;
-	cdev_init(&file_cdev, &visorchipset_fops);
-	file_cdev.owner = THIS_MODULE;
-	if (MAJOR(major_dev) == 0) {
-		rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME);
-		/* dynamic major device number registration required */
-		if (rc < 0)
-			return rc;
-	} else {
-		/* static major device number registration required */
-		rc = register_chrdev_region(major_dev, 1, MYDRVNAME);
-		if (rc < 0)
-			return rc;
-	}
-	rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
-	if (rc < 0) {
-		unregister_chrdev_region(major_dev, 1);
-		return rc;
-	}
-	return 0;
-}
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 34ac17b..d5bd1a1 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -16,7 +16,6 @@
  */
 
 #include "version.h"
-#include "visorchipset.h"
 #include "procobjecttree.h"
 #include "visorbus.h"
 #include "periodic_work.h"
@@ -24,7 +23,10 @@
 #include "uisutils.h"
 #include "controlvmcompletionstatus.h"
 #include "guestlinuxdebug.h"
+#include "visorchipset.h"
 
+#include <linux/fs.h>
+#include <linux/mm.h>
 #include <linux/nls.h>
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
@@ -56,6 +58,23 @@ static int visorchipset_testteardown;
 static int visorchipset_disable_controlvm;
 static int visorchipset_holdchipsetready;
 
+static int
+visorchipset_open(struct inode *inode, struct file *file)
+{
+	unsigned minor_number = iminor(inode);
+
+	if (minor_number)
+		return -ENODEV;
+	file->private_data = NULL;
+	return 0;
+}
+
+static int
+visorchipset_release(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
 /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
 * we switch to slow polling mode.  As soon as we get a controlvm
 * message, we switch back to fast polling mode.
@@ -74,6 +93,8 @@ static struct delayed_work periodic_controlvm_work;
 static struct workqueue_struct *periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(notifier_lock);
 
+static struct cdev file_cdev;
+static struct visorchannel **file_controlvm_channel;
 static struct controlvm_message_header g_chipset_msg_hdr;
 static const uuid_le spar_diag_pool_channel_protocol_uuid =
 	SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
@@ -2169,6 +2190,110 @@ static ssize_t deviceenabled_store(struct device *dev,
 	return count;
 }
 
+static int
+visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	unsigned long physaddr = 0;
+	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+	GUEST_PHYSICAL_ADDRESS addr = 0;
+
+	/* sv_enable_dfp(); */
+	if (offset & (PAGE_SIZE - 1))
+		return -ENXIO;	/* need aligned offsets */
+
+	switch (offset) {
+	case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
+		vma->vm_flags |= VM_IO;
+		if (!*file_controlvm_channel)
+			return -ENXIO;
+
+		visorchannel_read(*file_controlvm_channel,
+			offsetof(struct spar_controlvm_channel_protocol,
+				 gp_control_channel),
+			&addr, sizeof(addr));
+		if (!addr)
+			return -ENXIO;
+
+		physaddr = (unsigned long)addr;
+		if (remap_pfn_range(vma, vma->vm_start,
+				    physaddr >> PAGE_SHIFT,
+				    vma->vm_end - vma->vm_start,
+				    /*pgprot_noncached */
+				    (vma->vm_page_prot))) {
+			return -EAGAIN;
+		}
+		break;
+	default:
+		return -ENXIO;
+	}
+	return 0;
+}
+
+static long visorchipset_ioctl(struct file *file, unsigned int cmd,
+			       unsigned long arg)
+{
+	s64 adjustment;
+	s64 vrtc_offset;
+
+	switch (cmd) {
+	case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
+		/* get the physical rtc offset */
+		vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
+		if (copy_to_user((void __user *)arg, &vrtc_offset,
+				 sizeof(vrtc_offset))) {
+			return -EFAULT;
+		}
+		return SUCCESS;
+	case VMCALL_UPDATE_PHYSICAL_TIME:
+		if (copy_from_user(&adjustment, (void __user *)arg,
+				   sizeof(adjustment))) {
+			return -EFAULT;
+		}
+		return issue_vmcall_update_physical_time(adjustment);
+	default:
+		return -EFAULT;
+	}
+}
+
+static const struct file_operations visorchipset_fops = {
+	.owner = THIS_MODULE,
+	.open = visorchipset_open,
+	.read = NULL,
+	.write = NULL,
+	.unlocked_ioctl = visorchipset_ioctl,
+	.release = visorchipset_release,
+	.mmap = visorchipset_mmap,
+};
+
+int
+visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
+{
+	int rc = 0;
+
+	file_controlvm_channel = controlvm_channel;
+	cdev_init(&file_cdev, &visorchipset_fops);
+	file_cdev.owner = THIS_MODULE;
+	if (MAJOR(major_dev) == 0) {
+		rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME);
+		/* dynamic major device number registration required */
+		if (rc < 0)
+			return rc;
+	} else {
+		/* static major device number registration required */
+		rc = register_chrdev_region(major_dev, 1, MYDRVNAME);
+		if (rc < 0)
+			return rc;
+	}
+	rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
+	if (rc < 0) {
+		unregister_chrdev_region(major_dev, 1);
+		return rc;
+	}
+	return 0;
+}
+
+
+
 static int __init
 visorchipset_init(void)
 {
@@ -2262,6 +2387,15 @@ cleanup:
 	return rc;
 }
 
+void
+visorchipset_file_cleanup(dev_t major_dev)
+{
+	if (file_cdev.ops)
+		cdev_del(&file_cdev);
+	file_cdev.ops = NULL;
+	unregister_chrdev_region(major_dev, 1);
+}
+
 static void
 visorchipset_exit(void)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 037/141] staging: unisys: move parser.[ch] functionality into visorchipset
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (35 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 036/141] staging: unisys: remove file.c and pass functionality to visorchipset Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 038/141] staging: unisys: move visorchipset files to visorbus Benjamin Romer
                   ` (106 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch moves includes files and functions from parser.[ch] into
visorchipset.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    |   2 +-
 drivers/staging/unisys/visorchipset/Makefile       |   2 +-
 drivers/staging/unisys/visorchipset/parser.c       | 430 ---------------------
 drivers/staging/unisys/visorchipset/parser.h       |  45 ---
 drivers/staging/unisys/visorchipset/visorchipset.h |  24 +-
 .../unisys/visorchipset/visorchipset_main.c        | 411 +++++++++++++++++++-
 6 files changed, 432 insertions(+), 482 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorchipset/parser.c
 delete mode 100644 drivers/staging/unisys/visorchipset/parser.h

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 13a270d..d7ca116 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -2040,7 +2040,7 @@ visorbus_init(void)
 
 	POSTCODE_LINUX_3(DRIVER_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
 	bus_device_info_init(&clientbus_driverinfo,
-			     "clientbus", MYDRVNAME,
+			     "clientbus", "visorbus",
 			     VERSION, NULL);
 
 	/* process module options */
diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
index 6886cb7..e9168d8 100644
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ b/drivers/staging/unisys/visorchipset/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset.o
 
-visorchipset-y := visorchipset_main.o parser.o
+visorchipset-y := visorchipset_main.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/uislib
diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c
deleted file mode 100644
index 6ca6da8..0000000
--- a/drivers/staging/unisys/visorchipset/parser.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/* parser.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#include "parser.h"
-#include "memregion.h"
-#include "controlvmchannel.h"
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/uuid.h>
-
-#define MYDRVNAME "visorchipset_parser"
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_parser_c
-
-/* We will refuse to allocate more than this many bytes to copy data from
- * incoming payloads.  This serves as a throttling mechanism.
- */
-#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
-static unsigned long controlvm_payload_bytes_buffered;
-
-struct parser_context {
-	unsigned long allocbytes;
-	unsigned long param_bytes;
-	u8 *curr;
-	unsigned long bytes_remaining;
-	bool byte_stream;
-	char data[0];
-};
-
-static struct parser_context *
-parser_init_guts(u64 addr, u32 bytes, bool local,
-		 bool standard_payload_header, bool *retry)
-{
-	int allocbytes = sizeof(struct parser_context) + bytes;
-	struct parser_context *rc = NULL;
-	struct parser_context *ctx = NULL;
-	struct memregion *rgn = NULL;
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (retry)
-		*retry = false;
-	if (!standard_payload_header)
-		/* alloc and 0 extra byte to ensure payload is
-		 * '\0'-terminated
-		 */
-		allocbytes++;
-	if ((controlvm_payload_bytes_buffered + bytes)
-	    > MAX_CONTROLVM_PAYLOAD_BYTES) {
-		if (retry)
-			*retry = true;
-		rc = NULL;
-		goto cleanup;
-	}
-	ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
-	if (!ctx) {
-		if (retry)
-			*retry = true;
-		rc = NULL;
-		goto cleanup;
-	}
-
-	ctx->allocbytes = allocbytes;
-	ctx->param_bytes = bytes;
-	ctx->curr = NULL;
-	ctx->bytes_remaining = 0;
-	ctx->byte_stream = false;
-	if (local) {
-		void *p;
-
-		if (addr > virt_to_phys(high_memory - 1)) {
-			rc = NULL;
-			goto cleanup;
-		}
-		p = __va((unsigned long) (addr));
-		memcpy(ctx->data, p, bytes);
-	} else {
-		rgn = visor_memregion_create(addr, bytes);
-		if (!rgn) {
-			rc = NULL;
-			goto cleanup;
-		}
-		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
-			rc = NULL;
-			goto cleanup;
-		}
-	}
-	if (!standard_payload_header) {
-		ctx->byte_stream = true;
-		rc = ctx;
-		goto cleanup;
-	}
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	if (phdr->total_length != bytes) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->total_length < phdr->header_length) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->header_length <
-	    sizeof(struct spar_controlvm_parameters_header)) {
-		rc = NULL;
-		goto cleanup;
-	}
-
-	rc = ctx;
-cleanup:
-	if (rgn) {
-		visor_memregion_destroy(rgn);
-		rgn = NULL;
-	}
-	if (rc) {
-		controlvm_payload_bytes_buffered += ctx->param_bytes;
-	} else {
-		if (ctx) {
-			parser_done(ctx);
-			ctx = NULL;
-		}
-	}
-	return rc;
-}
-
-struct parser_context *
-parser_init(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, true, retry);
-}
-
-/* Call this instead of parser_init() if the payload area consists of just
- * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
- * structures.  Afterwards, you can call parser_simpleString_get() or
- * parser_byteStream_get() to obtain the data.
- */
-struct parser_context *
-parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, false, retry);
-}
-
-/* Obtain '\0'-terminated copy of string in payload area.
- */
-char *
-parser_simpleString_get(struct parser_context *ctx)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	return ctx->data;	/* note this IS '\0'-terminated, because of
-				 * the num of bytes we alloc+clear in
-				 * parser_init_byteStream() */
-}
-
-/* Obtain a copy of the buffer in the payload area.
- */
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	if (nbytes)
-		*nbytes = ctx->param_bytes;
-	return (void *)ctx->data;
-}
-
-uuid_le
-parser_id_get(struct parser_context *ctx)
-{
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (ctx == NULL)
-		return NULL_UUID_LE;
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	return phdr->id;
-}
-
-void
-parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
-{
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (ctx == NULL)
-		goto Away;
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	switch (which_string) {
-	case PARSERSTRING_INITIATOR:
-		ctx->curr = ctx->data + phdr->initiator_offset;
-		ctx->bytes_remaining = phdr->initiator_length;
-		break;
-	case PARSERSTRING_TARGET:
-		ctx->curr = ctx->data + phdr->target_offset;
-		ctx->bytes_remaining = phdr->target_length;
-		break;
-	case PARSERSTRING_CONNECTION:
-		ctx->curr = ctx->data + phdr->connection_offset;
-		ctx->bytes_remaining = phdr->connection_length;
-		break;
-	case PARSERSTRING_NAME:
-		ctx->curr = ctx->data + phdr->name_offset;
-		ctx->bytes_remaining = phdr->name_length;
-		break;
-	default:
-		break;
-	}
-
-Away:
-	return;
-}
-
-void
-parser_done(struct parser_context *ctx)
-{
-	if (!ctx)
-		return;
-	controlvm_payload_bytes_buffered -= ctx->param_bytes;
-	kfree(ctx);
-}
-
-/** Return length of string not counting trailing spaces. */
-static int
-string_length_no_trail(char *s, int len)
-{
-	int i = len - 1;
-
-	while (i >= 0) {
-		if (!isspace(s[i]))
-			return i + 1;
-		i--;
-	}
-	return 0;
-}
-
-/** Grab the next name and value out of the parameter buffer.
- *  The entire parameter buffer looks like this:
- *      <name>=<value>\0
- *      <name>=<value>\0
- *      ...
- *      \0
- *  If successful, the next <name> value is returned within the supplied
- *  <nam> buffer (the value is always upper-cased), and the corresponding
- *  <value> is returned within a kmalloc()ed buffer, whose pointer is
- *  provided as the return value of this function.
- *  (The total number of bytes allocated is strlen(<value>)+1.)
- *
- *  NULL is returned to indicate failure, which can occur for several reasons:
- *  - all <name>=<value> pairs have already been processed
- *  - bad parameter
- *  - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
- *    the confines of the parameter buffer)
- *  - the <nam> buffer is not large enough to hold the <name> of the next
- *    parameter
- */
-void *
-parser_param_get(struct parser_context *ctx, char *nam, int namesize)
-{
-	u8 *pscan, *pnam = nam;
-	unsigned long nscan;
-	int value_length = -1, orig_value_length = -1;
-	void *value = NULL;
-	int i;
-	int closing_quote = 0;
-
-	if (!ctx)
-		return NULL;
-	pscan = ctx->curr;
-	nscan = ctx->bytes_remaining;
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\0')
-		/*  This is the normal return point after you have processed
-		 *  all of the <name>=<value> pairs in a syntactically-valid
-		 *  parameter buffer.
-		 */
-		return NULL;
-
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	while (*pscan != ':') {
-		if (namesize <= 0)
-			return NULL;
-		*pnam = toupper(*pscan);
-		pnam++;
-		namesize--;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (namesize <= 0)
-		return NULL;
-	*pnam = '\0';
-	nam[string_length_no_trail(nam, strlen(nam))] = '\0';
-
-	/* point to char immediately after ":" in "<name>:<value>" */
-	pscan++;
-	nscan--;
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\'' || *pscan == '"') {
-		closing_quote = *pscan;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	/* look for a separator character, terminator character, or
-	 * end of data
-	 */
-	for (i = 0, value_length = -1; i < nscan; i++) {
-		if (closing_quote) {
-			if (pscan[i] == '\0')
-				return NULL;
-			if (pscan[i] == closing_quote) {
-				value_length = i;
-				break;
-			}
-		} else
-		    if (pscan[i] == ',' || pscan[i] == ';'
-			|| pscan[i] == '\0') {
-			value_length = i;
-			break;
-		}
-	}
-	if (value_length < 0) {
-		if (closing_quote)
-			return NULL;
-		value_length = nscan;
-	}
-	orig_value_length = value_length;
-	if (closing_quote == 0)
-		value_length = string_length_no_trail(pscan, orig_value_length);
-	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
-	if (value == NULL)
-		return NULL;
-	memcpy(value, pscan, value_length);
-	((u8 *) (value))[value_length] = '\0';
-
-	pscan += orig_value_length;
-	nscan -= orig_value_length;
-
-	/* skip past separator or closing quote */
-	if (nscan > 0) {
-		if (*pscan != '\0') {
-			pscan++;
-			nscan--;
-		}
-	}
-
-	if (closing_quote && (nscan > 0)) {
-		/* we still need to skip around the real separator if present */
-		/* first, skip whitespace */
-		while (isspace(*pscan)) {
-			pscan++;
-			nscan--;
-			if (nscan == 0)
-				break;
-		}
-		if (nscan > 0) {
-			if (*pscan == ',' || *pscan == ';') {
-				pscan++;
-				nscan--;
-			} else if (*pscan != '\0') {
-				kfree(value);
-				value = NULL;
-				return NULL;
-			}
-		}
-	}
-	ctx->curr = pscan;
-	ctx->bytes_remaining = nscan;
-	return value;
-}
-
-void *
-parser_string_get(struct parser_context *ctx)
-{
-	u8 *pscan;
-	unsigned long nscan;
-	int value_length = -1;
-	void *value = NULL;
-	int i;
-
-	if (!ctx)
-		return NULL;
-	pscan = ctx->curr;
-	nscan = ctx->bytes_remaining;
-	if (nscan == 0)
-		return NULL;
-	if (!pscan)
-		return NULL;
-	for (i = 0, value_length = -1; i < nscan; i++)
-		if (pscan[i] == '\0') {
-			value_length = i;
-			break;
-		}
-	if (value_length < 0)	/* '\0' was not included in the length */
-		value_length = nscan;
-	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
-	if (value == NULL)
-		return NULL;
-	if (value_length > 0)
-		memcpy(value, pscan, value_length);
-	((u8 *) (value))[value_length] = '\0';
-	return value;
-}
diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h
deleted file mode 100644
index 3fe17c0..0000000
--- a/drivers/staging/unisys/visorchipset/parser.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* parser.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __PARSER_H__
-#define __PARSER_H__
-
-#include <linux/uuid.h>
-
-#include "channel.h"
-
-typedef enum {
-	PARSERSTRING_INITIATOR,
-	PARSERSTRING_TARGET,
-	PARSERSTRING_CONNECTION,
-	PARSERSTRING_NAME,
-} PARSER_WHICH_STRING;
-
-struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal,
-				   bool *tryAgain);
-struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local,
-				       bool *retry);
-void parser_param_start(struct parser_context *ctx,
-			PARSER_WHICH_STRING which_string);
-void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
-void *parser_string_get(struct parser_context *ctx);
-uuid_le parser_id_get(struct parser_context *ctx);
-char *parser_simpleString_get(struct parser_context *ctx);
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes);
-void parser_done(struct parser_context *ctx);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
index 93763ee..264a3e9 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
@@ -22,17 +22,37 @@
 
 #include "channel.h"
 #include "controlvmchannel.h"
-#include "parser.h"
 #include "procobjecttree.h"
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
-#define MYDRVNAME "visorchipset"
 #define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
 
 /** Describes the state from the perspective of which controlvm messages have
  *  been received for a bus or device.
  */
+
+enum PARSER_WHICH_STRING {
+	PARSERSTRING_INITIATOR,
+	PARSERSTRING_TARGET,
+	PARSERSTRING_CONNECTION,
+	PARSERSTRING_NAME,
+};
+
+struct visorchannel;
+struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal,
+				   bool *tryAgain);
+struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local,
+				       bool *retry);
+void parser_param_start(struct parser_context *ctx,
+			PARSER_WHICH_STRING which_string);
+void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
+void *parser_string_get(struct parser_context *ctx);
+uuid_le parser_id_get(struct parser_context *ctx);
+char *parser_simpleString_get(struct parser_context *ctx);
+void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes);
+void parser_done(struct parser_context *ctx);
+
 struct visorchipset_state {
 	u32 created:1;
 	u32 attached:1;
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index d5bd1a1..dc9f1dc 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -15,16 +15,19 @@
  * details.
  */
 
+#include "memregion.h"
+#include "controlvmchannel.h"
 #include "version.h"
 #include "procobjecttree.h"
 #include "visorbus.h"
 #include "periodic_work.h"
-#include "parser.h"
 #include "uisutils.h"
 #include "controlvmcompletionstatus.h"
 #include "guestlinuxdebug.h"
 #include "visorchipset.h"
 
+
+#include <linux/ctype.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/nls.h>
@@ -45,6 +48,7 @@
 #define POLLJIFFIES_CONTROLVMCHANNEL_FAST   1
 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
 
+#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
 /*
  * Module parameters
  */
@@ -57,6 +61,7 @@ static int visorchipset_clientregwait = 1;	/* default is on */
 static int visorchipset_testteardown;
 static int visorchipset_disable_controlvm;
 static int visorchipset_holdchipsetready;
+static unsigned long controlvm_payload_bytes_buffered;
 
 static int
 visorchipset_open(struct inode *inode, struct file *file)
@@ -89,6 +94,15 @@ static int clientregistered;
 #define MAX_CHIPSET_EVENTS 2
 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
 
+struct parser_context {
+	unsigned long allocbytes;
+	unsigned long param_bytes;
+	u8 *curr;
+	unsigned long bytes_remaining;
+	bool byte_stream;
+	char data[0];
+};
+
 static struct delayed_work periodic_controlvm_work;
 static struct workqueue_struct *periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(notifier_lock);
@@ -367,6 +381,397 @@ static void controlvm_respond_physdev_changestate(
 		struct controlvm_message_header *msg_hdr, int response,
 		struct spar_segment_state state);
 
+
+static struct parser_context *
+parser_init_guts(u64 addr, u32 bytes, bool local,
+		 bool standard_payload_header, bool *retry)
+{
+	int allocbytes = sizeof(struct parser_context) + bytes;
+	struct parser_context *rc = NULL;
+	struct parser_context *ctx = NULL;
+	struct memregion *rgn = NULL;
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (retry)
+		*retry = false;
+	if (!standard_payload_header)
+		/* alloc and 0 extra byte to ensure payload is
+		 * '\0'-terminated
+		 */
+		allocbytes++;
+	if ((controlvm_payload_bytes_buffered + bytes)
+	    > MAX_CONTROLVM_PAYLOAD_BYTES) {
+		if (retry)
+			*retry = true;
+		rc = NULL;
+		goto cleanup;
+	}
+	ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
+	if (!ctx) {
+		if (retry)
+			*retry = true;
+		rc = NULL;
+		goto cleanup;
+	}
+
+	ctx->allocbytes = allocbytes;
+	ctx->param_bytes = bytes;
+	ctx->curr = NULL;
+	ctx->bytes_remaining = 0;
+	ctx->byte_stream = false;
+	if (local) {
+		void *p;
+
+		if (addr > virt_to_phys(high_memory - 1)) {
+			rc = NULL;
+			goto cleanup;
+		}
+		p = __va((unsigned long) (addr));
+		memcpy(ctx->data, p, bytes);
+	} else {
+		rgn = visor_memregion_create(addr, bytes);
+		if (!rgn) {
+			rc = NULL;
+			goto cleanup;
+		}
+		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
+			rc = NULL;
+			goto cleanup;
+		}
+	}
+	if (!standard_payload_header) {
+		ctx->byte_stream = true;
+		rc = ctx;
+		goto cleanup;
+	}
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	if (phdr->total_length != bytes) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (phdr->total_length < phdr->header_length) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (phdr->header_length <
+	    sizeof(struct spar_controlvm_parameters_header)) {
+		rc = NULL;
+		goto cleanup;
+	}
+
+	rc = ctx;
+cleanup:
+	if (rgn) {
+		visor_memregion_destroy(rgn);
+		rgn = NULL;
+	}
+	if (rc) {
+		controlvm_payload_bytes_buffered += ctx->param_bytes;
+	} else {
+		if (ctx) {
+			parser_done(ctx);
+			ctx = NULL;
+		}
+	}
+	return rc;
+}
+
+struct parser_context *
+parser_init(u64 addr, u32 bytes, bool local, bool *retry)
+{
+	return parser_init_guts(addr, bytes, local, true, retry);
+}
+
+/* Call this instead of parser_init() if the payload area consists of just
+ * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
+ * structures.  Afterwards, you can call parser_simpleString_get() or
+ * parser_byteStream_get() to obtain the data.
+ */
+struct parser_context *
+parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
+{
+	return parser_init_guts(addr, bytes, local, false, retry);
+}
+
+/* Obtain '\0'-terminated copy of string in payload area.
+ */
+char *
+parser_simpleString_get(struct parser_context *ctx)
+{
+	if (!ctx->byte_stream)
+		return NULL;
+	return ctx->data;	/* note this IS '\0'-terminated, because of
+				 * the num of bytes we alloc+clear in
+				 * parser_init_byteStream() */
+}
+
+/* Obtain a copy of the buffer in the payload area.
+ */
+void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes)
+{
+	if (!ctx->byte_stream)
+		return NULL;
+	if (nbytes)
+		*nbytes = ctx->param_bytes;
+	return (void *)ctx->data;
+}
+
+uuid_le
+parser_id_get(struct parser_context *ctx)
+{
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (ctx == NULL)
+		return NULL_UUID_LE;
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	return phdr->id;
+}
+
+void
+parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
+{
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (ctx == NULL)
+		goto Away;
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	switch (which_string) {
+	case PARSERSTRING_INITIATOR:
+		ctx->curr = ctx->data + phdr->initiator_offset;
+		ctx->bytes_remaining = phdr->initiator_length;
+		break;
+	case PARSERSTRING_TARGET:
+		ctx->curr = ctx->data + phdr->target_offset;
+		ctx->bytes_remaining = phdr->target_length;
+		break;
+	case PARSERSTRING_CONNECTION:
+		ctx->curr = ctx->data + phdr->connection_offset;
+		ctx->bytes_remaining = phdr->connection_length;
+		break;
+	case PARSERSTRING_NAME:
+		ctx->curr = ctx->data + phdr->name_offset;
+		ctx->bytes_remaining = phdr->name_length;
+		break;
+	default:
+		break;
+	}
+
+Away:
+	return;
+}
+
+void
+parser_done(struct parser_context *ctx)
+{
+	if (!ctx)
+		return;
+	controlvm_payload_bytes_buffered -= ctx->param_bytes;
+	kfree(ctx);
+}
+
+/** Return length of string not counting trailing spaces. */
+static int
+string_length_no_trail(char *s, int len)
+{
+	int i = len - 1;
+
+	while (i >= 0) {
+		if (!isspace(s[i]))
+			return i + 1;
+		i--;
+	}
+	return 0;
+}
+
+/** Grab the next name and value out of the parameter buffer.
+ *  The entire parameter buffer looks like this:
+ *      <name>=<value>\0
+ *      <name>=<value>\0
+ *      ...
+ *      \0
+ *  If successful, the next <name> value is returned within the supplied
+ *  <nam> buffer (the value is always upper-cased), and the corresponding
+ *  <value> is returned within a kmalloc()ed buffer, whose pointer is
+ *  provided as the return value of this function.
+ *  (The total number of bytes allocated is strlen(<value>)+1.)
+ *
+ *  NULL is returned to indicate failure, which can occur for several reasons:
+ *  - all <name>=<value> pairs have already been processed
+ *  - bad parameter
+ *  - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
+ *    the confines of the parameter buffer)
+ *  - the <nam> buffer is not large enough to hold the <name> of the next
+ *    parameter
+ */
+void *
+parser_param_get(struct parser_context *ctx, char *nam, int namesize)
+{
+	u8 *pscan, *pnam = nam;
+	unsigned long nscan;
+	int value_length = -1, orig_value_length = -1;
+	void *value = NULL;
+	int i;
+	int closing_quote = 0;
+
+	if (!ctx)
+		return NULL;
+	pscan = ctx->curr;
+	nscan = ctx->bytes_remaining;
+	if (nscan == 0)
+		return NULL;
+	if (*pscan == '\0')
+		/*  This is the normal return point after you have processed
+		 *  all of the <name>=<value> pairs in a syntactically-valid
+		 *  parameter buffer.
+		 */
+		return NULL;
+
+	/* skip whitespace */
+	while (isspace(*pscan)) {
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+
+	while (*pscan != ':') {
+		if (namesize <= 0)
+			return NULL;
+		*pnam = toupper(*pscan);
+		pnam++;
+		namesize--;
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+	if (namesize <= 0)
+		return NULL;
+	*pnam = '\0';
+	nam[string_length_no_trail(nam, strlen(nam))] = '\0';
+
+	/* point to char immediately after ":" in "<name>:<value>" */
+	pscan++;
+	nscan--;
+	/* skip whitespace */
+	while (isspace(*pscan)) {
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+	if (nscan == 0)
+		return NULL;
+	if (*pscan == '\'' || *pscan == '"') {
+		closing_quote = *pscan;
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+
+	/* look for a separator character, terminator character, or
+	 * end of data
+	 */
+	for (i = 0, value_length = -1; i < nscan; i++) {
+		if (closing_quote) {
+			if (pscan[i] == '\0')
+				return NULL;
+			if (pscan[i] == closing_quote) {
+				value_length = i;
+				break;
+			}
+		} else
+		    if (pscan[i] == ',' || pscan[i] == ';'
+			|| pscan[i] == '\0') {
+			value_length = i;
+			break;
+		}
+	}
+	if (value_length < 0) {
+		if (closing_quote)
+			return NULL;
+		value_length = nscan;
+	}
+	orig_value_length = value_length;
+	if (closing_quote == 0)
+		value_length = string_length_no_trail(pscan, orig_value_length);
+	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
+	if (value == NULL)
+		return NULL;
+	memcpy(value, pscan, value_length);
+	((u8 *) (value))[value_length] = '\0';
+
+	pscan += orig_value_length;
+	nscan -= orig_value_length;
+
+	/* skip past separator or closing quote */
+	if (nscan > 0) {
+		if (*pscan != '\0') {
+			pscan++;
+			nscan--;
+		}
+	}
+
+	if (closing_quote && (nscan > 0)) {
+		/* we still need to skip around the real separator if present */
+		/* first, skip whitespace */
+		while (isspace(*pscan)) {
+			pscan++;
+			nscan--;
+			if (nscan == 0)
+				break;
+		}
+		if (nscan > 0) {
+			if (*pscan == ',' || *pscan == ';') {
+				pscan++;
+				nscan--;
+			} else if (*pscan != '\0') {
+				kfree(value);
+				value = NULL;
+				return NULL;
+			}
+		}
+	}
+	ctx->curr = pscan;
+	ctx->bytes_remaining = nscan;
+	return value;
+}
+
+void *
+parser_string_get(struct parser_context *ctx)
+{
+	u8 *pscan;
+	unsigned long nscan;
+	int value_length = -1;
+	void *value = NULL;
+	int i;
+
+	if (!ctx)
+		return NULL;
+	pscan = ctx->curr;
+	nscan = ctx->bytes_remaining;
+	if (nscan == 0)
+		return NULL;
+	if (!pscan)
+		return NULL;
+	for (i = 0, value_length = -1; i < nscan; i++)
+		if (pscan[i] == '\0') {
+			value_length = i;
+			break;
+		}
+	if (value_length < 0)	/* '\0' was not included in the length */
+		value_length = nscan;
+	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
+	if (value == NULL)
+		return NULL;
+	if (value_length > 0)
+		memcpy(value, pscan, value_length);
+	((u8 *) (value))[value_length] = '\0';
+	return value;
+}
+
+
 static ssize_t toolaction_show(struct device *dev,
 			       struct device_attribute *attr,
 			       char *buf)
@@ -2274,13 +2679,13 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
 	cdev_init(&file_cdev, &visorchipset_fops);
 	file_cdev.owner = THIS_MODULE;
 	if (MAJOR(major_dev) == 0) {
-		rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME);
+		rc = alloc_chrdev_region(&major_dev, 0, 1, "visorchipset");
 		/* dynamic major device number registration required */
 		if (rc < 0)
 			return rc;
 	} else {
 		/* static major device number registration required */
-		rc = register_chrdev_region(major_dev, 1, MYDRVNAME);
+		rc = register_chrdev_region(major_dev, 1, "visorchipset");
 		if (rc < 0)
 			return rc;
 	}
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 038/141] staging: unisys: move visorchipset files to visorbus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (36 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 037/141] staging: unisys: move parser.[ch] functionality into visorchipset Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 039/141] staging: unisys: cleanup visorbus_private.h Benjamin Romer
                   ` (105 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

Move visorchipset_main.c and visorchipset.h to visorbus/visorchipset.c and
visorbus/visorbus_private.h.  This leaves an empty visorchipset directory
which can also be destroyed.

As a result of this patch the visorchipset init code now calls the
visorbus_init() directly.  Similarily the visorchipset exit code now
cleans up by calling visorbus_exit().

No other functional changes were made.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Kconfig                     |    1 -
 drivers/staging/unisys/Makefile                    |    1 -
 drivers/staging/unisys/visorbus/Kconfig            |    2 +-
 drivers/staging/unisys/visorbus/Makefile           |    2 +-
 drivers/staging/unisys/visorbus/visorbus_main.c    |   11 +-
 drivers/staging/unisys/visorbus/visorbus_private.h |  218 ++
 drivers/staging/unisys/visorbus/visorchipset.c     | 2866 ++++++++++++++++++++
 drivers/staging/unisys/visorchipset/Kconfig        |   11 -
 drivers/staging/unisys/visorchipset/Makefile       |   15 -
 drivers/staging/unisys/visorchipset/visorchipset.h |  214 --
 .../unisys/visorchipset/visorchipset_main.c        | 2863 -------------------
 11 files changed, 3091 insertions(+), 3113 deletions(-)
 create mode 100644 drivers/staging/unisys/visorbus/visorbus_private.h
 create mode 100644 drivers/staging/unisys/visorbus/visorchipset.c
 delete mode 100644 drivers/staging/unisys/visorchipset/Kconfig
 delete mode 100644 drivers/staging/unisys/visorchipset/Makefile
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset.h
 delete mode 100644 drivers/staging/unisys/visorchipset/visorchipset_main.c

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index dbdd449..50223c7 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -10,7 +10,6 @@ menuconfig UNISYSSPAR
 if UNISYSSPAR
 
 source "drivers/staging/unisys/visorutil/Kconfig"
-source "drivers/staging/unisys/visorchipset/Kconfig"
 source "drivers/staging/unisys/visorbus/Kconfig"
 
 endif # UNISYSSPAR
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index b14a477..e0c893a 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -2,5 +2,4 @@
 # Makefile for Unisys SPAR drivers
 #
 obj-$(CONFIG_UNISYS_VISORUTIL)		+= visorutil/
-obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset/
 obj-$(CONFIG_UNISYS_VISORBUS)		+= visorbus/
diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig
index 12cf8f0..420c9ee 100644
--- a/drivers/staging/unisys/visorbus/Kconfig
+++ b/drivers/staging/unisys/visorbus/Kconfig
@@ -4,6 +4,6 @@
 
 config UNISYS_VISORBUS
 	tristate "Unisys visorbus driver"
-	depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHIPSET
+	depends on UNISYSSPAR && UNISYS_VISORUTIL
 	---help---
 	If you say Y here, you will enable the Unisys visorbus driver.
diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 7151690..16d3ff5 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -6,9 +6,9 @@ obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 
 visorbus-y := visorbus_main.o
 visorbus-y += visorchannel.o
+visorbus-y += visorchipset.o
 
 ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/visorchipset
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
 ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
 ccflags-y += -Idrivers/staging/unisys/visorutil
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d7ca116..6c939ce 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -18,7 +18,7 @@
 #include <linux/uuid.h>
 
 #include "visorbus.h"
-#include "visorchipset.h"
+#include "visorbus_private.h"
 #include "version.h"
 #include "timskmod.h"
 #include "periodic_work.h"
@@ -26,6 +26,8 @@
 #include "guestlinuxdebug.h"
 #include "vbusdeviceinfo.h"
 
+#define MYDRVNAME "visorbus"
+
 /* module parameters */
 int visorbus_debug;
 int visorbus_forcematch;
@@ -2033,7 +2035,7 @@ struct channel_size_info {
 	unsigned long max_size;
 };
 
-static int __init
+int __init
 visorbus_init(void)
 {
 	int rc = 0;
@@ -2077,7 +2079,7 @@ away:
 	return rc;
 }
 
-static void
+void
 visorbus_exit(void)
 {
 	struct list_head *listentry, *listtmp;
@@ -2135,9 +2137,6 @@ MODULE_PARM_DESC(visorbus_serialloopbacktest,
 		 "non-0 to just create 2 serial devices on the same channel");
 int visorbus_serialloopbacktest = 0;
 
-module_init(visorbus_init);
-module_exit(visorbus_exit);
-
 MODULE_AUTHOR("Unisys");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION);
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
new file mode 100644
index 0000000..68d770f
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -0,0 +1,218 @@
+/* visorchipset.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VISORCHIPSET_H__
+#define __VISORCHIPSET_H__
+
+#include <linux/uuid.h>
+
+#include "channel.h"
+#include "controlvmchannel.h"
+#include "procobjecttree.h"
+#include "vbusdeviceinfo.h"
+#include "vbushelper.h"
+
+#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
+
+/** Describes the state from the perspective of which controlvm messages have
+ *  been received for a bus or device.
+ */
+
+enum PARSER_WHICH_STRING {
+	PARSERSTRING_INITIATOR,
+	PARSERSTRING_TARGET,
+	PARSERSTRING_CONNECTION,
+	PARSERSTRING_NAME,
+};
+
+struct visorchannel;
+struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal,
+				   bool *tryAgain);
+struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local,
+				       bool *retry);
+void parser_param_start(struct parser_context *ctx,
+			PARSER_WHICH_STRING which_string);
+void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
+void *parser_string_get(struct parser_context *ctx);
+uuid_le parser_id_get(struct parser_context *ctx);
+char *parser_simpleString_get(struct parser_context *ctx);
+void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes);
+void parser_done(struct parser_context *ctx);
+
+struct visorchipset_state {
+	u32 created:1;
+	u32 attached:1;
+	u32 configured:1;
+	u32 running:1;
+	/* Add new fields above. */
+	/* Remaining bits in this 32-bit word are unused. */
+};
+
+enum visorchipset_addresstype {
+	/** address is guest physical, but outside of the physical memory
+	 *  region that is controlled by the running OS (this is the normal
+	 *  address type for Supervisor channels)
+	 */
+	ADDRTYPE_LOCALPHYSICAL,
+
+	/** address is guest physical, and withIN the confines of the
+	 *  physical memory controlled by the running OS.
+	 */
+	ADDRTYPE_LOCALTEST,
+};
+
+enum crash_obj_type {
+	CRASH_DEV,
+	CRASH_BUS,
+};
+
+/** Attributes for a particular Supervisor channel.
+ */
+struct visorchipset_channel_info {
+	enum visorchipset_addresstype addr_type;
+	HOSTADDRESS channel_addr;
+	struct irq_info intr;
+	u64 n_channel_bytes;
+	uuid_le channel_type_uuid;
+	uuid_le channel_inst_uuid;
+};
+
+/** Attributes for a particular Supervisor device.
+ *  Any visorchipset client can query these attributes using
+ *  visorchipset_get_client_device_info() or
+ *  visorchipset_get_server_device_info().
+ */
+struct visorchipset_device_info {
+	struct list_head entry;
+	u32 bus_no;
+	u32 dev_no;
+	uuid_le dev_inst_uuid;
+	struct visorchipset_state state;
+	struct visorchipset_channel_info chan_info;
+	u32 reserved1;		/* control_vm_id */
+	u64 reserved2;
+	u32 switch_no;		/* when devState.attached==1 */
+	u32 internal_port_no;	/* when devState.attached==1 */
+	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
+	/** For private use by the bus driver */
+	void *bus_driver_context;
+};
+
+/** Attributes for a particular Supervisor bus.
+ *  (For a service partition acting as the server for buses/devices, there
+ *  is a 1-to-1 relationship between busses and guest partitions.)
+ *  Any visorchipset client can query these attributes using
+ *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
+ */
+struct visorchipset_bus_info {
+	struct list_head entry;
+	u32 bus_no;
+	struct visorchipset_state state;
+	struct visorchipset_channel_info chan_info;
+	uuid_le partition_uuid;
+	u64 partition_handle;
+	u8 *name;		/* UTF8 */
+	u8 *description;	/* UTF8 */
+	u64 reserved1;
+	u32 reserved2;
+	struct {
+		u32 server:1;
+		/* Add new fields above. */
+		/* Remaining bits in this 32-bit word are unused. */
+	} flags;
+	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
+	/** For private use by the bus driver */
+	void *bus_driver_context;
+};
+
+/*  These functions will be called from within visorchipset when certain
+ *  events happen.  (The implementation of these functions is outside of
+ *  visorchipset.)
+ */
+struct visorchipset_busdev_notifiers {
+	void (*bus_create)(u32 bus_no);
+	void (*bus_destroy)(u32 bus_no);
+	void (*device_create)(u32 bus_no, u32 dev_no);
+	void (*device_destroy)(u32 bus_no, u32 dev_no);
+	void (*device_pause)(u32 bus_no, u32 dev_no);
+	void (*device_resume)(u32 bus_no, u32 dev_no);
+};
+
+/*  These functions live inside visorchipset, and will be called to indicate
+ *  responses to specific events (by code outside of visorchipset).
+ *  For now, the value for each response is simply either:
+ *       0 = it worked
+ *      -1 = it failed
+ */
+struct visorchipset_busdev_responders {
+	void (*bus_create)(u32 bus_no, int response);
+	void (*bus_destroy)(u32 bus_no, int response);
+	void (*device_create)(u32 bus_no, u32 dev_no, int response);
+	void (*device_destroy)(u32 bus_no, u32 dev_no, int response);
+	void (*device_pause)(u32 bus_no, u32 dev_no, int response);
+	void (*device_resume)(u32 bus_no, u32 dev_no, int response);
+};
+
+/** Register functions (in the bus driver) to get called by visorchipset
+ *  whenever a bus or device appears for which this service partition is
+ *  to be the server for.  visorchipset will fill in <responders>, to
+ *  indicate functions the bus driver should call to indicate message
+ *  responses.
+ */
+void
+visorchipset_register_busdev_client(
+			struct visorchipset_busdev_notifiers *notifiers,
+			struct visorchipset_busdev_responders *responders,
+			struct ultra_vbus_deviceinfo *driver_info);
+
+/** Register functions (in the bus driver) to get called by visorchipset
+ *  whenever a bus or device appears for which this service partition is
+ *  to be the client for.  visorchipset will fill in <responders>, to
+ *  indicate functions the bus driver should call to indicate message
+ *  responses.
+ */
+void
+visorchipset_register_busdev_server(
+			struct visorchipset_busdev_notifiers *notifiers,
+			struct visorchipset_busdev_responders *responders,
+			struct ultra_vbus_deviceinfo *driver_info);
+
+void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response);
+
+bool visorchipset_get_bus_info(u32 bus_no,
+			       struct visorchipset_bus_info *bus_info);
+bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
+				  struct visorchipset_device_info *dev_info);
+bool visorchipset_set_bus_context(u32 bus_no, void *context);
+bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context);
+int visorchipset_chipset_ready(void);
+int visorchipset_chipset_selftest(void);
+int visorchipset_chipset_notready(void);
+void visorchipset_save_message(struct controlvm_message *msg,
+			       enum crash_obj_type type);
+void *visorchipset_cache_alloc(struct kmem_cache *pool,
+			       bool ok_to_block, char *fn, int ln);
+void visorchipset_cache_free(struct kmem_cache *pool, void *p,
+			     char *fn, int ln);
+int visorchipset_file_init(dev_t majorDev,
+			   struct visorchannel **pControlVm_channel);
+void visorchipset_file_cleanup(dev_t major_dev);
+
+/* visorbus init and exit functions */
+int __init visorbus_init(void);
+void visorbus_exit(void);
+#endif
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
new file mode 100644
index 0000000..f3a2145
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -0,0 +1,2866 @@
+/* visorchipset_main.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#include "memregion.h"
+#include "controlvmchannel.h"
+#include "version.h"
+#include "procobjecttree.h"
+#include "visorbus.h"
+#include "periodic_work.h"
+#include "uisutils.h"
+#include "controlvmcompletionstatus.h"
+#include "guestlinuxdebug.h"
+#include "visorbus_private.h"
+
+
+#include <linux/ctype.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/nls.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/uuid.h>
+#include <linux/crash_dump.h>
+
+#define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
+#define TEST_VNIC_PHYSITF "eth0"	/* physical network itf for
+					 * vnic loopback test */
+#define TEST_VNIC_SWITCHNO 1
+#define TEST_VNIC_BUSNO 9
+
+#define MAX_NAME_SIZE 128
+#define MAX_IP_SIZE   50
+#define MAXOUTSTANDINGCHANNELCOMMAND 256
+#define POLLJIFFIES_CONTROLVMCHANNEL_FAST   1
+#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
+
+#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
+/*
+ * Module parameters
+ */
+static int visorchipset_testvnic;
+static int visorchipset_testvnicclient;
+static int visorchipset_testmsg;
+static int visorchipset_major;
+static int visorchipset_serverregwait;
+static int visorchipset_clientregwait = 1;	/* default is on */
+static int visorchipset_testteardown;
+static int visorchipset_disable_controlvm;
+static int visorchipset_holdchipsetready;
+static unsigned long controlvm_payload_bytes_buffered;
+
+static int
+visorchipset_open(struct inode *inode, struct file *file)
+{
+	unsigned minor_number = iminor(inode);
+
+	if (minor_number)
+		return -ENODEV;
+	file->private_data = NULL;
+	return 0;
+}
+
+static int
+visorchipset_release(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
+/* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
+* we switch to slow polling mode.  As soon as we get a controlvm
+* message, we switch back to fast polling mode.
+*/
+#define MIN_IDLE_SECONDS 10
+static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+static unsigned long most_recent_message_jiffies;	/* when we got our last
+						 * controlvm message */
+static int serverregistered;
+static int clientregistered;
+
+#define MAX_CHIPSET_EVENTS 2
+static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
+
+struct parser_context {
+	unsigned long allocbytes;
+	unsigned long param_bytes;
+	u8 *curr;
+	unsigned long bytes_remaining;
+	bool byte_stream;
+	char data[0];
+};
+
+static struct delayed_work periodic_controlvm_work;
+static struct workqueue_struct *periodic_controlvm_workqueue;
+static DEFINE_SEMAPHORE(notifier_lock);
+
+static struct cdev file_cdev;
+static struct visorchannel **file_controlvm_channel;
+static struct controlvm_message_header g_chipset_msg_hdr;
+static const uuid_le spar_diag_pool_channel_protocol_uuid =
+	SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
+/* 0xffffff is an invalid Bus/Device number */
+static u32 g_diagpool_bus_no = 0xffffff;
+static u32 g_diagpool_dev_no = 0xffffff;
+static struct controlvm_message_packet g_devicechangestate_packet;
+
+/* Only VNIC and VHBA channels are sent to visorclientbus (aka
+ * "visorhackbus")
+ */
+#define FOR_VISORHACKBUS(channel_type_guid) \
+	(((uuid_le_cmp(channel_type_guid,\
+		       spar_vnic_channel_protocol_uuid) == 0) ||\
+	(uuid_le_cmp(channel_type_guid,\
+			spar_vhba_channel_protocol_uuid) == 0)))
+#define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
+
+#define is_diagpool_channel(channel_type_guid) \
+	(uuid_le_cmp(channel_type_guid,\
+		     spar_diag_pool_channel_protocol_uuid) == 0)
+
+static LIST_HEAD(bus_info_list);
+static LIST_HEAD(dev_info_list);
+
+static struct visorchannel *controlvm_channel;
+
+/* Manages the request payload in the controlvm channel */
+struct visor_controlvm_payload_info {
+	u8 __iomem *ptr;	/* pointer to base address of payload pool */
+	u64 offset;		/* offset from beginning of controlvm
+				 * channel to beginning of payload * pool */
+	u32 bytes;		/* number of bytes in payload pool */
+};
+
+static struct visor_controlvm_payload_info controlvm_payload_info;
+
+/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
+ * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
+ */
+struct visor_livedump_info {
+	struct controlvm_message_header dumpcapture_header;
+	struct controlvm_message_header gettextdump_header;
+	struct controlvm_message_header dumpcomplete_header;
+	bool gettextdump_outstanding;
+	u32 crc32;
+	unsigned long length;
+	atomic_t buffers_in_use;
+	unsigned long destination;
+};
+
+static struct visor_livedump_info livedump_info;
+
+/* The following globals are used to handle the scenario where we are unable to
+ * offload the payload from a controlvm message due to memory requirements.  In
+ * this scenario, we simply stash the controlvm message, then attempt to
+ * process it again the next time controlvm_periodic_work() runs.
+ */
+static struct controlvm_message controlvm_pending_msg;
+static bool controlvm_pending_msg_valid;
+
+/* This identifies a data buffer that has been received via a controlvm messages
+ * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
+ */
+struct putfile_buffer_entry {
+	struct list_head next;	/* putfile_buffer_entry list */
+	struct parser_context *parser_ctx; /* points to input data buffer */
+};
+
+/* List of struct putfile_request *, via next_putfile_request member.
+ * Each entry in this list identifies an outstanding TRANSMIT_FILE
+ * conversation.
+ */
+static LIST_HEAD(putfile_request_list);
+
+/* This describes a buffer and its current state of transfer (e.g., how many
+ * bytes have already been supplied as putfile data, and how many bytes are
+ * remaining) for a putfile_request.
+ */
+struct putfile_active_buffer {
+	/* a payload from a controlvm message, containing a file data buffer */
+	struct parser_context *parser_ctx;
+	/* points within data area of parser_ctx to next byte of data */
+	u8 *pnext;
+	/* # bytes left from <pnext> to the end of this data buffer */
+	size_t bytes_remaining;
+};
+
+#define PUTFILE_REQUEST_SIG 0x0906101302281211
+/* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
+ * conversation.  Structs of this type are dynamically linked into
+ * <Putfile_request_list>.
+ */
+struct putfile_request {
+	u64 sig;		/* PUTFILE_REQUEST_SIG */
+
+	/* header from original TransmitFile request */
+	struct controlvm_message_header controlvm_header;
+	u64 file_request_number;	/* from original TransmitFile request */
+
+	/* link to next struct putfile_request */
+	struct list_head next_putfile_request;
+
+	/* most-recent sequence number supplied via a controlvm message */
+	u64 data_sequence_number;
+
+	/* head of putfile_buffer_entry list, which describes the data to be
+	 * supplied as putfile data;
+	 * - this list is added to when controlvm messages come in that supply
+	 * file data
+	 * - this list is removed from via the hotplug program that is actually
+	 * consuming these buffers to write as file data */
+	struct list_head input_buffer_list;
+	spinlock_t req_list_lock;	/* lock for input_buffer_list */
+
+	/* waiters for input_buffer_list to go non-empty */
+	wait_queue_head_t input_buffer_wq;
+
+	/* data not yet read within current putfile_buffer_entry */
+	struct putfile_active_buffer active_buf;
+
+	/* <0 = failed, 0 = in-progress, >0 = successful; */
+	/* note that this must be set with req_list_lock, and if you set <0, */
+	/* it is your responsibility to also free up all of the other objects */
+	/* in this struct (like input_buffer_list, active_buf.parser_ctx) */
+	/* before releasing the lock */
+	int completion_status;
+};
+
+struct parahotplug_request {
+	struct list_head list;
+	int id;
+	unsigned long expiration;
+	struct controlvm_message msg;
+};
+
+static LIST_HEAD(parahotplug_request_list);
+static DEFINE_SPINLOCK(parahotplug_request_list_lock);	/* lock for above */
+static void parahotplug_process_list(void);
+
+/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
+ * CONTROLVM_REPORTEVENT.
+ */
+static struct visorchipset_busdev_notifiers busdev_server_notifiers;
+static struct visorchipset_busdev_notifiers busdev_client_notifiers;
+
+static void bus_create_response(u32 bus_no, int response);
+static void bus_destroy_response(u32 bus_no, int response);
+static void device_create_response(u32 bus_no, u32 dev_no, int response);
+static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
+static void device_resume_response(u32 bus_no, u32 dev_no, int response);
+
+static struct visorchipset_busdev_responders busdev_responders = {
+	.bus_create = bus_create_response,
+	.bus_destroy = bus_destroy_response,
+	.device_create = device_create_response,
+	.device_destroy = device_destroy_response,
+	.device_pause = visorchipset_device_pause_response,
+	.device_resume = device_resume_response,
+};
+
+/* info for /dev/visorchipset */
+static dev_t major_dev = -1; /**< indicates major num for device */
+
+/* prototypes for attributes */
+static ssize_t toolaction_show(struct device *dev,
+			       struct device_attribute *attr, char *buf);
+static ssize_t toolaction_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count);
+static DEVICE_ATTR_RW(toolaction);
+
+static ssize_t boottotool_show(struct device *dev,
+			       struct device_attribute *attr, char *buf);
+static ssize_t boottotool_store(struct device *dev,
+				struct device_attribute *attr, const char *buf,
+				size_t count);
+static DEVICE_ATTR_RW(boottotool);
+
+static ssize_t error_show(struct device *dev, struct device_attribute *attr,
+			  char *buf);
+static ssize_t error_store(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count);
+static DEVICE_ATTR_RW(error);
+
+static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
+			   char *buf);
+static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
+			    const char *buf, size_t count);
+static DEVICE_ATTR_RW(textid);
+
+static ssize_t remaining_steps_show(struct device *dev,
+				    struct device_attribute *attr, char *buf);
+static ssize_t remaining_steps_store(struct device *dev,
+				     struct device_attribute *attr,
+				     const char *buf, size_t count);
+static DEVICE_ATTR_RW(remaining_steps);
+
+static ssize_t chipsetready_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count);
+static DEVICE_ATTR_WO(chipsetready);
+
+static ssize_t devicedisabled_store(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count);
+static DEVICE_ATTR_WO(devicedisabled);
+
+static ssize_t deviceenabled_store(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t count);
+static DEVICE_ATTR_WO(deviceenabled);
+
+static struct attribute *visorchipset_install_attrs[] = {
+	&dev_attr_toolaction.attr,
+	&dev_attr_boottotool.attr,
+	&dev_attr_error.attr,
+	&dev_attr_textid.attr,
+	&dev_attr_remaining_steps.attr,
+	NULL
+};
+
+static struct attribute_group visorchipset_install_group = {
+	.name = "install",
+	.attrs = visorchipset_install_attrs
+};
+
+static struct attribute *visorchipset_guest_attrs[] = {
+	&dev_attr_chipsetready.attr,
+	NULL
+};
+
+static struct attribute_group visorchipset_guest_group = {
+	.name = "guest",
+	.attrs = visorchipset_guest_attrs
+};
+
+static struct attribute *visorchipset_parahotplug_attrs[] = {
+	&dev_attr_devicedisabled.attr,
+	&dev_attr_deviceenabled.attr,
+	NULL
+};
+
+static struct attribute_group visorchipset_parahotplug_group = {
+	.name = "parahotplug",
+	.attrs = visorchipset_parahotplug_attrs
+};
+
+static const struct attribute_group *visorchipset_dev_groups[] = {
+	&visorchipset_install_group,
+	&visorchipset_guest_group,
+	&visorchipset_parahotplug_group,
+	NULL
+};
+
+/* /sys/devices/platform/visorchipset */
+static struct platform_device visorchipset_platform_device = {
+	.name = "visorchipset",
+	.id = -1,
+	.dev.groups = visorchipset_dev_groups,
+};
+
+/* Function prototypes */
+static void controlvm_respond(struct controlvm_message_header *msg_hdr,
+			      int response);
+static void controlvm_respond_chipset_init(
+		struct controlvm_message_header *msg_hdr, int response,
+		enum ultra_chipset_feature features);
+static void controlvm_respond_physdev_changestate(
+		struct controlvm_message_header *msg_hdr, int response,
+		struct spar_segment_state state);
+
+
+static struct parser_context *
+parser_init_guts(u64 addr, u32 bytes, bool local,
+		 bool standard_payload_header, bool *retry)
+{
+	int allocbytes = sizeof(struct parser_context) + bytes;
+	struct parser_context *rc = NULL;
+	struct parser_context *ctx = NULL;
+	struct memregion *rgn = NULL;
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (retry)
+		*retry = false;
+	if (!standard_payload_header)
+		/* alloc and 0 extra byte to ensure payload is
+		 * '\0'-terminated
+		 */
+		allocbytes++;
+	if ((controlvm_payload_bytes_buffered + bytes)
+	    > MAX_CONTROLVM_PAYLOAD_BYTES) {
+		if (retry)
+			*retry = true;
+		rc = NULL;
+		goto cleanup;
+	}
+	ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
+	if (!ctx) {
+		if (retry)
+			*retry = true;
+		rc = NULL;
+		goto cleanup;
+	}
+
+	ctx->allocbytes = allocbytes;
+	ctx->param_bytes = bytes;
+	ctx->curr = NULL;
+	ctx->bytes_remaining = 0;
+	ctx->byte_stream = false;
+	if (local) {
+		void *p;
+
+		if (addr > virt_to_phys(high_memory - 1)) {
+			rc = NULL;
+			goto cleanup;
+		}
+		p = __va((unsigned long) (addr));
+		memcpy(ctx->data, p, bytes);
+	} else {
+		rgn = visor_memregion_create(addr, bytes);
+		if (!rgn) {
+			rc = NULL;
+			goto cleanup;
+		}
+		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
+			rc = NULL;
+			goto cleanup;
+		}
+	}
+	if (!standard_payload_header) {
+		ctx->byte_stream = true;
+		rc = ctx;
+		goto cleanup;
+	}
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	if (phdr->total_length != bytes) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (phdr->total_length < phdr->header_length) {
+		rc = NULL;
+		goto cleanup;
+	}
+	if (phdr->header_length <
+	    sizeof(struct spar_controlvm_parameters_header)) {
+		rc = NULL;
+		goto cleanup;
+	}
+
+	rc = ctx;
+cleanup:
+	if (rgn) {
+		visor_memregion_destroy(rgn);
+		rgn = NULL;
+	}
+	if (rc) {
+		controlvm_payload_bytes_buffered += ctx->param_bytes;
+	} else {
+		if (ctx) {
+			parser_done(ctx);
+			ctx = NULL;
+		}
+	}
+	return rc;
+}
+
+struct parser_context *
+parser_init(u64 addr, u32 bytes, bool local, bool *retry)
+{
+	return parser_init_guts(addr, bytes, local, true, retry);
+}
+
+/* Call this instead of parser_init() if the payload area consists of just
+ * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
+ * structures.  Afterwards, you can call parser_simpleString_get() or
+ * parser_byteStream_get() to obtain the data.
+ */
+struct parser_context *
+parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
+{
+	return parser_init_guts(addr, bytes, local, false, retry);
+}
+
+/* Obtain '\0'-terminated copy of string in payload area.
+ */
+char *
+parser_simpleString_get(struct parser_context *ctx)
+{
+	if (!ctx->byte_stream)
+		return NULL;
+	return ctx->data;	/* note this IS '\0'-terminated, because of
+				 * the num of bytes we alloc+clear in
+				 * parser_init_byteStream() */
+}
+
+/* Obtain a copy of the buffer in the payload area.
+ */
+void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes)
+{
+	if (!ctx->byte_stream)
+		return NULL;
+	if (nbytes)
+		*nbytes = ctx->param_bytes;
+	return (void *)ctx->data;
+}
+
+uuid_le
+parser_id_get(struct parser_context *ctx)
+{
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (ctx == NULL)
+		return NULL_UUID_LE;
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	return phdr->id;
+}
+
+void
+parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
+{
+	struct spar_controlvm_parameters_header *phdr = NULL;
+
+	if (ctx == NULL)
+		goto Away;
+	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+	switch (which_string) {
+	case PARSERSTRING_INITIATOR:
+		ctx->curr = ctx->data + phdr->initiator_offset;
+		ctx->bytes_remaining = phdr->initiator_length;
+		break;
+	case PARSERSTRING_TARGET:
+		ctx->curr = ctx->data + phdr->target_offset;
+		ctx->bytes_remaining = phdr->target_length;
+		break;
+	case PARSERSTRING_CONNECTION:
+		ctx->curr = ctx->data + phdr->connection_offset;
+		ctx->bytes_remaining = phdr->connection_length;
+		break;
+	case PARSERSTRING_NAME:
+		ctx->curr = ctx->data + phdr->name_offset;
+		ctx->bytes_remaining = phdr->name_length;
+		break;
+	default:
+		break;
+	}
+
+Away:
+	return;
+}
+
+void
+parser_done(struct parser_context *ctx)
+{
+	if (!ctx)
+		return;
+	controlvm_payload_bytes_buffered -= ctx->param_bytes;
+	kfree(ctx);
+}
+
+/** Return length of string not counting trailing spaces. */
+static int
+string_length_no_trail(char *s, int len)
+{
+	int i = len - 1;
+
+	while (i >= 0) {
+		if (!isspace(s[i]))
+			return i + 1;
+		i--;
+	}
+	return 0;
+}
+
+/** Grab the next name and value out of the parameter buffer.
+ *  The entire parameter buffer looks like this:
+ *      <name>=<value>\0
+ *      <name>=<value>\0
+ *      ...
+ *      \0
+ *  If successful, the next <name> value is returned within the supplied
+ *  <nam> buffer (the value is always upper-cased), and the corresponding
+ *  <value> is returned within a kmalloc()ed buffer, whose pointer is
+ *  provided as the return value of this function.
+ *  (The total number of bytes allocated is strlen(<value>)+1.)
+ *
+ *  NULL is returned to indicate failure, which can occur for several reasons:
+ *  - all <name>=<value> pairs have already been processed
+ *  - bad parameter
+ *  - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
+ *    the confines of the parameter buffer)
+ *  - the <nam> buffer is not large enough to hold the <name> of the next
+ *    parameter
+ */
+void *
+parser_param_get(struct parser_context *ctx, char *nam, int namesize)
+{
+	u8 *pscan, *pnam = nam;
+	unsigned long nscan;
+	int value_length = -1, orig_value_length = -1;
+	void *value = NULL;
+	int i;
+	int closing_quote = 0;
+
+	if (!ctx)
+		return NULL;
+	pscan = ctx->curr;
+	nscan = ctx->bytes_remaining;
+	if (nscan == 0)
+		return NULL;
+	if (*pscan == '\0')
+		/*  This is the normal return point after you have processed
+		 *  all of the <name>=<value> pairs in a syntactically-valid
+		 *  parameter buffer.
+		 */
+		return NULL;
+
+	/* skip whitespace */
+	while (isspace(*pscan)) {
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+
+	while (*pscan != ':') {
+		if (namesize <= 0)
+			return NULL;
+		*pnam = toupper(*pscan);
+		pnam++;
+		namesize--;
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+	if (namesize <= 0)
+		return NULL;
+	*pnam = '\0';
+	nam[string_length_no_trail(nam, strlen(nam))] = '\0';
+
+	/* point to char immediately after ":" in "<name>:<value>" */
+	pscan++;
+	nscan--;
+	/* skip whitespace */
+	while (isspace(*pscan)) {
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+	if (nscan == 0)
+		return NULL;
+	if (*pscan == '\'' || *pscan == '"') {
+		closing_quote = *pscan;
+		pscan++;
+		nscan--;
+		if (nscan == 0)
+			return NULL;
+	}
+
+	/* look for a separator character, terminator character, or
+	 * end of data
+	 */
+	for (i = 0, value_length = -1; i < nscan; i++) {
+		if (closing_quote) {
+			if (pscan[i] == '\0')
+				return NULL;
+			if (pscan[i] == closing_quote) {
+				value_length = i;
+				break;
+			}
+		} else
+		    if (pscan[i] == ',' || pscan[i] == ';'
+			|| pscan[i] == '\0') {
+			value_length = i;
+			break;
+		}
+	}
+	if (value_length < 0) {
+		if (closing_quote)
+			return NULL;
+		value_length = nscan;
+	}
+	orig_value_length = value_length;
+	if (closing_quote == 0)
+		value_length = string_length_no_trail(pscan, orig_value_length);
+	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
+	if (value == NULL)
+		return NULL;
+	memcpy(value, pscan, value_length);
+	((u8 *) (value))[value_length] = '\0';
+
+	pscan += orig_value_length;
+	nscan -= orig_value_length;
+
+	/* skip past separator or closing quote */
+	if (nscan > 0) {
+		if (*pscan != '\0') {
+			pscan++;
+			nscan--;
+		}
+	}
+
+	if (closing_quote && (nscan > 0)) {
+		/* we still need to skip around the real separator if present */
+		/* first, skip whitespace */
+		while (isspace(*pscan)) {
+			pscan++;
+			nscan--;
+			if (nscan == 0)
+				break;
+		}
+		if (nscan > 0) {
+			if (*pscan == ',' || *pscan == ';') {
+				pscan++;
+				nscan--;
+			} else if (*pscan != '\0') {
+				kfree(value);
+				value = NULL;
+				return NULL;
+			}
+		}
+	}
+	ctx->curr = pscan;
+	ctx->bytes_remaining = nscan;
+	return value;
+}
+
+void *
+parser_string_get(struct parser_context *ctx)
+{
+	u8 *pscan;
+	unsigned long nscan;
+	int value_length = -1;
+	void *value = NULL;
+	int i;
+
+	if (!ctx)
+		return NULL;
+	pscan = ctx->curr;
+	nscan = ctx->bytes_remaining;
+	if (nscan == 0)
+		return NULL;
+	if (!pscan)
+		return NULL;
+	for (i = 0, value_length = -1; i < nscan; i++)
+		if (pscan[i] == '\0') {
+			value_length = i;
+			break;
+		}
+	if (value_length < 0)	/* '\0' was not included in the length */
+		value_length = nscan;
+	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
+	if (value == NULL)
+		return NULL;
+	if (value_length > 0)
+		memcpy(value, pscan, value_length);
+	((u8 *) (value))[value_length] = '\0';
+	return value;
+}
+
+
+static ssize_t toolaction_show(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	u8 tool_action;
+
+	visorchannel_read(controlvm_channel,
+		offsetof(struct spar_controlvm_channel_protocol,
+			 tool_action), &tool_action, sizeof(u8));
+	return scnprintf(buf, PAGE_SIZE, "%u\n", tool_action);
+}
+
+static ssize_t toolaction_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	u8 tool_action;
+	int ret;
+
+	if (kstrtou8(buf, 10, &tool_action))
+		return -EINVAL;
+
+	ret = visorchannel_write(controlvm_channel,
+		offsetof(struct spar_controlvm_channel_protocol,
+			 tool_action),
+		&tool_action, sizeof(u8));
+
+	if (ret)
+		return ret;
+	return count;
+}
+
+static ssize_t boottotool_show(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	struct efi_spar_indication efi_spar_indication;
+
+	visorchannel_read(controlvm_channel,
+			  offsetof(struct spar_controlvm_channel_protocol,
+				   efi_spar_ind), &efi_spar_indication,
+			  sizeof(struct efi_spar_indication));
+	return scnprintf(buf, PAGE_SIZE, "%u\n",
+			 efi_spar_indication.boot_to_tool);
+}
+
+static ssize_t boottotool_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	int val, ret;
+	struct efi_spar_indication efi_spar_indication;
+
+	if (kstrtoint(buf, 10, &val))
+		return -EINVAL;
+
+	efi_spar_indication.boot_to_tool = val;
+	ret = visorchannel_write(controlvm_channel,
+			offsetof(struct spar_controlvm_channel_protocol,
+				 efi_spar_ind), &(efi_spar_indication),
+				 sizeof(struct efi_spar_indication));
+
+	if (ret)
+		return ret;
+	return count;
+}
+
+static ssize_t error_show(struct device *dev, struct device_attribute *attr,
+			  char *buf)
+{
+	u32 error;
+
+	visorchannel_read(controlvm_channel,
+			  offsetof(struct spar_controlvm_channel_protocol,
+				   installation_error),
+			  &error, sizeof(u32));
+	return scnprintf(buf, PAGE_SIZE, "%i\n", error);
+}
+
+static ssize_t error_store(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	u32 error;
+	int ret;
+
+	if (kstrtou32(buf, 10, &error))
+		return -EINVAL;
+
+	ret = visorchannel_write(controlvm_channel,
+		offsetof(struct spar_controlvm_channel_protocol,
+			 installation_error),
+		&error, sizeof(u32));
+	if (ret)
+		return ret;
+	return count;
+}
+
+static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)
+{
+	u32 text_id;
+
+	visorchannel_read(controlvm_channel,
+			  offsetof(struct spar_controlvm_channel_protocol,
+				   installation_text_id),
+			  &text_id, sizeof(u32));
+	return scnprintf(buf, PAGE_SIZE, "%i\n", text_id);
+}
+
+static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	u32 text_id;
+	int ret;
+
+	if (kstrtou32(buf, 10, &text_id))
+		return -EINVAL;
+
+	ret = visorchannel_write(controlvm_channel,
+		offsetof(struct spar_controlvm_channel_protocol,
+			 installation_text_id),
+		&text_id, sizeof(u32));
+	if (ret)
+		return ret;
+	return count;
+}
+
+static ssize_t remaining_steps_show(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	u16 remaining_steps;
+
+	visorchannel_read(controlvm_channel,
+			  offsetof(struct spar_controlvm_channel_protocol,
+				   installation_remaining_steps),
+			  &remaining_steps, sizeof(u16));
+	return scnprintf(buf, PAGE_SIZE, "%hu\n", remaining_steps);
+}
+
+static ssize_t remaining_steps_store(struct device *dev,
+				     struct device_attribute *attr,
+				     const char *buf, size_t count)
+{
+	u16 remaining_steps;
+	int ret;
+
+	if (kstrtou16(buf, 10, &remaining_steps))
+		return -EINVAL;
+
+	ret = visorchannel_write(controlvm_channel,
+		offsetof(struct spar_controlvm_channel_protocol,
+			 installation_remaining_steps),
+		&remaining_steps, sizeof(u16));
+	if (ret)
+		return ret;
+	return count;
+}
+
+static void
+bus_info_clear(void *v)
+{
+	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
+
+	kfree(p->name);
+	kfree(p->description);
+	memset(p, 0, sizeof(struct visorchipset_bus_info));
+}
+
+static void
+dev_info_clear(void *v)
+{
+	struct visorchipset_device_info *p =
+		(struct visorchipset_device_info *) v;
+
+	memset(p, 0, sizeof(struct visorchipset_device_info));
+}
+
+static struct visorchipset_bus_info *
+bus_find(struct list_head *list, u32 bus_no)
+{
+	struct visorchipset_bus_info *p;
+
+	list_for_each_entry(p, list, entry) {
+		if (p->bus_no == bus_no)
+			return p;
+	}
+
+	return NULL;
+}
+
+static struct visorchipset_device_info *
+device_find(struct list_head *list, u32 bus_no, u32 dev_no)
+{
+	struct visorchipset_device_info *p;
+
+	list_for_each_entry(p, list, entry) {
+		if (p->bus_no == bus_no && p->dev_no == dev_no)
+			return p;
+	}
+
+	return NULL;
+}
+
+static void busdevices_del(struct list_head *list, u32 bus_no)
+{
+	struct visorchipset_device_info *p, *tmp;
+
+	list_for_each_entry_safe(p, tmp, list, entry) {
+		if (p->bus_no == bus_no) {
+			list_del(&p->entry);
+			kfree(p);
+		}
+	}
+}
+
+static u8
+check_chipset_events(void)
+{
+	int i;
+	u8 send_msg = 1;
+	/* Check events to determine if response should be sent */
+	for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
+		send_msg &= chipset_events[i];
+	return send_msg;
+}
+
+static void
+clear_chipset_events(void)
+{
+	int i;
+	/* Clear chipset_events */
+	for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
+		chipset_events[i] = 0;
+}
+
+void
+visorchipset_register_busdev_server(
+			struct visorchipset_busdev_notifiers *notifiers,
+			struct visorchipset_busdev_responders *responders,
+			struct ultra_vbus_deviceinfo *driver_info)
+{
+	down(&notifier_lock);
+	if (!notifiers) {
+		memset(&busdev_server_notifiers, 0,
+		       sizeof(busdev_server_notifiers));
+		serverregistered = 0;	/* clear flag */
+	} else {
+		busdev_server_notifiers = *notifiers;
+		serverregistered = 1;	/* set flag */
+	}
+	if (responders)
+		*responders = busdev_responders;
+	if (driver_info)
+		bus_device_info_init(driver_info, "chipset", "visorchipset",
+				     VERSION, NULL);
+
+	up(&notifier_lock);
+}
+EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
+
+void
+visorchipset_register_busdev_client(
+			struct visorchipset_busdev_notifiers *notifiers,
+			struct visorchipset_busdev_responders *responders,
+			struct ultra_vbus_deviceinfo *driver_info)
+{
+	down(&notifier_lock);
+	if (!notifiers) {
+		memset(&busdev_client_notifiers, 0,
+		       sizeof(busdev_client_notifiers));
+		clientregistered = 0;	/* clear flag */
+	} else {
+		busdev_client_notifiers = *notifiers;
+		clientregistered = 1;	/* set flag */
+	}
+	if (responders)
+		*responders = busdev_responders;
+	if (driver_info)
+		bus_device_info_init(driver_info, "chipset(bolts)",
+				     "visorchipset", VERSION, NULL);
+	up(&notifier_lock);
+}
+EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
+
+static void
+cleanup_controlvm_structures(void)
+{
+	struct visorchipset_bus_info *bi, *tmp_bi;
+	struct visorchipset_device_info *di, *tmp_di;
+
+	list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
+		bus_info_clear(bi);
+		list_del(&bi->entry);
+		kfree(bi);
+	}
+
+	list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
+		dev_info_clear(di);
+		list_del(&di->entry);
+		kfree(di);
+	}
+}
+
+static void
+chipset_init(struct controlvm_message *inmsg)
+{
+	static int chipset_inited;
+	enum ultra_chipset_feature features = 0;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
+	if (chipset_inited) {
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+		goto cleanup;
+	}
+	chipset_inited = 1;
+	POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
+
+	/* Set features to indicate we support parahotplug (if Command
+	 * also supports it). */
+	features =
+	    inmsg->cmd.init_chipset.
+	    features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG;
+
+	/* Set the "reply" bit so Command knows this is a
+	 * features-aware driver. */
+	features |= ULTRA_CHIPSET_FEATURE_REPLY;
+
+cleanup:
+	if (rc < 0)
+		cleanup_controlvm_structures();
+	if (inmsg->hdr.flags.response_expected)
+		controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
+}
+
+static void
+controlvm_init_response(struct controlvm_message *msg,
+			struct controlvm_message_header *msg_hdr, int response)
+{
+	memset(msg, 0, sizeof(struct controlvm_message));
+	memcpy(&msg->hdr, msg_hdr, sizeof(struct controlvm_message_header));
+	msg->hdr.payload_bytes = 0;
+	msg->hdr.payload_vm_offset = 0;
+	msg->hdr.payload_max_bytes = 0;
+	if (response < 0) {
+		msg->hdr.flags.failed = 1;
+		msg->hdr.completion_status = (u32) (-response);
+	}
+}
+
+static void
+controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
+{
+	struct controlvm_message outmsg;
+
+	controlvm_init_response(&outmsg, msg_hdr, response);
+	/* For DiagPool channel DEVICE_CHANGESTATE, we need to send
+	* back the deviceChangeState structure in the packet. */
+	if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
+	    g_devicechangestate_packet.device_change_state.bus_no ==
+	    g_diagpool_bus_no &&
+	    g_devicechangestate_packet.device_change_state.dev_no ==
+	    g_diagpool_dev_no)
+		outmsg.cmd = g_devicechangestate_packet;
+	if (outmsg.hdr.flags.test_message == 1)
+		return;
+
+	if (!visorchannel_signalinsert(controlvm_channel,
+				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
+		return;
+	}
+}
+
+static void
+controlvm_respond_chipset_init(struct controlvm_message_header *msg_hdr,
+			       int response,
+			       enum ultra_chipset_feature features)
+{
+	struct controlvm_message outmsg;
+
+	controlvm_init_response(&outmsg, msg_hdr, response);
+	outmsg.cmd.init_chipset.features = features;
+	if (!visorchannel_signalinsert(controlvm_channel,
+				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
+		return;
+	}
+}
+
+static void controlvm_respond_physdev_changestate(
+		struct controlvm_message_header *msg_hdr, int response,
+		struct spar_segment_state state)
+{
+	struct controlvm_message outmsg;
+
+	controlvm_init_response(&outmsg, msg_hdr, response);
+	outmsg.cmd.device_change_state.state = state;
+	outmsg.cmd.device_change_state.flags.phys_device = 1;
+	if (!visorchannel_signalinsert(controlvm_channel,
+				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
+		return;
+	}
+}
+
+void
+visorchipset_save_message(struct controlvm_message *msg,
+			  enum crash_obj_type type)
+{
+	u32 crash_msg_offset;
+	u16 crash_msg_count;
+
+	/* get saved message count */
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       saved_crash_message_count),
+			      &crash_msg_count, sizeof(u16)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
+		POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
+				 crash_msg_count,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* get saved crash message offset */
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       saved_crash_message_offset),
+			      &crash_msg_offset, sizeof(u32)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	if (type == CRASH_BUS) {
+		if (visorchannel_write(controlvm_channel,
+				       crash_msg_offset,
+				       msg,
+				       sizeof(struct controlvm_message)) < 0) {
+			POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
+					 POSTCODE_SEVERITY_ERR);
+			return;
+		}
+	} else {
+		if (visorchannel_write(controlvm_channel,
+				       crash_msg_offset +
+				       sizeof(struct controlvm_message), msg,
+				       sizeof(struct controlvm_message)) < 0) {
+			POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
+					 POSTCODE_SEVERITY_ERR);
+			return;
+		}
+	}
+}
+EXPORT_SYMBOL_GPL(visorchipset_save_message);
+
+static void
+bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
+{
+	struct visorchipset_bus_info *p;
+	bool need_clear = false;
+
+	p = bus_find(&bus_info_list, bus_no);
+	if (!p)
+		return;
+
+	if (response < 0) {
+		if ((cmd_id == CONTROLVM_BUS_CREATE) &&
+		    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
+			/* undo the row we just created... */
+			busdevices_del(&dev_info_list, bus_no);
+	} else {
+		if (cmd_id == CONTROLVM_BUS_CREATE)
+			p->state.created = 1;
+		if (cmd_id == CONTROLVM_BUS_DESTROY)
+			need_clear = true;
+	}
+
+	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+		return;		/* no controlvm response needed */
+	if (p->pending_msg_hdr.id != (u32)cmd_id)
+		return;
+	controlvm_respond(&p->pending_msg_hdr, response);
+	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+	if (need_clear) {
+		bus_info_clear(p);
+		busdevices_del(&dev_info_list, bus_no);
+	}
+}
+
+static void
+device_changestate_responder(enum controlvm_id cmd_id,
+			     u32 bus_no, u32 dev_no, int response,
+			     struct spar_segment_state response_state)
+{
+	struct visorchipset_device_info *p;
+	struct controlvm_message outmsg;
+
+	p = device_find(&dev_info_list, bus_no, dev_no);
+	if (!p)
+		return;
+	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+		return;		/* no controlvm response needed */
+	if (p->pending_msg_hdr.id != cmd_id)
+		return;
+
+	controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
+
+	outmsg.cmd.device_change_state.bus_no = bus_no;
+	outmsg.cmd.device_change_state.dev_no = dev_no;
+	outmsg.cmd.device_change_state.state = response_state;
+
+	if (!visorchannel_signalinsert(controlvm_channel,
+				       CONTROLVM_QUEUE_REQUEST, &outmsg))
+		return;
+
+	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+}
+
+static void
+device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
+{
+	struct visorchipset_device_info *p;
+	bool need_clear = false;
+
+	p = device_find(&dev_info_list, bus_no, dev_no);
+	if (!p)
+		return;
+	if (response >= 0) {
+		if (cmd_id == CONTROLVM_DEVICE_CREATE)
+			p->state.created = 1;
+		if (cmd_id == CONTROLVM_DEVICE_DESTROY)
+			need_clear = true;
+	}
+
+	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+		return;		/* no controlvm response needed */
+
+	if (p->pending_msg_hdr.id != (u32)cmd_id)
+		return;
+
+	controlvm_respond(&p->pending_msg_hdr, response);
+	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+	if (need_clear)
+		dev_info_clear(p);
+}
+
+static void
+bus_epilog(u32 bus_no,
+	   u32 cmd, struct controlvm_message_header *msg_hdr,
+	   int response, bool need_response)
+{
+	struct visorchipset_bus_info *bus_info;
+	bool notified = false;
+
+	bus_info = bus_find(&bus_info_list, bus_no);
+
+	if (!bus_info)
+		return;
+
+	if (need_response) {
+		memcpy(&bus_info->pending_msg_hdr, msg_hdr,
+		       sizeof(struct controlvm_message_header));
+	} else {
+		bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+	}
+
+	down(&notifier_lock);
+	if (response == CONTROLVM_RESP_SUCCESS) {
+		switch (cmd) {
+		case CONTROLVM_BUS_CREATE:
+			/* We can't tell from the bus_create
+			* information which of our 2 bus flavors the
+			* devices on this bus will ultimately end up.
+			* FORTUNATELY, it turns out it is harmless to
+			* send the bus_create to both of them.  We can
+			* narrow things down a little bit, though,
+			* because we know: - BusDev_Server can handle
+			* either server or client devices
+			* - BusDev_Client can handle ONLY client
+			* devices */
+			if (busdev_server_notifiers.bus_create) {
+				(*busdev_server_notifiers.bus_create) (bus_no);
+				notified = true;
+			}
+			if ((!bus_info->flags.server) /*client */ &&
+			    busdev_client_notifiers.bus_create) {
+				(*busdev_client_notifiers.bus_create) (bus_no);
+				notified = true;
+			}
+			break;
+		case CONTROLVM_BUS_DESTROY:
+			if (busdev_server_notifiers.bus_destroy) {
+				(*busdev_server_notifiers.bus_destroy) (bus_no);
+				notified = true;
+			}
+			if ((!bus_info->flags.server) /*client */ &&
+			    busdev_client_notifiers.bus_destroy) {
+				(*busdev_client_notifiers.bus_destroy) (bus_no);
+				notified = true;
+			}
+			break;
+		}
+	}
+	if (notified)
+		/* The callback function just called above is responsible
+		 * for calling the appropriate visorchipset_busdev_responders
+		 * function, which will call bus_responder()
+		 */
+		;
+	else
+		bus_responder(cmd, bus_no, response);
+	up(&notifier_lock);
+}
+
+static void
+device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
+	      struct controlvm_message_header *msg_hdr, int response,
+	      bool need_response, bool for_visorbus)
+{
+	struct visorchipset_busdev_notifiers *notifiers;
+	bool notified = false;
+
+	struct visorchipset_device_info *dev_info =
+		device_find(&dev_info_list, bus_no, dev_no);
+	char *envp[] = {
+		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
+		NULL
+	};
+
+	if (!dev_info)
+		return;
+
+	if (for_visorbus)
+		notifiers = &busdev_server_notifiers;
+	else
+		notifiers = &busdev_client_notifiers;
+	if (need_response) {
+		memcpy(&dev_info->pending_msg_hdr, msg_hdr,
+		       sizeof(struct controlvm_message_header));
+	} else {
+		dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+	}
+
+	down(&notifier_lock);
+	if (response >= 0) {
+		switch (cmd) {
+		case CONTROLVM_DEVICE_CREATE:
+			if (notifiers->device_create) {
+				(*notifiers->device_create) (bus_no, dev_no);
+				notified = true;
+			}
+			break;
+		case CONTROLVM_DEVICE_CHANGESTATE:
+			/* ServerReady / ServerRunning / SegmentStateRunning */
+			if (state.alive == segment_state_running.alive &&
+			    state.operating ==
+				segment_state_running.operating) {
+				if (notifiers->device_resume) {
+					(*notifiers->device_resume) (bus_no,
+								     dev_no);
+					notified = true;
+				}
+			}
+			/* ServerNotReady / ServerLost / SegmentStateStandby */
+			else if (state.alive == segment_state_standby.alive &&
+				 state.operating ==
+				 segment_state_standby.operating) {
+				/* technically this is standby case
+				 * where server is lost
+				 */
+				if (notifiers->device_pause) {
+					(*notifiers->device_pause) (bus_no,
+								    dev_no);
+					notified = true;
+				}
+			} else if (state.alive == segment_state_paused.alive &&
+				   state.operating ==
+				   segment_state_paused.operating) {
+				/* this is lite pause where channel is
+				 * still valid just 'pause' of it
+				 */
+				if (bus_no == g_diagpool_bus_no &&
+				    dev_no == g_diagpool_dev_no) {
+					/* this will trigger the
+					 * diag_shutdown.sh script in
+					 * the visorchipset hotplug */
+					kobject_uevent_env
+					    (&visorchipset_platform_device.dev.
+					     kobj, KOBJ_ONLINE, envp);
+				}
+			}
+			break;
+		case CONTROLVM_DEVICE_DESTROY:
+			if (notifiers->device_destroy) {
+				(*notifiers->device_destroy) (bus_no, dev_no);
+				notified = true;
+			}
+			break;
+		}
+	}
+	if (notified)
+		/* The callback function just called above is responsible
+		 * for calling the appropriate visorchipset_busdev_responders
+		 * function, which will call device_responder()
+		 */
+		;
+	else
+		device_responder(cmd, bus_no, dev_no, response);
+	up(&notifier_lock);
+}
+
+static void
+bus_create(struct controlvm_message *inmsg)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no = cmd->create_bus.bus_no;
+	int rc = CONTROLVM_RESP_SUCCESS;
+	struct visorchipset_bus_info *bus_info;
+
+	bus_info = bus_find(&bus_info_list, bus_no);
+	if (bus_info && (bus_info->state.created == 1)) {
+		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+		goto cleanup;
+	}
+	bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
+	if (!bus_info) {
+		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+		goto cleanup;
+	}
+
+	INIT_LIST_HEAD(&bus_info->entry);
+	bus_info->bus_no = bus_no;
+
+	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
+
+	if (inmsg->hdr.flags.test_message == 1)
+		bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
+	else
+		bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
+
+	bus_info->flags.server = inmsg->hdr.flags.server;
+	bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
+	bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
+	bus_info->chan_info.channel_type_uuid =
+			cmd->create_bus.bus_data_type_uuid;
+	bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
+
+	list_add(&bus_info->entry, &bus_info_list);
+
+	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
+
+cleanup:
+	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
+		   rc, inmsg->hdr.flags.response_expected == 1);
+}
+
+static void
+bus_destroy(struct controlvm_message *inmsg)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no = cmd->destroy_bus.bus_no;
+	struct visorchipset_bus_info *bus_info;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	bus_info = bus_find(&bus_info_list, bus_no);
+	if (!bus_info)
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+	else if (bus_info->state.created == 0)
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+
+	bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
+		   rc, inmsg->hdr.flags.response_expected == 1);
+}
+
+static void
+bus_configure(struct controlvm_message *inmsg,
+	      struct parser_context *parser_ctx)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no;
+	struct visorchipset_bus_info *bus_info;
+	int rc = CONTROLVM_RESP_SUCCESS;
+	char s[99];
+
+	bus_no = cmd->configure_bus.bus_no;
+	POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+
+	bus_info = bus_find(&bus_info_list, bus_no);
+	if (!bus_info) {
+		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+	} else if (bus_info->state.created == 0) {
+		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+	} else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
+		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
+	} else {
+		bus_info->partition_handle = cmd->configure_bus.guest_handle;
+		bus_info->partition_uuid = parser_id_get(parser_ctx);
+		parser_param_start(parser_ctx, PARSERSTRING_NAME);
+		bus_info->name = parser_string_get(parser_ctx);
+
+		visorchannel_uuid_id(&bus_info->partition_uuid, s);
+		POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
+				 POSTCODE_SEVERITY_INFO);
+	}
+	bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
+		   rc, inmsg->hdr.flags.response_expected == 1);
+}
+
+static void
+my_device_create(struct controlvm_message *inmsg)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no = cmd->create_device.bus_no;
+	u32 dev_no = cmd->create_device.dev_no;
+	struct visorchipset_device_info *dev_info;
+	struct visorchipset_bus_info *bus_info;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	if (dev_info && (dev_info->state.created == 1)) {
+		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+		goto cleanup;
+	}
+	bus_info = bus_find(&bus_info_list, bus_no);
+	if (!bus_info) {
+		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+		goto cleanup;
+	}
+	if (bus_info->state.created == 0) {
+		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+		goto cleanup;
+	}
+	dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
+	if (!dev_info) {
+		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+		goto cleanup;
+	}
+
+	INIT_LIST_HEAD(&dev_info->entry);
+	dev_info->bus_no = bus_no;
+	dev_info->dev_no = dev_no;
+	dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
+	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+
+	if (inmsg->hdr.flags.test_message == 1)
+		dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
+	else
+		dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
+	dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
+	dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
+	dev_info->chan_info.channel_type_uuid =
+			cmd->create_device.data_type_uuid;
+	dev_info->chan_info.intr = cmd->create_device.intr;
+	list_add(&dev_info->entry, &dev_info_list);
+	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
+			 POSTCODE_SEVERITY_INFO);
+cleanup:
+	/* get the bus and devNo for DiagPool channel */
+	if (dev_info &&
+	    is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
+		g_diagpool_bus_no = bus_no;
+		g_diagpool_dev_no = dev_no;
+	}
+	device_epilog(bus_no, dev_no, segment_state_running,
+		      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
+		      inmsg->hdr.flags.response_expected == 1,
+		      FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
+}
+
+static void
+my_device_changestate(struct controlvm_message *inmsg)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no = cmd->device_change_state.bus_no;
+	u32 dev_no = cmd->device_change_state.dev_no;
+	struct spar_segment_state state = cmd->device_change_state.state;
+	struct visorchipset_device_info *dev_info;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	if (!dev_info) {
+		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
+	} else if (dev_info->state.created == 0) {
+		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
+				 POSTCODE_SEVERITY_ERR);
+		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
+	}
+	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
+		device_epilog(bus_no, dev_no, state,
+			      CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
+			      inmsg->hdr.flags.response_expected == 1,
+			      FOR_VISORBUS(
+					dev_info->chan_info.channel_type_uuid));
+}
+
+static void
+my_device_destroy(struct controlvm_message *inmsg)
+{
+	struct controlvm_message_packet *cmd = &inmsg->cmd;
+	u32 bus_no = cmd->destroy_device.bus_no;
+	u32 dev_no = cmd->destroy_device.dev_no;
+	struct visorchipset_device_info *dev_info;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	if (!dev_info)
+		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
+	else if (dev_info->state.created == 0)
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+
+	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
+		device_epilog(bus_no, dev_no, segment_state_running,
+			      CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
+			      inmsg->hdr.flags.response_expected == 1,
+			      FOR_VISORBUS(
+					dev_info->chan_info.channel_type_uuid));
+}
+
+/* When provided with the physical address of the controlvm channel
+ * (phys_addr), the offset to the payload area we need to manage
+ * (offset), and the size of this payload area (bytes), fills in the
+ * controlvm_payload_info struct.  Returns true for success or false
+ * for failure.
+ */
+static int
+initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
+				  struct visor_controlvm_payload_info *info)
+{
+	u8 __iomem *payload = NULL;
+	int rc = CONTROLVM_RESP_SUCCESS;
+
+	if (!info) {
+		rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
+		goto cleanup;
+	}
+	memset(info, 0, sizeof(struct visor_controlvm_payload_info));
+	if ((offset == 0) || (bytes == 0)) {
+		rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
+		goto cleanup;
+	}
+	payload = ioremap_cache(phys_addr + offset, bytes);
+	if (!payload) {
+		rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
+		goto cleanup;
+	}
+
+	info->offset = offset;
+	info->bytes = bytes;
+	info->ptr = payload;
+
+cleanup:
+	if (rc < 0) {
+		if (payload) {
+			iounmap(payload);
+			payload = NULL;
+		}
+	}
+	return rc;
+}
+
+static void
+destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
+{
+	if (info->ptr) {
+		iounmap(info->ptr);
+		info->ptr = NULL;
+	}
+	memset(info, 0, sizeof(struct visor_controlvm_payload_info));
+}
+
+static void
+initialize_controlvm_payload(void)
+{
+	HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
+	u64 payload_offset = 0;
+	u32 payload_bytes = 0;
+
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       request_payload_offset),
+			      &payload_offset, sizeof(payload_offset)) < 0) {
+		POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       request_payload_bytes),
+			      &payload_bytes, sizeof(payload_bytes)) < 0) {
+		POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+	initialize_controlvm_payload_info(phys_addr,
+					  payload_offset, payload_bytes,
+					  &controlvm_payload_info);
+}
+
+/*  Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
+ *  Returns CONTROLVM_RESP_xxx code.
+ */
+int
+visorchipset_chipset_ready(void)
+{
+	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
+	return CONTROLVM_RESP_SUCCESS;
+}
+EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
+
+int
+visorchipset_chipset_selftest(void)
+{
+	char env_selftest[20];
+	char *envp[] = { env_selftest, NULL };
+
+	sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
+	kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
+			   envp);
+	return CONTROLVM_RESP_SUCCESS;
+}
+EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
+
+/*  Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
+ *  Returns CONTROLVM_RESP_xxx code.
+ */
+int
+visorchipset_chipset_notready(void)
+{
+	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
+	return CONTROLVM_RESP_SUCCESS;
+}
+EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
+
+static void
+chipset_ready(struct controlvm_message_header *msg_hdr)
+{
+	int rc = visorchipset_chipset_ready();
+
+	if (rc != CONTROLVM_RESP_SUCCESS)
+		rc = -rc;
+	if (msg_hdr->flags.response_expected && !visorchipset_holdchipsetready)
+		controlvm_respond(msg_hdr, rc);
+	if (msg_hdr->flags.response_expected && visorchipset_holdchipsetready) {
+		/* Send CHIPSET_READY response when all modules have been loaded
+		 * and disks mounted for the partition
+		 */
+		g_chipset_msg_hdr = *msg_hdr;
+	}
+}
+
+static void
+chipset_selftest(struct controlvm_message_header *msg_hdr)
+{
+	int rc = visorchipset_chipset_selftest();
+
+	if (rc != CONTROLVM_RESP_SUCCESS)
+		rc = -rc;
+	if (msg_hdr->flags.response_expected)
+		controlvm_respond(msg_hdr, rc);
+}
+
+static void
+chipset_notready(struct controlvm_message_header *msg_hdr)
+{
+	int rc = visorchipset_chipset_notready();
+
+	if (rc != CONTROLVM_RESP_SUCCESS)
+		rc = -rc;
+	if (msg_hdr->flags.response_expected)
+		controlvm_respond(msg_hdr, rc);
+}
+
+/* This is your "one-stop" shop for grabbing the next message from the
+ * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
+ */
+static bool
+read_controlvm_event(struct controlvm_message *msg)
+{
+	if (visorchannel_signalremove(controlvm_channel,
+				      CONTROLVM_QUEUE_EVENT, msg)) {
+		/* got a message */
+		if (msg->hdr.flags.test_message == 1)
+			return false;
+		return true;
+	}
+	return false;
+}
+
+/*
+ * The general parahotplug flow works as follows.  The visorchipset
+ * driver receives a DEVICE_CHANGESTATE message from Command
+ * specifying a physical device to enable or disable.  The CONTROLVM
+ * message handler calls parahotplug_process_message, which then adds
+ * the message to a global list and kicks off a udev event which
+ * causes a user level script to enable or disable the specified
+ * device.  The udev script then writes to
+ * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
+ * to get called, at which point the appropriate CONTROLVM message is
+ * retrieved from the list and responded to.
+ */
+
+#define PARAHOTPLUG_TIMEOUT_MS 2000
+
+/*
+ * Generate unique int to match an outstanding CONTROLVM message with a
+ * udev script /proc response
+ */
+static int
+parahotplug_next_id(void)
+{
+	static atomic_t id = ATOMIC_INIT(0);
+
+	return atomic_inc_return(&id);
+}
+
+/*
+ * Returns the time (in jiffies) when a CONTROLVM message on the list
+ * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
+ */
+static unsigned long
+parahotplug_next_expiration(void)
+{
+	return jiffies + msecs_to_jiffies(PARAHOTPLUG_TIMEOUT_MS);
+}
+
+/*
+ * Create a parahotplug_request, which is basically a wrapper for a
+ * CONTROLVM_MESSAGE that we can stick on a list
+ */
+static struct parahotplug_request *
+parahotplug_request_create(struct controlvm_message *msg)
+{
+	struct parahotplug_request *req;
+
+	req = kmalloc(sizeof(*req), GFP_KERNEL | __GFP_NORETRY);
+	if (!req)
+		return NULL;
+
+	req->id = parahotplug_next_id();
+	req->expiration = parahotplug_next_expiration();
+	req->msg = *msg;
+
+	return req;
+}
+
+/*
+ * Free a parahotplug_request.
+ */
+static void
+parahotplug_request_destroy(struct parahotplug_request *req)
+{
+	kfree(req);
+}
+
+/*
+ * Cause uevent to run the user level script to do the disable/enable
+ * specified in (the CONTROLVM message in) the specified
+ * parahotplug_request
+ */
+static void
+parahotplug_request_kickoff(struct parahotplug_request *req)
+{
+	struct controlvm_message_packet *cmd = &req->msg.cmd;
+	char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
+	    env_func[40];
+	char *envp[] = {
+		env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
+	};
+
+	sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
+	sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
+	sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
+		cmd->device_change_state.state.active);
+	sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
+		cmd->device_change_state.bus_no);
+	sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
+		cmd->device_change_state.dev_no >> 3);
+	sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
+		cmd->device_change_state.dev_no & 0x7);
+
+	kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
+			   envp);
+}
+
+/*
+ * Remove any request from the list that's been on there too long and
+ * respond with an error.
+ */
+static void
+parahotplug_process_list(void)
+{
+	struct list_head *pos;
+	struct list_head *tmp;
+
+	spin_lock(&parahotplug_request_list_lock);
+
+	list_for_each_safe(pos, tmp, &parahotplug_request_list) {
+		struct parahotplug_request *req =
+		    list_entry(pos, struct parahotplug_request, list);
+
+		if (!time_after_eq(jiffies, req->expiration))
+			continue;
+
+		list_del(pos);
+		if (req->msg.hdr.flags.response_expected)
+			controlvm_respond_physdev_changestate(
+				&req->msg.hdr,
+				CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
+				req->msg.cmd.device_change_state.state);
+		parahotplug_request_destroy(req);
+	}
+
+	spin_unlock(&parahotplug_request_list_lock);
+}
+
+/*
+ * Called from the /proc handler, which means the user script has
+ * finished the enable/disable.  Find the matching identifier, and
+ * respond to the CONTROLVM message with success.
+ */
+static int
+parahotplug_request_complete(int id, u16 active)
+{
+	struct list_head *pos;
+	struct list_head *tmp;
+
+	spin_lock(&parahotplug_request_list_lock);
+
+	/* Look for a request matching "id". */
+	list_for_each_safe(pos, tmp, &parahotplug_request_list) {
+		struct parahotplug_request *req =
+		    list_entry(pos, struct parahotplug_request, list);
+		if (req->id == id) {
+			/* Found a match.  Remove it from the list and
+			 * respond.
+			 */
+			list_del(pos);
+			spin_unlock(&parahotplug_request_list_lock);
+			req->msg.cmd.device_change_state.state.active = active;
+			if (req->msg.hdr.flags.response_expected)
+				controlvm_respond_physdev_changestate(
+					&req->msg.hdr, CONTROLVM_RESP_SUCCESS,
+					req->msg.cmd.device_change_state.state);
+			parahotplug_request_destroy(req);
+			return 0;
+		}
+	}
+
+	spin_unlock(&parahotplug_request_list_lock);
+	return -1;
+}
+
+/*
+ * Enables or disables a PCI device by kicking off a udev script
+ */
+static void
+parahotplug_process_message(struct controlvm_message *inmsg)
+{
+	struct parahotplug_request *req;
+
+	req = parahotplug_request_create(inmsg);
+
+	if (!req)
+		return;
+
+	if (inmsg->cmd.device_change_state.state.active) {
+		/* For enable messages, just respond with success
+		* right away.  This is a bit of a hack, but there are
+		* issues with the early enable messages we get (with
+		* either the udev script not detecting that the device
+		* is up, or not getting called at all).  Fortunately
+		* the messages that get lost don't matter anyway, as
+		* devices are automatically enabled at
+		* initialization.
+		*/
+		parahotplug_request_kickoff(req);
+		controlvm_respond_physdev_changestate(&inmsg->hdr,
+			CONTROLVM_RESP_SUCCESS,
+			inmsg->cmd.device_change_state.state);
+		parahotplug_request_destroy(req);
+	} else {
+		/* For disable messages, add the request to the
+		* request list before kicking off the udev script.  It
+		* won't get responded to until the script has
+		* indicated it's done.
+		*/
+		spin_lock(&parahotplug_request_list_lock);
+		list_add_tail(&req->list, &parahotplug_request_list);
+		spin_unlock(&parahotplug_request_list_lock);
+
+		parahotplug_request_kickoff(req);
+	}
+}
+
+/* Process a controlvm message.
+ * Return result:
+ *    false - this function will return FALSE only in the case where the
+ *            controlvm message was NOT processed, but processing must be
+ *            retried before reading the next controlvm message; a
+ *            scenario where this can occur is when we need to throttle
+ *            the allocation of memory in which to copy out controlvm
+ *            payload data
+ *    true  - processing of the controlvm message completed,
+ *            either successfully or with an error.
+ */
+static bool
+handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
+{
+	struct controlvm_message_packet *cmd = &inmsg.cmd;
+	u64 parm_addr;
+	u32 parm_bytes;
+	struct parser_context *parser_ctx = NULL;
+	bool local_addr;
+	struct controlvm_message ackmsg;
+
+	/* create parsing context if necessary */
+	local_addr = (inmsg.hdr.flags.test_message == 1);
+	if (channel_addr == 0)
+		return true;
+	parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
+	parm_bytes = inmsg.hdr.payload_bytes;
+
+	/* Parameter and channel addresses within test messages actually lie
+	 * within our OS-controlled memory.  We need to know that, because it
+	 * makes a difference in how we compute the virtual address.
+	 */
+	if (parm_addr && parm_bytes) {
+		bool retry = false;
+
+		parser_ctx =
+		    parser_init_byte_stream(parm_addr, parm_bytes,
+					    local_addr, &retry);
+		if (!parser_ctx && retry)
+			return false;
+	}
+
+	if (!local_addr) {
+		controlvm_init_response(&ackmsg, &inmsg.hdr,
+					CONTROLVM_RESP_SUCCESS);
+		if (controlvm_channel)
+			visorchannel_signalinsert(controlvm_channel,
+						  CONTROLVM_QUEUE_ACK,
+						  &ackmsg);
+	}
+	switch (inmsg.hdr.id) {
+	case CONTROLVM_CHIPSET_INIT:
+		chipset_init(&inmsg);
+		break;
+	case CONTROLVM_BUS_CREATE:
+		bus_create(&inmsg);
+		break;
+	case CONTROLVM_BUS_DESTROY:
+		bus_destroy(&inmsg);
+		break;
+	case CONTROLVM_BUS_CONFIGURE:
+		bus_configure(&inmsg, parser_ctx);
+		break;
+	case CONTROLVM_DEVICE_CREATE:
+		my_device_create(&inmsg);
+		break;
+	case CONTROLVM_DEVICE_CHANGESTATE:
+		if (cmd->device_change_state.flags.phys_device) {
+			parahotplug_process_message(&inmsg);
+		} else {
+			/* save the hdr and cmd structures for later use */
+			/* when sending back the response to Command */
+			my_device_changestate(&inmsg);
+			g_devicechangestate_packet = inmsg.cmd;
+			break;
+		}
+		break;
+	case CONTROLVM_DEVICE_DESTROY:
+		my_device_destroy(&inmsg);
+		break;
+	case CONTROLVM_DEVICE_CONFIGURE:
+		/* no op for now, just send a respond that we passed */
+		if (inmsg.hdr.flags.response_expected)
+			controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
+		break;
+	case CONTROLVM_CHIPSET_READY:
+		chipset_ready(&inmsg.hdr);
+		break;
+	case CONTROLVM_CHIPSET_SELFTEST:
+		chipset_selftest(&inmsg.hdr);
+		break;
+	case CONTROLVM_CHIPSET_STOP:
+		chipset_notready(&inmsg.hdr);
+		break;
+	default:
+		if (inmsg.hdr.flags.response_expected)
+			controlvm_respond(&inmsg.hdr,
+				-CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
+		break;
+	}
+
+	if (parser_ctx) {
+		parser_done(parser_ctx);
+		parser_ctx = NULL;
+	}
+	return true;
+}
+
+static HOSTADDRESS controlvm_get_channel_address(void)
+{
+	u64 addr = 0;
+	u32 size = 0;
+
+	if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size)))
+		return 0;
+
+	return addr;
+}
+
+static void
+controlvm_periodic_work(struct work_struct *work)
+{
+	struct controlvm_message inmsg;
+	bool got_command = false;
+	bool handle_command_failed = false;
+	static u64 poll_count;
+
+	/* make sure visorbus server is registered for controlvm callbacks */
+	if (visorchipset_serverregwait && !serverregistered)
+		goto cleanup;
+	/* make sure visorclientbus server is regsitered for controlvm
+	 * callbacks
+	 */
+	if (visorchipset_clientregwait && !clientregistered)
+		goto cleanup;
+
+	poll_count++;
+	if (poll_count >= 250)
+		;	/* keep going */
+	else
+		goto cleanup;
+
+	/* Check events to determine if response to CHIPSET_READY
+	 * should be sent
+	 */
+	if (visorchipset_holdchipsetready &&
+	    (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) {
+		if (check_chipset_events() == 1) {
+			controlvm_respond(&g_chipset_msg_hdr, 0);
+			clear_chipset_events();
+			memset(&g_chipset_msg_hdr, 0,
+			       sizeof(struct controlvm_message_header));
+		}
+	}
+
+	while (visorchannel_signalremove(controlvm_channel,
+					 CONTROLVM_QUEUE_RESPONSE,
+					 &inmsg))
+		;
+	if (!got_command) {
+		if (controlvm_pending_msg_valid) {
+			/* we throttled processing of a prior
+			* msg, so try to process it again
+			* rather than reading a new one
+			*/
+			inmsg = controlvm_pending_msg;
+			controlvm_pending_msg_valid = false;
+			got_command = true;
+		} else {
+			got_command = read_controlvm_event(&inmsg);
+		}
+	}
+
+	handle_command_failed = false;
+	while (got_command && (!handle_command_failed)) {
+		most_recent_message_jiffies = jiffies;
+		if (handle_command(inmsg,
+				   visorchannel_get_physaddr
+				   (controlvm_channel)))
+			got_command = read_controlvm_event(&inmsg);
+		else {
+			/* this is a scenario where throttling
+			* is required, but probably NOT an
+			* error...; we stash the current
+			* controlvm msg so we will attempt to
+			* reprocess it on our next loop
+			*/
+			handle_command_failed = true;
+			controlvm_pending_msg = inmsg;
+			controlvm_pending_msg_valid = true;
+		}
+	}
+
+	/* parahotplug_worker */
+	parahotplug_process_list();
+
+cleanup:
+
+	if (time_after(jiffies,
+		       most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
+		/* it's been longer than MIN_IDLE_SECONDS since we
+		* processed our last controlvm message; slow down the
+		* polling
+		*/
+		if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW)
+			poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
+	} else {
+		if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST)
+			poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+	}
+
+	queue_delayed_work(periodic_controlvm_workqueue,
+			   &periodic_controlvm_work, poll_jiffies);
+}
+
+static void
+setup_crash_devices_work_queue(struct work_struct *work)
+{
+	struct controlvm_message local_crash_bus_msg;
+	struct controlvm_message local_crash_dev_msg;
+	struct controlvm_message msg;
+	u32 local_crash_msg_offset;
+	u16 local_crash_msg_count;
+
+	/* make sure visorbus server is registered for controlvm callbacks */
+	if (visorchipset_serverregwait && !serverregistered)
+		goto cleanup;
+
+	/* make sure visorclientbus server is regsitered for controlvm
+	 * callbacks
+	 */
+	if (visorchipset_clientregwait && !clientregistered)
+		goto cleanup;
+
+	POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
+
+	/* send init chipset msg */
+	msg.hdr.id = CONTROLVM_CHIPSET_INIT;
+	msg.cmd.init_chipset.bus_count = 23;
+	msg.cmd.init_chipset.switch_count = 0;
+
+	chipset_init(&msg);
+
+	/* get saved message count */
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       saved_crash_message_count),
+			      &local_crash_msg_count, sizeof(u16)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
+		POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
+				 local_crash_msg_count,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* get saved crash message offset */
+	if (visorchannel_read(controlvm_channel,
+			      offsetof(struct spar_controlvm_channel_protocol,
+				       saved_crash_message_offset),
+			      &local_crash_msg_offset, sizeof(u32)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* read create device message for storage bus offset */
+	if (visorchannel_read(controlvm_channel,
+			      local_crash_msg_offset,
+			      &local_crash_bus_msg,
+			      sizeof(struct controlvm_message)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* read create device message for storage device */
+	if (visorchannel_read(controlvm_channel,
+			      local_crash_msg_offset +
+			      sizeof(struct controlvm_message),
+			      &local_crash_dev_msg,
+			      sizeof(struct controlvm_message)) < 0) {
+		POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* reuse IOVM create bus message */
+	if (local_crash_bus_msg.cmd.create_bus.channel_addr) {
+		bus_create(&local_crash_bus_msg);
+	} else {
+		POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+
+	/* reuse create device message for storage device */
+	if (local_crash_dev_msg.cmd.create_device.channel_addr) {
+		my_device_create(&local_crash_dev_msg);
+	} else {
+		POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
+				 POSTCODE_SEVERITY_ERR);
+		return;
+	}
+	POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO);
+	return;
+
+cleanup:
+
+	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
+
+	queue_delayed_work(periodic_controlvm_workqueue,
+			   &periodic_controlvm_work, poll_jiffies);
+}
+
+static void
+bus_create_response(u32 bus_no, int response)
+{
+	bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+}
+
+static void
+bus_destroy_response(u32 bus_no, int response)
+{
+	bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+}
+
+static void
+device_create_response(u32 bus_no, u32 dev_no, int response)
+{
+	device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
+}
+
+static void
+device_destroy_response(u32 bus_no, u32 dev_no, int response)
+{
+	device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
+}
+
+void
+visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
+{
+	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
+				     bus_no, dev_no, response,
+				     segment_state_standby);
+}
+EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
+
+static void
+device_resume_response(u32 bus_no, u32 dev_no, int response)
+{
+	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
+				     bus_no, dev_no, response,
+				     segment_state_running);
+}
+
+bool
+visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
+{
+	void *p = bus_find(&bus_info_list, bus_no);
+
+	if (!p)
+		return false;
+	memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
+	return true;
+}
+EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
+
+bool
+visorchipset_set_bus_context(u32 bus_no, void *context)
+{
+	struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
+
+	if (!p)
+		return false;
+	p->bus_driver_context = context;
+	return true;
+}
+EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
+
+bool
+visorchipset_get_device_info(u32 bus_no, u32 dev_no,
+			     struct visorchipset_device_info *dev_info)
+{
+	void *p = device_find(&dev_info_list, bus_no, dev_no);
+
+	if (!p)
+		return false;
+	memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
+	return true;
+}
+EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
+
+bool
+visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
+{
+	struct visorchipset_device_info *p;
+
+	p = device_find(&dev_info_list, bus_no, dev_no);
+
+	if (!p)
+		return false;
+	p->bus_driver_context = context;
+	return true;
+}
+EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
+
+/* Generic wrapper function for allocating memory from a kmem_cache pool.
+ */
+void *
+visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block,
+			 char *fn, int ln)
+{
+	gfp_t gfp;
+	void *p;
+
+	if (ok_to_block)
+		gfp = GFP_KERNEL;
+	else
+		gfp = GFP_ATOMIC;
+	/* __GFP_NORETRY means "ok to fail", meaning
+	 * kmem_cache_alloc() can return NULL, implying the caller CAN
+	 * cope with failure.  If you do NOT specify __GFP_NORETRY,
+	 * Linux will go to extreme measures to get memory for you
+	 * (like, invoke oom killer), which will probably cripple the
+	 * system.
+	 */
+	gfp |= __GFP_NORETRY;
+	p = kmem_cache_alloc(pool, gfp);
+	if (!p)
+		return NULL;
+
+	return p;
+}
+
+/* Generic wrapper function for freeing memory from a kmem_cache pool.
+ */
+void
+visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
+{
+	if (!p)
+		return;
+
+	kmem_cache_free(pool, p);
+}
+
+static ssize_t chipsetready_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	char msgtype[64];
+
+	if (sscanf(buf, "%63s", msgtype) != 1)
+		return -EINVAL;
+
+	if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) {
+		chipset_events[0] = 1;
+		return count;
+	} else if (!strcmp(msgtype, "MODULES_LOADED")) {
+		chipset_events[1] = 1;
+		return count;
+	}
+	return -EINVAL;
+}
+
+/* The parahotplug/devicedisabled interface gets called by our support script
+ * when an SR-IOV device has been shut down. The ID is passed to the script
+ * and then passed back when the device has been removed.
+ */
+static ssize_t devicedisabled_store(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned int id;
+
+	if (kstrtouint(buf, 10, &id))
+		return -EINVAL;
+
+	parahotplug_request_complete(id, 0);
+	return count;
+}
+
+/* The parahotplug/deviceenabled interface gets called by our support script
+ * when an SR-IOV device has been recovered. The ID is passed to the script
+ * and then passed back when the device has been brought back up.
+ */
+static ssize_t deviceenabled_store(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t count)
+{
+	unsigned int id;
+
+	if (kstrtouint(buf, 10, &id))
+		return -EINVAL;
+
+	parahotplug_request_complete(id, 1);
+	return count;
+}
+
+static int
+visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	unsigned long physaddr = 0;
+	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+	GUEST_PHYSICAL_ADDRESS addr = 0;
+
+	/* sv_enable_dfp(); */
+	if (offset & (PAGE_SIZE - 1))
+		return -ENXIO;	/* need aligned offsets */
+
+	switch (offset) {
+	case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
+		vma->vm_flags |= VM_IO;
+		if (!*file_controlvm_channel)
+			return -ENXIO;
+
+		visorchannel_read(*file_controlvm_channel,
+			offsetof(struct spar_controlvm_channel_protocol,
+				 gp_control_channel),
+			&addr, sizeof(addr));
+		if (!addr)
+			return -ENXIO;
+
+		physaddr = (unsigned long)addr;
+		if (remap_pfn_range(vma, vma->vm_start,
+				    physaddr >> PAGE_SHIFT,
+				    vma->vm_end - vma->vm_start,
+				    /*pgprot_noncached */
+				    (vma->vm_page_prot))) {
+			return -EAGAIN;
+		}
+		break;
+	default:
+		return -ENXIO;
+	}
+	return 0;
+}
+
+static long visorchipset_ioctl(struct file *file, unsigned int cmd,
+			       unsigned long arg)
+{
+	s64 adjustment;
+	s64 vrtc_offset;
+
+	switch (cmd) {
+	case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
+		/* get the physical rtc offset */
+		vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
+		if (copy_to_user((void __user *)arg, &vrtc_offset,
+				 sizeof(vrtc_offset))) {
+			return -EFAULT;
+		}
+		return SUCCESS;
+	case VMCALL_UPDATE_PHYSICAL_TIME:
+		if (copy_from_user(&adjustment, (void __user *)arg,
+				   sizeof(adjustment))) {
+			return -EFAULT;
+		}
+		return issue_vmcall_update_physical_time(adjustment);
+	default:
+		return -EFAULT;
+	}
+}
+
+static const struct file_operations visorchipset_fops = {
+	.owner = THIS_MODULE,
+	.open = visorchipset_open,
+	.read = NULL,
+	.write = NULL,
+	.unlocked_ioctl = visorchipset_ioctl,
+	.release = visorchipset_release,
+	.mmap = visorchipset_mmap,
+};
+
+int
+visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
+{
+	int rc = 0;
+
+	file_controlvm_channel = controlvm_channel;
+	cdev_init(&file_cdev, &visorchipset_fops);
+	file_cdev.owner = THIS_MODULE;
+	if (MAJOR(major_dev) == 0) {
+		rc = alloc_chrdev_region(&major_dev, 0, 1, "visorchipset");
+		/* dynamic major device number registration required */
+		if (rc < 0)
+			return rc;
+	} else {
+		/* static major device number registration required */
+		rc = register_chrdev_region(major_dev, 1, "visorchipset");
+		if (rc < 0)
+			return rc;
+	}
+	rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
+	if (rc < 0) {
+		unregister_chrdev_region(major_dev, 1);
+		return rc;
+	}
+	return 0;
+}
+
+
+
+static int __init
+visorchipset_init(void)
+{
+	int rc = 0, x = 0;
+	HOSTADDRESS addr;
+
+	if (!unisys_spar_platform)
+		return -ENODEV;
+
+	memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers));
+	memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers));
+	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
+	memset(&livedump_info, 0, sizeof(livedump_info));
+	atomic_set(&livedump_info.buffers_in_use, 0);
+
+	if (visorchipset_testvnic) {
+		POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
+		rc = x;
+		goto cleanup;
+	}
+
+	addr = controlvm_get_channel_address();
+	if (addr) {
+		controlvm_channel =
+		    visorchannel_create_with_lock
+		    (addr,
+		     sizeof(struct spar_controlvm_channel_protocol),
+		     spar_controlvm_channel_protocol_uuid);
+		if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
+				visorchannel_get_header(controlvm_channel))) {
+			initialize_controlvm_payload();
+		} else {
+			visorchannel_destroy(controlvm_channel);
+			controlvm_channel = NULL;
+			return -ENODEV;
+		}
+	} else {
+		return -ENODEV;
+	}
+
+	major_dev = MKDEV(visorchipset_major, 0);
+	rc = visorchipset_file_init(major_dev, &controlvm_channel);
+	if (rc < 0) {
+		POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
+		goto cleanup;
+	}
+
+	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
+
+	if (!visorchipset_disable_controlvm) {
+		/* if booting in a crash kernel */
+		if (is_kdump_kernel())
+			INIT_DELAYED_WORK(&periodic_controlvm_work,
+					  setup_crash_devices_work_queue);
+		else
+			INIT_DELAYED_WORK(&periodic_controlvm_work,
+					  controlvm_periodic_work);
+		periodic_controlvm_workqueue =
+		    create_singlethread_workqueue("visorchipset_controlvm");
+
+		if (!periodic_controlvm_workqueue) {
+			POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
+					 DIAG_SEVERITY_ERR);
+			rc = -ENOMEM;
+			goto cleanup;
+		}
+		most_recent_message_jiffies = jiffies;
+		poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+		rc = queue_delayed_work(periodic_controlvm_workqueue,
+					&periodic_controlvm_work, poll_jiffies);
+		if (rc < 0) {
+			POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
+					 DIAG_SEVERITY_ERR);
+			goto cleanup;
+		}
+	}
+
+	visorchipset_platform_device.dev.devt = major_dev;
+	if (platform_device_register(&visorchipset_platform_device) < 0) {
+		POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
+		rc = -1;
+		goto cleanup;
+	}
+	POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
+
+	rc = visorbus_init();
+cleanup:
+	if (rc) {
+		POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
+				 POSTCODE_SEVERITY_ERR);
+	}
+	return rc;
+}
+
+void
+visorchipset_file_cleanup(dev_t major_dev)
+{
+	if (file_cdev.ops)
+		cdev_del(&file_cdev);
+	file_cdev.ops = NULL;
+	unregister_chrdev_region(major_dev, 1);
+}
+
+static void
+visorchipset_exit(void)
+{
+	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
+
+	visorbus_exit();
+
+	if (visorchipset_disable_controlvm) {
+		;
+	} else {
+		cancel_delayed_work(&periodic_controlvm_work);
+		flush_workqueue(periodic_controlvm_workqueue);
+		destroy_workqueue(periodic_controlvm_workqueue);
+		periodic_controlvm_workqueue = NULL;
+		destroy_controlvm_payload_info(&controlvm_payload_info);
+	}
+
+	cleanup_controlvm_structures();
+
+	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
+
+	visorchannel_destroy(controlvm_channel);
+
+	visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
+	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
+}
+
+module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
+module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
+module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_testmsg,
+		 "1 to manufacture the chipset, bus, and switch messages");
+module_param_named(major, visorchipset_major, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_major,
+		 "major device number to use for the device node");
+module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_serverreqwait,
+		 "1 to have the module wait for the visor bus to register");
+module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
+module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_testteardown,
+		 "1 to test teardown of the chipset, bus, and switch");
+module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
+		   S_IRUGO);
+MODULE_PARM_DESC(visorchipset_disable_controlvm,
+		 "1 to disable polling of controlVm channel");
+module_param_named(holdchipsetready, visorchipset_holdchipsetready,
+		   int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_holdchipsetready,
+		 "1 to hold response to CHIPSET_READY");
+
+module_init(visorchipset_init);
+module_exit(visorchipset_exit);
+
+MODULE_AUTHOR("Unisys");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
+		   VERSION);
+MODULE_VERSION(VERSION);
diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig
deleted file mode 100644
index 01d9a9a..0000000
--- a/drivers/staging/unisys/visorchipset/Kconfig
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Unisys visorchipset configuration
-#
-
-config UNISYS_VISORCHIPSET
-	tristate "Unisys visorchipset driver"
-	select UNISYS_VISORUTIL
-	select UNISYS_VISORBUS
-	---help---
-	If you say Y here, you will enable the Unisys visorchipset driver.
-
diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
deleted file mode 100644
index e9168d8..0000000
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Makefile for Unisys visorchipset
-#
-
-obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset.o
-
-visorchipset-y := visorchipset_main.o
-
-ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
-ccflags-y += -Idrivers/staging/unisys/visorutil
-ccflags-y += -Idrivers/staging/unisys/visorbus
-ccflags-y += -Iinclude/generated
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
deleted file mode 100644
index 264a3e9..0000000
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* visorchipset.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHIPSET_H__
-#define __VISORCHIPSET_H__
-
-#include <linux/uuid.h>
-
-#include "channel.h"
-#include "controlvmchannel.h"
-#include "procobjecttree.h"
-#include "vbusdeviceinfo.h"
-#include "vbushelper.h"
-
-#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
-
-/** Describes the state from the perspective of which controlvm messages have
- *  been received for a bus or device.
- */
-
-enum PARSER_WHICH_STRING {
-	PARSERSTRING_INITIATOR,
-	PARSERSTRING_TARGET,
-	PARSERSTRING_CONNECTION,
-	PARSERSTRING_NAME,
-};
-
-struct visorchannel;
-struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal,
-				   bool *tryAgain);
-struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local,
-				       bool *retry);
-void parser_param_start(struct parser_context *ctx,
-			PARSER_WHICH_STRING which_string);
-void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
-void *parser_string_get(struct parser_context *ctx);
-uuid_le parser_id_get(struct parser_context *ctx);
-char *parser_simpleString_get(struct parser_context *ctx);
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes);
-void parser_done(struct parser_context *ctx);
-
-struct visorchipset_state {
-	u32 created:1;
-	u32 attached:1;
-	u32 configured:1;
-	u32 running:1;
-	/* Add new fields above. */
-	/* Remaining bits in this 32-bit word are unused. */
-};
-
-enum visorchipset_addresstype {
-	/** address is guest physical, but outside of the physical memory
-	 *  region that is controlled by the running OS (this is the normal
-	 *  address type for Supervisor channels)
-	 */
-	ADDRTYPE_LOCALPHYSICAL,
-
-	/** address is guest physical, and withIN the confines of the
-	 *  physical memory controlled by the running OS.
-	 */
-	ADDRTYPE_LOCALTEST,
-};
-
-enum crash_obj_type {
-	CRASH_DEV,
-	CRASH_BUS,
-};
-
-/** Attributes for a particular Supervisor channel.
- */
-struct visorchipset_channel_info {
-	enum visorchipset_addresstype addr_type;
-	HOSTADDRESS channel_addr;
-	struct irq_info intr;
-	u64 n_channel_bytes;
-	uuid_le channel_type_uuid;
-	uuid_le channel_inst_uuid;
-};
-
-/** Attributes for a particular Supervisor device.
- *  Any visorchipset client can query these attributes using
- *  visorchipset_get_client_device_info() or
- *  visorchipset_get_server_device_info().
- */
-struct visorchipset_device_info {
-	struct list_head entry;
-	u32 bus_no;
-	u32 dev_no;
-	uuid_le dev_inst_uuid;
-	struct visorchipset_state state;
-	struct visorchipset_channel_info chan_info;
-	u32 reserved1;		/* control_vm_id */
-	u64 reserved2;
-	u32 switch_no;		/* when devState.attached==1 */
-	u32 internal_port_no;	/* when devState.attached==1 */
-	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
-	/** For private use by the bus driver */
-	void *bus_driver_context;
-};
-
-/** Attributes for a particular Supervisor bus.
- *  (For a service partition acting as the server for buses/devices, there
- *  is a 1-to-1 relationship between busses and guest partitions.)
- *  Any visorchipset client can query these attributes using
- *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
- */
-struct visorchipset_bus_info {
-	struct list_head entry;
-	u32 bus_no;
-	struct visorchipset_state state;
-	struct visorchipset_channel_info chan_info;
-	uuid_le partition_uuid;
-	u64 partition_handle;
-	u8 *name;		/* UTF8 */
-	u8 *description;	/* UTF8 */
-	u64 reserved1;
-	u32 reserved2;
-	struct {
-		u32 server:1;
-		/* Add new fields above. */
-		/* Remaining bits in this 32-bit word are unused. */
-	} flags;
-	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
-	/** For private use by the bus driver */
-	void *bus_driver_context;
-};
-
-/*  These functions will be called from within visorchipset when certain
- *  events happen.  (The implementation of these functions is outside of
- *  visorchipset.)
- */
-struct visorchipset_busdev_notifiers {
-	void (*bus_create)(u32 bus_no);
-	void (*bus_destroy)(u32 bus_no);
-	void (*device_create)(u32 bus_no, u32 dev_no);
-	void (*device_destroy)(u32 bus_no, u32 dev_no);
-	void (*device_pause)(u32 bus_no, u32 dev_no);
-	void (*device_resume)(u32 bus_no, u32 dev_no);
-};
-
-/*  These functions live inside visorchipset, and will be called to indicate
- *  responses to specific events (by code outside of visorchipset).
- *  For now, the value for each response is simply either:
- *       0 = it worked
- *      -1 = it failed
- */
-struct visorchipset_busdev_responders {
-	void (*bus_create)(u32 bus_no, int response);
-	void (*bus_destroy)(u32 bus_no, int response);
-	void (*device_create)(u32 bus_no, u32 dev_no, int response);
-	void (*device_destroy)(u32 bus_no, u32 dev_no, int response);
-	void (*device_pause)(u32 bus_no, u32 dev_no, int response);
-	void (*device_resume)(u32 bus_no, u32 dev_no, int response);
-};
-
-/** Register functions (in the bus driver) to get called by visorchipset
- *  whenever a bus or device appears for which this service partition is
- *  to be the server for.  visorchipset will fill in <responders>, to
- *  indicate functions the bus driver should call to indicate message
- *  responses.
- */
-void
-visorchipset_register_busdev_client(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info);
-
-/** Register functions (in the bus driver) to get called by visorchipset
- *  whenever a bus or device appears for which this service partition is
- *  to be the client for.  visorchipset will fill in <responders>, to
- *  indicate functions the bus driver should call to indicate message
- *  responses.
- */
-void
-visorchipset_register_busdev_server(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info);
-
-void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response);
-
-bool visorchipset_get_bus_info(u32 bus_no,
-			       struct visorchipset_bus_info *bus_info);
-bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-				  struct visorchipset_device_info *dev_info);
-bool visorchipset_set_bus_context(u32 bus_no, void *context);
-bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context);
-int visorchipset_chipset_ready(void);
-int visorchipset_chipset_selftest(void);
-int visorchipset_chipset_notready(void);
-void visorchipset_save_message(struct controlvm_message *msg,
-			       enum crash_obj_type type);
-void *visorchipset_cache_alloc(struct kmem_cache *pool,
-			       bool ok_to_block, char *fn, int ln);
-void visorchipset_cache_free(struct kmem_cache *pool, void *p,
-			     char *fn, int ln);
-int visorchipset_file_init(dev_t majorDev,
-			   struct visorchannel **pControlVm_channel);
-void visorchipset_file_cleanup(dev_t major_dev);
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
deleted file mode 100644
index dc9f1dc..0000000
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ /dev/null
@@ -1,2863 +0,0 @@
-/* visorchipset_main.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#include "memregion.h"
-#include "controlvmchannel.h"
-#include "version.h"
-#include "procobjecttree.h"
-#include "visorbus.h"
-#include "periodic_work.h"
-#include "uisutils.h"
-#include "controlvmcompletionstatus.h"
-#include "guestlinuxdebug.h"
-#include "visorchipset.h"
-
-
-#include <linux/ctype.h>
-#include <linux/fs.h>
-#include <linux/mm.h>
-#include <linux/nls.h>
-#include <linux/netdevice.h>
-#include <linux/platform_device.h>
-#include <linux/uuid.h>
-#include <linux/crash_dump.h>
-
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
-#define TEST_VNIC_PHYSITF "eth0"	/* physical network itf for
-					 * vnic loopback test */
-#define TEST_VNIC_SWITCHNO 1
-#define TEST_VNIC_BUSNO 9
-
-#define MAX_NAME_SIZE 128
-#define MAX_IP_SIZE   50
-#define MAXOUTSTANDINGCHANNELCOMMAND 256
-#define POLLJIFFIES_CONTROLVMCHANNEL_FAST   1
-#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
-
-#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
-/*
- * Module parameters
- */
-static int visorchipset_testvnic;
-static int visorchipset_testvnicclient;
-static int visorchipset_testmsg;
-static int visorchipset_major;
-static int visorchipset_serverregwait;
-static int visorchipset_clientregwait = 1;	/* default is on */
-static int visorchipset_testteardown;
-static int visorchipset_disable_controlvm;
-static int visorchipset_holdchipsetready;
-static unsigned long controlvm_payload_bytes_buffered;
-
-static int
-visorchipset_open(struct inode *inode, struct file *file)
-{
-	unsigned minor_number = iminor(inode);
-
-	if (minor_number)
-		return -ENODEV;
-	file->private_data = NULL;
-	return 0;
-}
-
-static int
-visorchipset_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-/* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
-* we switch to slow polling mode.  As soon as we get a controlvm
-* message, we switch back to fast polling mode.
-*/
-#define MIN_IDLE_SECONDS 10
-static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-static unsigned long most_recent_message_jiffies;	/* when we got our last
-						 * controlvm message */
-static int serverregistered;
-static int clientregistered;
-
-#define MAX_CHIPSET_EVENTS 2
-static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
-
-struct parser_context {
-	unsigned long allocbytes;
-	unsigned long param_bytes;
-	u8 *curr;
-	unsigned long bytes_remaining;
-	bool byte_stream;
-	char data[0];
-};
-
-static struct delayed_work periodic_controlvm_work;
-static struct workqueue_struct *periodic_controlvm_workqueue;
-static DEFINE_SEMAPHORE(notifier_lock);
-
-static struct cdev file_cdev;
-static struct visorchannel **file_controlvm_channel;
-static struct controlvm_message_header g_chipset_msg_hdr;
-static const uuid_le spar_diag_pool_channel_protocol_uuid =
-	SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
-/* 0xffffff is an invalid Bus/Device number */
-static u32 g_diagpool_bus_no = 0xffffff;
-static u32 g_diagpool_dev_no = 0xffffff;
-static struct controlvm_message_packet g_devicechangestate_packet;
-
-/* Only VNIC and VHBA channels are sent to visorclientbus (aka
- * "visorhackbus")
- */
-#define FOR_VISORHACKBUS(channel_type_guid) \
-	(((uuid_le_cmp(channel_type_guid,\
-		       spar_vnic_channel_protocol_uuid) == 0) ||\
-	(uuid_le_cmp(channel_type_guid,\
-			spar_vhba_channel_protocol_uuid) == 0)))
-#define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
-
-#define is_diagpool_channel(channel_type_guid) \
-	(uuid_le_cmp(channel_type_guid,\
-		     spar_diag_pool_channel_protocol_uuid) == 0)
-
-static LIST_HEAD(bus_info_list);
-static LIST_HEAD(dev_info_list);
-
-static struct visorchannel *controlvm_channel;
-
-/* Manages the request payload in the controlvm channel */
-struct visor_controlvm_payload_info {
-	u8 __iomem *ptr;	/* pointer to base address of payload pool */
-	u64 offset;		/* offset from beginning of controlvm
-				 * channel to beginning of payload * pool */
-	u32 bytes;		/* number of bytes in payload pool */
-};
-
-static struct visor_controlvm_payload_info controlvm_payload_info;
-
-/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
- * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
- */
-struct visor_livedump_info {
-	struct controlvm_message_header dumpcapture_header;
-	struct controlvm_message_header gettextdump_header;
-	struct controlvm_message_header dumpcomplete_header;
-	bool gettextdump_outstanding;
-	u32 crc32;
-	unsigned long length;
-	atomic_t buffers_in_use;
-	unsigned long destination;
-};
-
-static struct visor_livedump_info livedump_info;
-
-/* The following globals are used to handle the scenario where we are unable to
- * offload the payload from a controlvm message due to memory requirements.  In
- * this scenario, we simply stash the controlvm message, then attempt to
- * process it again the next time controlvm_periodic_work() runs.
- */
-static struct controlvm_message controlvm_pending_msg;
-static bool controlvm_pending_msg_valid = false;
-
-/* This identifies a data buffer that has been received via a controlvm messages
- * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
- */
-struct putfile_buffer_entry {
-	struct list_head next;	/* putfile_buffer_entry list */
-	struct parser_context *parser_ctx; /* points to input data buffer */
-};
-
-/* List of struct putfile_request *, via next_putfile_request member.
- * Each entry in this list identifies an outstanding TRANSMIT_FILE
- * conversation.
- */
-static LIST_HEAD(putfile_request_list);
-
-/* This describes a buffer and its current state of transfer (e.g., how many
- * bytes have already been supplied as putfile data, and how many bytes are
- * remaining) for a putfile_request.
- */
-struct putfile_active_buffer {
-	/* a payload from a controlvm message, containing a file data buffer */
-	struct parser_context *parser_ctx;
-	/* points within data area of parser_ctx to next byte of data */
-	u8 *pnext;
-	/* # bytes left from <pnext> to the end of this data buffer */
-	size_t bytes_remaining;
-};
-
-#define PUTFILE_REQUEST_SIG 0x0906101302281211
-/* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
- * conversation.  Structs of this type are dynamically linked into
- * <Putfile_request_list>.
- */
-struct putfile_request {
-	u64 sig;		/* PUTFILE_REQUEST_SIG */
-
-	/* header from original TransmitFile request */
-	struct controlvm_message_header controlvm_header;
-	u64 file_request_number;	/* from original TransmitFile request */
-
-	/* link to next struct putfile_request */
-	struct list_head next_putfile_request;
-
-	/* most-recent sequence number supplied via a controlvm message */
-	u64 data_sequence_number;
-
-	/* head of putfile_buffer_entry list, which describes the data to be
-	 * supplied as putfile data;
-	 * - this list is added to when controlvm messages come in that supply
-	 * file data
-	 * - this list is removed from via the hotplug program that is actually
-	 * consuming these buffers to write as file data */
-	struct list_head input_buffer_list;
-	spinlock_t req_list_lock;	/* lock for input_buffer_list */
-
-	/* waiters for input_buffer_list to go non-empty */
-	wait_queue_head_t input_buffer_wq;
-
-	/* data not yet read within current putfile_buffer_entry */
-	struct putfile_active_buffer active_buf;
-
-	/* <0 = failed, 0 = in-progress, >0 = successful; */
-	/* note that this must be set with req_list_lock, and if you set <0, */
-	/* it is your responsibility to also free up all of the other objects */
-	/* in this struct (like input_buffer_list, active_buf.parser_ctx) */
-	/* before releasing the lock */
-	int completion_status;
-};
-
-struct parahotplug_request {
-	struct list_head list;
-	int id;
-	unsigned long expiration;
-	struct controlvm_message msg;
-};
-
-static LIST_HEAD(parahotplug_request_list);
-static DEFINE_SPINLOCK(parahotplug_request_list_lock);	/* lock for above */
-static void parahotplug_process_list(void);
-
-/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
- * CONTROLVM_REPORTEVENT.
- */
-static struct visorchipset_busdev_notifiers busdev_server_notifiers;
-static struct visorchipset_busdev_notifiers busdev_client_notifiers;
-
-static void bus_create_response(u32 bus_no, int response);
-static void bus_destroy_response(u32 bus_no, int response);
-static void device_create_response(u32 bus_no, u32 dev_no, int response);
-static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
-static void device_resume_response(u32 bus_no, u32 dev_no, int response);
-
-static struct visorchipset_busdev_responders busdev_responders = {
-	.bus_create = bus_create_response,
-	.bus_destroy = bus_destroy_response,
-	.device_create = device_create_response,
-	.device_destroy = device_destroy_response,
-	.device_pause = visorchipset_device_pause_response,
-	.device_resume = device_resume_response,
-};
-
-/* info for /dev/visorchipset */
-static dev_t major_dev = -1; /**< indicates major num for device */
-
-/* prototypes for attributes */
-static ssize_t toolaction_show(struct device *dev,
-			       struct device_attribute *attr, char *buf);
-static ssize_t toolaction_store(struct device *dev,
-				struct device_attribute *attr,
-				const char *buf, size_t count);
-static DEVICE_ATTR_RW(toolaction);
-
-static ssize_t boottotool_show(struct device *dev,
-			       struct device_attribute *attr, char *buf);
-static ssize_t boottotool_store(struct device *dev,
-				struct device_attribute *attr, const char *buf,
-				size_t count);
-static DEVICE_ATTR_RW(boottotool);
-
-static ssize_t error_show(struct device *dev, struct device_attribute *attr,
-			  char *buf);
-static ssize_t error_store(struct device *dev, struct device_attribute *attr,
-			   const char *buf, size_t count);
-static DEVICE_ATTR_RW(error);
-
-static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
-			   char *buf);
-static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
-			    const char *buf, size_t count);
-static DEVICE_ATTR_RW(textid);
-
-static ssize_t remaining_steps_show(struct device *dev,
-				    struct device_attribute *attr, char *buf);
-static ssize_t remaining_steps_store(struct device *dev,
-				     struct device_attribute *attr,
-				     const char *buf, size_t count);
-static DEVICE_ATTR_RW(remaining_steps);
-
-static ssize_t chipsetready_store(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf, size_t count);
-static DEVICE_ATTR_WO(chipsetready);
-
-static ssize_t devicedisabled_store(struct device *dev,
-				    struct device_attribute *attr,
-				    const char *buf, size_t count);
-static DEVICE_ATTR_WO(devicedisabled);
-
-static ssize_t deviceenabled_store(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf, size_t count);
-static DEVICE_ATTR_WO(deviceenabled);
-
-static struct attribute *visorchipset_install_attrs[] = {
-	&dev_attr_toolaction.attr,
-	&dev_attr_boottotool.attr,
-	&dev_attr_error.attr,
-	&dev_attr_textid.attr,
-	&dev_attr_remaining_steps.attr,
-	NULL
-};
-
-static struct attribute_group visorchipset_install_group = {
-	.name = "install",
-	.attrs = visorchipset_install_attrs
-};
-
-static struct attribute *visorchipset_guest_attrs[] = {
-	&dev_attr_chipsetready.attr,
-	NULL
-};
-
-static struct attribute_group visorchipset_guest_group = {
-	.name = "guest",
-	.attrs = visorchipset_guest_attrs
-};
-
-static struct attribute *visorchipset_parahotplug_attrs[] = {
-	&dev_attr_devicedisabled.attr,
-	&dev_attr_deviceenabled.attr,
-	NULL
-};
-
-static struct attribute_group visorchipset_parahotplug_group = {
-	.name = "parahotplug",
-	.attrs = visorchipset_parahotplug_attrs
-};
-
-static const struct attribute_group *visorchipset_dev_groups[] = {
-	&visorchipset_install_group,
-	&visorchipset_guest_group,
-	&visorchipset_parahotplug_group,
-	NULL
-};
-
-/* /sys/devices/platform/visorchipset */
-static struct platform_device visorchipset_platform_device = {
-	.name = "visorchipset",
-	.id = -1,
-	.dev.groups = visorchipset_dev_groups,
-};
-
-/* Function prototypes */
-static void controlvm_respond(struct controlvm_message_header *msg_hdr,
-			      int response);
-static void controlvm_respond_chipset_init(
-		struct controlvm_message_header *msg_hdr, int response,
-		enum ultra_chipset_feature features);
-static void controlvm_respond_physdev_changestate(
-		struct controlvm_message_header *msg_hdr, int response,
-		struct spar_segment_state state);
-
-
-static struct parser_context *
-parser_init_guts(u64 addr, u32 bytes, bool local,
-		 bool standard_payload_header, bool *retry)
-{
-	int allocbytes = sizeof(struct parser_context) + bytes;
-	struct parser_context *rc = NULL;
-	struct parser_context *ctx = NULL;
-	struct memregion *rgn = NULL;
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (retry)
-		*retry = false;
-	if (!standard_payload_header)
-		/* alloc and 0 extra byte to ensure payload is
-		 * '\0'-terminated
-		 */
-		allocbytes++;
-	if ((controlvm_payload_bytes_buffered + bytes)
-	    > MAX_CONTROLVM_PAYLOAD_BYTES) {
-		if (retry)
-			*retry = true;
-		rc = NULL;
-		goto cleanup;
-	}
-	ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
-	if (!ctx) {
-		if (retry)
-			*retry = true;
-		rc = NULL;
-		goto cleanup;
-	}
-
-	ctx->allocbytes = allocbytes;
-	ctx->param_bytes = bytes;
-	ctx->curr = NULL;
-	ctx->bytes_remaining = 0;
-	ctx->byte_stream = false;
-	if (local) {
-		void *p;
-
-		if (addr > virt_to_phys(high_memory - 1)) {
-			rc = NULL;
-			goto cleanup;
-		}
-		p = __va((unsigned long) (addr));
-		memcpy(ctx->data, p, bytes);
-	} else {
-		rgn = visor_memregion_create(addr, bytes);
-		if (!rgn) {
-			rc = NULL;
-			goto cleanup;
-		}
-		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
-			rc = NULL;
-			goto cleanup;
-		}
-	}
-	if (!standard_payload_header) {
-		ctx->byte_stream = true;
-		rc = ctx;
-		goto cleanup;
-	}
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	if (phdr->total_length != bytes) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->total_length < phdr->header_length) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->header_length <
-	    sizeof(struct spar_controlvm_parameters_header)) {
-		rc = NULL;
-		goto cleanup;
-	}
-
-	rc = ctx;
-cleanup:
-	if (rgn) {
-		visor_memregion_destroy(rgn);
-		rgn = NULL;
-	}
-	if (rc) {
-		controlvm_payload_bytes_buffered += ctx->param_bytes;
-	} else {
-		if (ctx) {
-			parser_done(ctx);
-			ctx = NULL;
-		}
-	}
-	return rc;
-}
-
-struct parser_context *
-parser_init(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, true, retry);
-}
-
-/* Call this instead of parser_init() if the payload area consists of just
- * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
- * structures.  Afterwards, you can call parser_simpleString_get() or
- * parser_byteStream_get() to obtain the data.
- */
-struct parser_context *
-parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, false, retry);
-}
-
-/* Obtain '\0'-terminated copy of string in payload area.
- */
-char *
-parser_simpleString_get(struct parser_context *ctx)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	return ctx->data;	/* note this IS '\0'-terminated, because of
-				 * the num of bytes we alloc+clear in
-				 * parser_init_byteStream() */
-}
-
-/* Obtain a copy of the buffer in the payload area.
- */
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	if (nbytes)
-		*nbytes = ctx->param_bytes;
-	return (void *)ctx->data;
-}
-
-uuid_le
-parser_id_get(struct parser_context *ctx)
-{
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (ctx == NULL)
-		return NULL_UUID_LE;
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	return phdr->id;
-}
-
-void
-parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
-{
-	struct spar_controlvm_parameters_header *phdr = NULL;
-
-	if (ctx == NULL)
-		goto Away;
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	switch (which_string) {
-	case PARSERSTRING_INITIATOR:
-		ctx->curr = ctx->data + phdr->initiator_offset;
-		ctx->bytes_remaining = phdr->initiator_length;
-		break;
-	case PARSERSTRING_TARGET:
-		ctx->curr = ctx->data + phdr->target_offset;
-		ctx->bytes_remaining = phdr->target_length;
-		break;
-	case PARSERSTRING_CONNECTION:
-		ctx->curr = ctx->data + phdr->connection_offset;
-		ctx->bytes_remaining = phdr->connection_length;
-		break;
-	case PARSERSTRING_NAME:
-		ctx->curr = ctx->data + phdr->name_offset;
-		ctx->bytes_remaining = phdr->name_length;
-		break;
-	default:
-		break;
-	}
-
-Away:
-	return;
-}
-
-void
-parser_done(struct parser_context *ctx)
-{
-	if (!ctx)
-		return;
-	controlvm_payload_bytes_buffered -= ctx->param_bytes;
-	kfree(ctx);
-}
-
-/** Return length of string not counting trailing spaces. */
-static int
-string_length_no_trail(char *s, int len)
-{
-	int i = len - 1;
-
-	while (i >= 0) {
-		if (!isspace(s[i]))
-			return i + 1;
-		i--;
-	}
-	return 0;
-}
-
-/** Grab the next name and value out of the parameter buffer.
- *  The entire parameter buffer looks like this:
- *      <name>=<value>\0
- *      <name>=<value>\0
- *      ...
- *      \0
- *  If successful, the next <name> value is returned within the supplied
- *  <nam> buffer (the value is always upper-cased), and the corresponding
- *  <value> is returned within a kmalloc()ed buffer, whose pointer is
- *  provided as the return value of this function.
- *  (The total number of bytes allocated is strlen(<value>)+1.)
- *
- *  NULL is returned to indicate failure, which can occur for several reasons:
- *  - all <name>=<value> pairs have already been processed
- *  - bad parameter
- *  - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
- *    the confines of the parameter buffer)
- *  - the <nam> buffer is not large enough to hold the <name> of the next
- *    parameter
- */
-void *
-parser_param_get(struct parser_context *ctx, char *nam, int namesize)
-{
-	u8 *pscan, *pnam = nam;
-	unsigned long nscan;
-	int value_length = -1, orig_value_length = -1;
-	void *value = NULL;
-	int i;
-	int closing_quote = 0;
-
-	if (!ctx)
-		return NULL;
-	pscan = ctx->curr;
-	nscan = ctx->bytes_remaining;
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\0')
-		/*  This is the normal return point after you have processed
-		 *  all of the <name>=<value> pairs in a syntactically-valid
-		 *  parameter buffer.
-		 */
-		return NULL;
-
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	while (*pscan != ':') {
-		if (namesize <= 0)
-			return NULL;
-		*pnam = toupper(*pscan);
-		pnam++;
-		namesize--;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (namesize <= 0)
-		return NULL;
-	*pnam = '\0';
-	nam[string_length_no_trail(nam, strlen(nam))] = '\0';
-
-	/* point to char immediately after ":" in "<name>:<value>" */
-	pscan++;
-	nscan--;
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\'' || *pscan == '"') {
-		closing_quote = *pscan;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	/* look for a separator character, terminator character, or
-	 * end of data
-	 */
-	for (i = 0, value_length = -1; i < nscan; i++) {
-		if (closing_quote) {
-			if (pscan[i] == '\0')
-				return NULL;
-			if (pscan[i] == closing_quote) {
-				value_length = i;
-				break;
-			}
-		} else
-		    if (pscan[i] == ',' || pscan[i] == ';'
-			|| pscan[i] == '\0') {
-			value_length = i;
-			break;
-		}
-	}
-	if (value_length < 0) {
-		if (closing_quote)
-			return NULL;
-		value_length = nscan;
-	}
-	orig_value_length = value_length;
-	if (closing_quote == 0)
-		value_length = string_length_no_trail(pscan, orig_value_length);
-	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
-	if (value == NULL)
-		return NULL;
-	memcpy(value, pscan, value_length);
-	((u8 *) (value))[value_length] = '\0';
-
-	pscan += orig_value_length;
-	nscan -= orig_value_length;
-
-	/* skip past separator or closing quote */
-	if (nscan > 0) {
-		if (*pscan != '\0') {
-			pscan++;
-			nscan--;
-		}
-	}
-
-	if (closing_quote && (nscan > 0)) {
-		/* we still need to skip around the real separator if present */
-		/* first, skip whitespace */
-		while (isspace(*pscan)) {
-			pscan++;
-			nscan--;
-			if (nscan == 0)
-				break;
-		}
-		if (nscan > 0) {
-			if (*pscan == ',' || *pscan == ';') {
-				pscan++;
-				nscan--;
-			} else if (*pscan != '\0') {
-				kfree(value);
-				value = NULL;
-				return NULL;
-			}
-		}
-	}
-	ctx->curr = pscan;
-	ctx->bytes_remaining = nscan;
-	return value;
-}
-
-void *
-parser_string_get(struct parser_context *ctx)
-{
-	u8 *pscan;
-	unsigned long nscan;
-	int value_length = -1;
-	void *value = NULL;
-	int i;
-
-	if (!ctx)
-		return NULL;
-	pscan = ctx->curr;
-	nscan = ctx->bytes_remaining;
-	if (nscan == 0)
-		return NULL;
-	if (!pscan)
-		return NULL;
-	for (i = 0, value_length = -1; i < nscan; i++)
-		if (pscan[i] == '\0') {
-			value_length = i;
-			break;
-		}
-	if (value_length < 0)	/* '\0' was not included in the length */
-		value_length = nscan;
-	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
-	if (value == NULL)
-		return NULL;
-	if (value_length > 0)
-		memcpy(value, pscan, value_length);
-	((u8 *) (value))[value_length] = '\0';
-	return value;
-}
-
-
-static ssize_t toolaction_show(struct device *dev,
-			       struct device_attribute *attr,
-			       char *buf)
-{
-	u8 tool_action;
-
-	visorchannel_read(controlvm_channel,
-		offsetof(struct spar_controlvm_channel_protocol,
-			 tool_action), &tool_action, sizeof(u8));
-	return scnprintf(buf, PAGE_SIZE, "%u\n", tool_action);
-}
-
-static ssize_t toolaction_store(struct device *dev,
-				struct device_attribute *attr,
-				const char *buf, size_t count)
-{
-	u8 tool_action;
-	int ret;
-
-	if (kstrtou8(buf, 10, &tool_action))
-		return -EINVAL;
-
-	ret = visorchannel_write(controlvm_channel,
-		offsetof(struct spar_controlvm_channel_protocol,
-			 tool_action),
-		&tool_action, sizeof(u8));
-
-	if (ret)
-		return ret;
-	return count;
-}
-
-static ssize_t boottotool_show(struct device *dev,
-			       struct device_attribute *attr,
-			       char *buf)
-{
-	struct efi_spar_indication efi_spar_indication;
-
-	visorchannel_read(controlvm_channel,
-			  offsetof(struct spar_controlvm_channel_protocol,
-				   efi_spar_ind), &efi_spar_indication,
-			  sizeof(struct efi_spar_indication));
-	return scnprintf(buf, PAGE_SIZE, "%u\n",
-			 efi_spar_indication.boot_to_tool);
-}
-
-static ssize_t boottotool_store(struct device *dev,
-				struct device_attribute *attr,
-				const char *buf, size_t count)
-{
-	int val, ret;
-	struct efi_spar_indication efi_spar_indication;
-
-	if (kstrtoint(buf, 10, &val))
-		return -EINVAL;
-
-	efi_spar_indication.boot_to_tool = val;
-	ret = visorchannel_write(controlvm_channel,
-			offsetof(struct spar_controlvm_channel_protocol,
-				 efi_spar_ind), &(efi_spar_indication),
-				 sizeof(struct efi_spar_indication));
-
-	if (ret)
-		return ret;
-	return count;
-}
-
-static ssize_t error_show(struct device *dev, struct device_attribute *attr,
-			  char *buf)
-{
-	u32 error;
-
-	visorchannel_read(controlvm_channel,
-			  offsetof(struct spar_controlvm_channel_protocol,
-				   installation_error),
-			  &error, sizeof(u32));
-	return scnprintf(buf, PAGE_SIZE, "%i\n", error);
-}
-
-static ssize_t error_store(struct device *dev, struct device_attribute *attr,
-			   const char *buf, size_t count)
-{
-	u32 error;
-	int ret;
-
-	if (kstrtou32(buf, 10, &error))
-		return -EINVAL;
-
-	ret = visorchannel_write(controlvm_channel,
-		offsetof(struct spar_controlvm_channel_protocol,
-			 installation_error),
-		&error, sizeof(u32));
-	if (ret)
-		return ret;
-	return count;
-}
-
-static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
-			   char *buf)
-{
-	u32 text_id;
-
-	visorchannel_read(controlvm_channel,
-			  offsetof(struct spar_controlvm_channel_protocol,
-				   installation_text_id),
-			  &text_id, sizeof(u32));
-	return scnprintf(buf, PAGE_SIZE, "%i\n", text_id);
-}
-
-static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
-			    const char *buf, size_t count)
-{
-	u32 text_id;
-	int ret;
-
-	if (kstrtou32(buf, 10, &text_id))
-		return -EINVAL;
-
-	ret = visorchannel_write(controlvm_channel,
-		offsetof(struct spar_controlvm_channel_protocol,
-			 installation_text_id),
-		&text_id, sizeof(u32));
-	if (ret)
-		return ret;
-	return count;
-}
-
-static ssize_t remaining_steps_show(struct device *dev,
-				    struct device_attribute *attr, char *buf)
-{
-	u16 remaining_steps;
-
-	visorchannel_read(controlvm_channel,
-			  offsetof(struct spar_controlvm_channel_protocol,
-				   installation_remaining_steps),
-			  &remaining_steps, sizeof(u16));
-	return scnprintf(buf, PAGE_SIZE, "%hu\n", remaining_steps);
-}
-
-static ssize_t remaining_steps_store(struct device *dev,
-				     struct device_attribute *attr,
-				     const char *buf, size_t count)
-{
-	u16 remaining_steps;
-	int ret;
-
-	if (kstrtou16(buf, 10, &remaining_steps))
-		return -EINVAL;
-
-	ret = visorchannel_write(controlvm_channel,
-		offsetof(struct spar_controlvm_channel_protocol,
-			 installation_remaining_steps),
-		&remaining_steps, sizeof(u16));
-	if (ret)
-		return ret;
-	return count;
-}
-
-static void
-bus_info_clear(void *v)
-{
-	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
-
-	kfree(p->name);
-	kfree(p->description);
-	memset(p, 0, sizeof(struct visorchipset_bus_info));
-}
-
-static void
-dev_info_clear(void *v)
-{
-	struct visorchipset_device_info *p =
-		(struct visorchipset_device_info *) v;
-
-	memset(p, 0, sizeof(struct visorchipset_device_info));
-}
-
-static struct visorchipset_bus_info *
-bus_find(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_bus_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no)
-			return p;
-	}
-
-	return NULL;
-}
-
-static struct visorchipset_device_info *
-device_find(struct list_head *list, u32 bus_no, u32 dev_no)
-{
-	struct visorchipset_device_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no && p->dev_no == dev_no)
-			return p;
-	}
-
-	return NULL;
-}
-
-static void busdevices_del(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_device_info *p, *tmp;
-
-	list_for_each_entry_safe(p, tmp, list, entry) {
-		if (p->bus_no == bus_no) {
-			list_del(&p->entry);
-			kfree(p);
-		}
-	}
-}
-
-static u8
-check_chipset_events(void)
-{
-	int i;
-	u8 send_msg = 1;
-	/* Check events to determine if response should be sent */
-	for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
-		send_msg &= chipset_events[i];
-	return send_msg;
-}
-
-static void
-clear_chipset_events(void)
-{
-	int i;
-	/* Clear chipset_events */
-	for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
-		chipset_events[i] = 0;
-}
-
-void
-visorchipset_register_busdev_server(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info)
-{
-	down(&notifier_lock);
-	if (!notifiers) {
-		memset(&busdev_server_notifiers, 0,
-		       sizeof(busdev_server_notifiers));
-		serverregistered = 0;	/* clear flag */
-	} else {
-		busdev_server_notifiers = *notifiers;
-		serverregistered = 1;	/* set flag */
-	}
-	if (responders)
-		*responders = busdev_responders;
-	if (driver_info)
-		bus_device_info_init(driver_info, "chipset", "visorchipset",
-				     VERSION, NULL);
-
-	up(&notifier_lock);
-}
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
-
-void
-visorchipset_register_busdev_client(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info)
-{
-	down(&notifier_lock);
-	if (!notifiers) {
-		memset(&busdev_client_notifiers, 0,
-		       sizeof(busdev_client_notifiers));
-		clientregistered = 0;	/* clear flag */
-	} else {
-		busdev_client_notifiers = *notifiers;
-		clientregistered = 1;	/* set flag */
-	}
-	if (responders)
-		*responders = busdev_responders;
-	if (driver_info)
-		bus_device_info_init(driver_info, "chipset(bolts)",
-				     "visorchipset", VERSION, NULL);
-	up(&notifier_lock);
-}
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
-
-static void
-cleanup_controlvm_structures(void)
-{
-	struct visorchipset_bus_info *bi, *tmp_bi;
-	struct visorchipset_device_info *di, *tmp_di;
-
-	list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
-		bus_info_clear(bi);
-		list_del(&bi->entry);
-		kfree(bi);
-	}
-
-	list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
-		dev_info_clear(di);
-		list_del(&di->entry);
-		kfree(di);
-	}
-}
-
-static void
-chipset_init(struct controlvm_message *inmsg)
-{
-	static int chipset_inited;
-	enum ultra_chipset_feature features = 0;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-	if (chipset_inited) {
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-		goto cleanup;
-	}
-	chipset_inited = 1;
-	POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
-
-	/* Set features to indicate we support parahotplug (if Command
-	 * also supports it). */
-	features =
-	    inmsg->cmd.init_chipset.
-	    features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG;
-
-	/* Set the "reply" bit so Command knows this is a
-	 * features-aware driver. */
-	features |= ULTRA_CHIPSET_FEATURE_REPLY;
-
-cleanup:
-	if (rc < 0)
-		cleanup_controlvm_structures();
-	if (inmsg->hdr.flags.response_expected)
-		controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
-}
-
-static void
-controlvm_init_response(struct controlvm_message *msg,
-			struct controlvm_message_header *msg_hdr, int response)
-{
-	memset(msg, 0, sizeof(struct controlvm_message));
-	memcpy(&msg->hdr, msg_hdr, sizeof(struct controlvm_message_header));
-	msg->hdr.payload_bytes = 0;
-	msg->hdr.payload_vm_offset = 0;
-	msg->hdr.payload_max_bytes = 0;
-	if (response < 0) {
-		msg->hdr.flags.failed = 1;
-		msg->hdr.completion_status = (u32) (-response);
-	}
-}
-
-static void
-controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
-{
-	struct controlvm_message outmsg;
-
-	controlvm_init_response(&outmsg, msg_hdr, response);
-	/* For DiagPool channel DEVICE_CHANGESTATE, we need to send
-	* back the deviceChangeState structure in the packet. */
-	if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
-	    g_devicechangestate_packet.device_change_state.bus_no ==
-	    g_diagpool_bus_no &&
-	    g_devicechangestate_packet.device_change_state.dev_no ==
-	    g_diagpool_dev_no)
-		outmsg.cmd = g_devicechangestate_packet;
-	if (outmsg.hdr.flags.test_message == 1)
-		return;
-
-	if (!visorchannel_signalinsert(controlvm_channel,
-				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-		return;
-	}
-}
-
-static void
-controlvm_respond_chipset_init(struct controlvm_message_header *msg_hdr,
-			       int response,
-			       enum ultra_chipset_feature features)
-{
-	struct controlvm_message outmsg;
-
-	controlvm_init_response(&outmsg, msg_hdr, response);
-	outmsg.cmd.init_chipset.features = features;
-	if (!visorchannel_signalinsert(controlvm_channel,
-				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-		return;
-	}
-}
-
-static void controlvm_respond_physdev_changestate(
-		struct controlvm_message_header *msg_hdr, int response,
-		struct spar_segment_state state)
-{
-	struct controlvm_message outmsg;
-
-	controlvm_init_response(&outmsg, msg_hdr, response);
-	outmsg.cmd.device_change_state.state = state;
-	outmsg.cmd.device_change_state.flags.phys_device = 1;
-	if (!visorchannel_signalinsert(controlvm_channel,
-				       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-		return;
-	}
-}
-
-void
-visorchipset_save_message(struct controlvm_message *msg,
-			  enum crash_obj_type type)
-{
-	u32 crash_msg_offset;
-	u16 crash_msg_count;
-
-	/* get saved message count */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_count),
-			      &crash_msg_count, sizeof(u16)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
-		POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
-				 crash_msg_count,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* get saved crash message offset */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_offset),
-			      &crash_msg_offset, sizeof(u32)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	if (type == CRASH_BUS) {
-		if (visorchannel_write(controlvm_channel,
-				       crash_msg_offset,
-				       msg,
-				       sizeof(struct controlvm_message)) < 0) {
-			POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
-					 POSTCODE_SEVERITY_ERR);
-			return;
-		}
-	} else {
-		if (visorchannel_write(controlvm_channel,
-				       crash_msg_offset +
-				       sizeof(struct controlvm_message), msg,
-				       sizeof(struct controlvm_message)) < 0) {
-			POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
-					 POSTCODE_SEVERITY_ERR);
-			return;
-		}
-	}
-}
-EXPORT_SYMBOL_GPL(visorchipset_save_message);
-
-static void
-bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
-{
-	struct visorchipset_bus_info *p;
-	bool need_clear = false;
-
-	p = bus_find(&bus_info_list, bus_no);
-	if (!p)
-		return;
-
-	if (response < 0) {
-		if ((cmd_id == CONTROLVM_BUS_CREATE) &&
-		    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
-			/* undo the row we just created... */
-			busdevices_del(&dev_info_list, bus_no);
-	} else {
-		if (cmd_id == CONTROLVM_BUS_CREATE)
-			p->state.created = 1;
-		if (cmd_id == CONTROLVM_BUS_DESTROY)
-			need_clear = true;
-	}
-
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
-		return;		/* no controlvm response needed */
-	if (p->pending_msg_hdr.id != (u32)cmd_id)
-		return;
-	controlvm_respond(&p->pending_msg_hdr, response);
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear) {
-		bus_info_clear(p);
-		busdevices_del(&dev_info_list, bus_no);
-	}
-}
-
-static void
-device_changestate_responder(enum controlvm_id cmd_id,
-			     u32 bus_no, u32 dev_no, int response,
-			     struct spar_segment_state response_state)
-{
-	struct visorchipset_device_info *p;
-	struct controlvm_message outmsg;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
-		return;		/* no controlvm response needed */
-	if (p->pending_msg_hdr.id != cmd_id)
-		return;
-
-	controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
-
-	outmsg.cmd.device_change_state.bus_no = bus_no;
-	outmsg.cmd.device_change_state.dev_no = dev_no;
-	outmsg.cmd.device_change_state.state = response_state;
-
-	if (!visorchannel_signalinsert(controlvm_channel,
-				       CONTROLVM_QUEUE_REQUEST, &outmsg))
-		return;
-
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-}
-
-static void
-device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
-{
-	struct visorchipset_device_info *p;
-	bool need_clear = false;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
-	if (response >= 0) {
-		if (cmd_id == CONTROLVM_DEVICE_CREATE)
-			p->state.created = 1;
-		if (cmd_id == CONTROLVM_DEVICE_DESTROY)
-			need_clear = true;
-	}
-
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
-		return;		/* no controlvm response needed */
-
-	if (p->pending_msg_hdr.id != (u32)cmd_id)
-		return;
-
-	controlvm_respond(&p->pending_msg_hdr, response);
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear)
-		dev_info_clear(p);
-}
-
-static void
-bus_epilog(u32 bus_no,
-	   u32 cmd, struct controlvm_message_header *msg_hdr,
-	   int response, bool need_response)
-{
-	struct visorchipset_bus_info *bus_info;
-	bool notified = false;
-
-	bus_info = bus_find(&bus_info_list, bus_no);
-
-	if (!bus_info)
-		return;
-
-	if (need_response) {
-		memcpy(&bus_info->pending_msg_hdr, msg_hdr,
-		       sizeof(struct controlvm_message_header));
-	} else {
-		bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
-	}
-
-	down(&notifier_lock);
-	if (response == CONTROLVM_RESP_SUCCESS) {
-		switch (cmd) {
-		case CONTROLVM_BUS_CREATE:
-			/* We can't tell from the bus_create
-			* information which of our 2 bus flavors the
-			* devices on this bus will ultimately end up.
-			* FORTUNATELY, it turns out it is harmless to
-			* send the bus_create to both of them.  We can
-			* narrow things down a little bit, though,
-			* because we know: - BusDev_Server can handle
-			* either server or client devices
-			* - BusDev_Client can handle ONLY client
-			* devices */
-			if (busdev_server_notifiers.bus_create) {
-				(*busdev_server_notifiers.bus_create) (bus_no);
-				notified = true;
-			}
-			if ((!bus_info->flags.server) /*client */ &&
-			    busdev_client_notifiers.bus_create) {
-				(*busdev_client_notifiers.bus_create) (bus_no);
-				notified = true;
-			}
-			break;
-		case CONTROLVM_BUS_DESTROY:
-			if (busdev_server_notifiers.bus_destroy) {
-				(*busdev_server_notifiers.bus_destroy) (bus_no);
-				notified = true;
-			}
-			if ((!bus_info->flags.server) /*client */ &&
-			    busdev_client_notifiers.bus_destroy) {
-				(*busdev_client_notifiers.bus_destroy) (bus_no);
-				notified = true;
-			}
-			break;
-		}
-	}
-	if (notified)
-		/* The callback function just called above is responsible
-		 * for calling the appropriate visorchipset_busdev_responders
-		 * function, which will call bus_responder()
-		 */
-		;
-	else
-		bus_responder(cmd, bus_no, response);
-	up(&notifier_lock);
-}
-
-static void
-device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
-	      struct controlvm_message_header *msg_hdr, int response,
-	      bool need_response, bool for_visorbus)
-{
-	struct visorchipset_busdev_notifiers *notifiers;
-	bool notified = false;
-
-	struct visorchipset_device_info *dev_info =
-		device_find(&dev_info_list, bus_no, dev_no);
-	char *envp[] = {
-		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
-		NULL
-	};
-
-	if (!dev_info)
-		return;
-
-	if (for_visorbus)
-		notifiers = &busdev_server_notifiers;
-	else
-		notifiers = &busdev_client_notifiers;
-	if (need_response) {
-		memcpy(&dev_info->pending_msg_hdr, msg_hdr,
-		       sizeof(struct controlvm_message_header));
-	} else {
-		dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
-	}
-
-	down(&notifier_lock);
-	if (response >= 0) {
-		switch (cmd) {
-		case CONTROLVM_DEVICE_CREATE:
-			if (notifiers->device_create) {
-				(*notifiers->device_create) (bus_no, dev_no);
-				notified = true;
-			}
-			break;
-		case CONTROLVM_DEVICE_CHANGESTATE:
-			/* ServerReady / ServerRunning / SegmentStateRunning */
-			if (state.alive == segment_state_running.alive &&
-			    state.operating ==
-				segment_state_running.operating) {
-				if (notifiers->device_resume) {
-					(*notifiers->device_resume) (bus_no,
-								     dev_no);
-					notified = true;
-				}
-			}
-			/* ServerNotReady / ServerLost / SegmentStateStandby */
-			else if (state.alive == segment_state_standby.alive &&
-				 state.operating ==
-				 segment_state_standby.operating) {
-				/* technically this is standby case
-				 * where server is lost
-				 */
-				if (notifiers->device_pause) {
-					(*notifiers->device_pause) (bus_no,
-								    dev_no);
-					notified = true;
-				}
-			} else if (state.alive == segment_state_paused.alive &&
-				   state.operating ==
-				   segment_state_paused.operating) {
-				/* this is lite pause where channel is
-				 * still valid just 'pause' of it
-				 */
-				if (bus_no == g_diagpool_bus_no &&
-				    dev_no == g_diagpool_dev_no) {
-					/* this will trigger the
-					 * diag_shutdown.sh script in
-					 * the visorchipset hotplug */
-					kobject_uevent_env
-					    (&visorchipset_platform_device.dev.
-					     kobj, KOBJ_ONLINE, envp);
-				}
-			}
-			break;
-		case CONTROLVM_DEVICE_DESTROY:
-			if (notifiers->device_destroy) {
-				(*notifiers->device_destroy) (bus_no, dev_no);
-				notified = true;
-			}
-			break;
-		}
-	}
-	if (notified)
-		/* The callback function just called above is responsible
-		 * for calling the appropriate visorchipset_busdev_responders
-		 * function, which will call device_responder()
-		 */
-		;
-	else
-		device_responder(cmd, bus_no, dev_no, response);
-	up(&notifier_lock);
-}
-
-static void
-bus_create(struct controlvm_message *inmsg)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->create_bus.bus_no;
-	int rc = CONTROLVM_RESP_SUCCESS;
-	struct visorchipset_bus_info *bus_info;
-
-	bus_info = bus_find(&bus_info_list, bus_no);
-	if (bus_info && (bus_info->state.created == 1)) {
-		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-		goto cleanup;
-	}
-	bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
-	if (!bus_info) {
-		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
-		goto cleanup;
-	}
-
-	INIT_LIST_HEAD(&bus_info->entry);
-	bus_info->bus_no = bus_no;
-
-	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
-
-	if (inmsg->hdr.flags.test_message == 1)
-		bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
-	else
-		bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-
-	bus_info->flags.server = inmsg->hdr.flags.server;
-	bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
-	bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
-	bus_info->chan_info.channel_type_uuid =
-			cmd->create_bus.bus_data_type_uuid;
-	bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
-
-	list_add(&bus_info->entry, &bus_info_list);
-
-	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
-
-cleanup:
-	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
-		   rc, inmsg->hdr.flags.response_expected == 1);
-}
-
-static void
-bus_destroy(struct controlvm_message *inmsg)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->destroy_bus.bus_no;
-	struct visorchipset_bus_info *bus_info;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	bus_info = bus_find(&bus_info_list, bus_no);
-	if (!bus_info)
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-	else if (bus_info->state.created == 0)
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-
-	bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
-		   rc, inmsg->hdr.flags.response_expected == 1);
-}
-
-static void
-bus_configure(struct controlvm_message *inmsg,
-	      struct parser_context *parser_ctx)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no;
-	struct visorchipset_bus_info *bus_info;
-	int rc = CONTROLVM_RESP_SUCCESS;
-	char s[99];
-
-	bus_no = cmd->configure_bus.bus_no;
-	POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-
-	bus_info = bus_find(&bus_info_list, bus_no);
-	if (!bus_info) {
-		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-	} else if (bus_info->state.created == 0) {
-		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-	} else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
-		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
-	} else {
-		bus_info->partition_handle = cmd->configure_bus.guest_handle;
-		bus_info->partition_uuid = parser_id_get(parser_ctx);
-		parser_param_start(parser_ctx, PARSERSTRING_NAME);
-		bus_info->name = parser_string_get(parser_ctx);
-
-		visorchannel_uuid_id(&bus_info->partition_uuid, s);
-		POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
-				 POSTCODE_SEVERITY_INFO);
-	}
-	bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
-		   rc, inmsg->hdr.flags.response_expected == 1);
-}
-
-static void
-my_device_create(struct controlvm_message *inmsg)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->create_device.bus_no;
-	u32 dev_no = cmd->create_device.dev_no;
-	struct visorchipset_device_info *dev_info;
-	struct visorchipset_bus_info *bus_info;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
-	if (dev_info && (dev_info->state.created == 1)) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-		goto cleanup;
-	}
-	bus_info = bus_find(&bus_info_list, bus_no);
-	if (!bus_info) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-		goto cleanup;
-	}
-	if (bus_info->state.created == 0) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-		goto cleanup;
-	}
-	dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
-	if (!dev_info) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
-		goto cleanup;
-	}
-
-	INIT_LIST_HEAD(&dev_info->entry);
-	dev_info->bus_no = bus_no;
-	dev_info->dev_no = dev_no;
-	dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
-	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-
-	if (inmsg->hdr.flags.test_message == 1)
-		dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
-	else
-		dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-	dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
-	dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
-	dev_info->chan_info.channel_type_uuid =
-			cmd->create_device.data_type_uuid;
-	dev_info->chan_info.intr = cmd->create_device.intr;
-	list_add(&dev_info->entry, &dev_info_list);
-	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-cleanup:
-	/* get the bus and devNo for DiagPool channel */
-	if (dev_info &&
-	    is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
-		g_diagpool_bus_no = bus_no;
-		g_diagpool_dev_no = dev_no;
-	}
-	device_epilog(bus_no, dev_no, segment_state_running,
-		      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
-		      inmsg->hdr.flags.response_expected == 1,
-		      FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
-}
-
-static void
-my_device_changestate(struct controlvm_message *inmsg)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->device_change_state.bus_no;
-	u32 dev_no = cmd->device_change_state.dev_no;
-	struct spar_segment_state state = cmd->device_change_state.state;
-	struct visorchipset_device_info *dev_info;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
-	if (!dev_info) {
-		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
-	} else if (dev_info->state.created == 0) {
-		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
-	}
-	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
-		device_epilog(bus_no, dev_no, state,
-			      CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
-			      inmsg->hdr.flags.response_expected == 1,
-			      FOR_VISORBUS(
-					dev_info->chan_info.channel_type_uuid));
-}
-
-static void
-my_device_destroy(struct controlvm_message *inmsg)
-{
-	struct controlvm_message_packet *cmd = &inmsg->cmd;
-	u32 bus_no = cmd->destroy_device.bus_no;
-	u32 dev_no = cmd->destroy_device.dev_no;
-	struct visorchipset_device_info *dev_info;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
-	if (!dev_info)
-		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
-	else if (dev_info->state.created == 0)
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-
-	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
-		device_epilog(bus_no, dev_no, segment_state_running,
-			      CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
-			      inmsg->hdr.flags.response_expected == 1,
-			      FOR_VISORBUS(
-					dev_info->chan_info.channel_type_uuid));
-}
-
-/* When provided with the physical address of the controlvm channel
- * (phys_addr), the offset to the payload area we need to manage
- * (offset), and the size of this payload area (bytes), fills in the
- * controlvm_payload_info struct.  Returns true for success or false
- * for failure.
- */
-static int
-initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
-				  struct visor_controlvm_payload_info *info)
-{
-	u8 __iomem *payload = NULL;
-	int rc = CONTROLVM_RESP_SUCCESS;
-
-	if (!info) {
-		rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
-		goto cleanup;
-	}
-	memset(info, 0, sizeof(struct visor_controlvm_payload_info));
-	if ((offset == 0) || (bytes == 0)) {
-		rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
-		goto cleanup;
-	}
-	payload = ioremap_cache(phys_addr + offset, bytes);
-	if (!payload) {
-		rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
-		goto cleanup;
-	}
-
-	info->offset = offset;
-	info->bytes = bytes;
-	info->ptr = payload;
-
-cleanup:
-	if (rc < 0) {
-		if (payload) {
-			iounmap(payload);
-			payload = NULL;
-		}
-	}
-	return rc;
-}
-
-static void
-destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
-{
-	if (info->ptr) {
-		iounmap(info->ptr);
-		info->ptr = NULL;
-	}
-	memset(info, 0, sizeof(struct visor_controlvm_payload_info));
-}
-
-static void
-initialize_controlvm_payload(void)
-{
-	HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
-	u64 payload_offset = 0;
-	u32 payload_bytes = 0;
-
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       request_payload_offset),
-			      &payload_offset, sizeof(payload_offset)) < 0) {
-		POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       request_payload_bytes),
-			      &payload_bytes, sizeof(payload_bytes)) < 0) {
-		POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-	initialize_controlvm_payload_info(phys_addr,
-					  payload_offset, payload_bytes,
-					  &controlvm_payload_info);
-}
-
-/*  Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
- *  Returns CONTROLVM_RESP_xxx code.
- */
-int
-visorchipset_chipset_ready(void)
-{
-	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
-	return CONTROLVM_RESP_SUCCESS;
-}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
-
-int
-visorchipset_chipset_selftest(void)
-{
-	char env_selftest[20];
-	char *envp[] = { env_selftest, NULL };
-
-	sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
-	kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
-			   envp);
-	return CONTROLVM_RESP_SUCCESS;
-}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
-
-/*  Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
- *  Returns CONTROLVM_RESP_xxx code.
- */
-int
-visorchipset_chipset_notready(void)
-{
-	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
-	return CONTROLVM_RESP_SUCCESS;
-}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
-
-static void
-chipset_ready(struct controlvm_message_header *msg_hdr)
-{
-	int rc = visorchipset_chipset_ready();
-
-	if (rc != CONTROLVM_RESP_SUCCESS)
-		rc = -rc;
-	if (msg_hdr->flags.response_expected && !visorchipset_holdchipsetready)
-		controlvm_respond(msg_hdr, rc);
-	if (msg_hdr->flags.response_expected && visorchipset_holdchipsetready) {
-		/* Send CHIPSET_READY response when all modules have been loaded
-		 * and disks mounted for the partition
-		 */
-		g_chipset_msg_hdr = *msg_hdr;
-	}
-}
-
-static void
-chipset_selftest(struct controlvm_message_header *msg_hdr)
-{
-	int rc = visorchipset_chipset_selftest();
-
-	if (rc != CONTROLVM_RESP_SUCCESS)
-		rc = -rc;
-	if (msg_hdr->flags.response_expected)
-		controlvm_respond(msg_hdr, rc);
-}
-
-static void
-chipset_notready(struct controlvm_message_header *msg_hdr)
-{
-	int rc = visorchipset_chipset_notready();
-
-	if (rc != CONTROLVM_RESP_SUCCESS)
-		rc = -rc;
-	if (msg_hdr->flags.response_expected)
-		controlvm_respond(msg_hdr, rc);
-}
-
-/* This is your "one-stop" shop for grabbing the next message from the
- * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
- */
-static bool
-read_controlvm_event(struct controlvm_message *msg)
-{
-	if (visorchannel_signalremove(controlvm_channel,
-				      CONTROLVM_QUEUE_EVENT, msg)) {
-		/* got a message */
-		if (msg->hdr.flags.test_message == 1)
-			return false;
-		return true;
-	}
-	return false;
-}
-
-/*
- * The general parahotplug flow works as follows.  The visorchipset
- * driver receives a DEVICE_CHANGESTATE message from Command
- * specifying a physical device to enable or disable.  The CONTROLVM
- * message handler calls parahotplug_process_message, which then adds
- * the message to a global list and kicks off a udev event which
- * causes a user level script to enable or disable the specified
- * device.  The udev script then writes to
- * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
- * to get called, at which point the appropriate CONTROLVM message is
- * retrieved from the list and responded to.
- */
-
-#define PARAHOTPLUG_TIMEOUT_MS 2000
-
-/*
- * Generate unique int to match an outstanding CONTROLVM message with a
- * udev script /proc response
- */
-static int
-parahotplug_next_id(void)
-{
-	static atomic_t id = ATOMIC_INIT(0);
-
-	return atomic_inc_return(&id);
-}
-
-/*
- * Returns the time (in jiffies) when a CONTROLVM message on the list
- * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
- */
-static unsigned long
-parahotplug_next_expiration(void)
-{
-	return jiffies + msecs_to_jiffies(PARAHOTPLUG_TIMEOUT_MS);
-}
-
-/*
- * Create a parahotplug_request, which is basically a wrapper for a
- * CONTROLVM_MESSAGE that we can stick on a list
- */
-static struct parahotplug_request *
-parahotplug_request_create(struct controlvm_message *msg)
-{
-	struct parahotplug_request *req;
-
-	req = kmalloc(sizeof(*req), GFP_KERNEL | __GFP_NORETRY);
-	if (!req)
-		return NULL;
-
-	req->id = parahotplug_next_id();
-	req->expiration = parahotplug_next_expiration();
-	req->msg = *msg;
-
-	return req;
-}
-
-/*
- * Free a parahotplug_request.
- */
-static void
-parahotplug_request_destroy(struct parahotplug_request *req)
-{
-	kfree(req);
-}
-
-/*
- * Cause uevent to run the user level script to do the disable/enable
- * specified in (the CONTROLVM message in) the specified
- * parahotplug_request
- */
-static void
-parahotplug_request_kickoff(struct parahotplug_request *req)
-{
-	struct controlvm_message_packet *cmd = &req->msg.cmd;
-	char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
-	    env_func[40];
-	char *envp[] = {
-		env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
-	};
-
-	sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
-	sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
-	sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
-		cmd->device_change_state.state.active);
-	sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
-		cmd->device_change_state.bus_no);
-	sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
-		cmd->device_change_state.dev_no >> 3);
-	sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
-		cmd->device_change_state.dev_no & 0x7);
-
-	kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
-			   envp);
-}
-
-/*
- * Remove any request from the list that's been on there too long and
- * respond with an error.
- */
-static void
-parahotplug_process_list(void)
-{
-	struct list_head *pos;
-	struct list_head *tmp;
-
-	spin_lock(&parahotplug_request_list_lock);
-
-	list_for_each_safe(pos, tmp, &parahotplug_request_list) {
-		struct parahotplug_request *req =
-		    list_entry(pos, struct parahotplug_request, list);
-
-		if (!time_after_eq(jiffies, req->expiration))
-			continue;
-
-		list_del(pos);
-		if (req->msg.hdr.flags.response_expected)
-			controlvm_respond_physdev_changestate(
-				&req->msg.hdr,
-				CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
-				req->msg.cmd.device_change_state.state);
-		parahotplug_request_destroy(req);
-	}
-
-	spin_unlock(&parahotplug_request_list_lock);
-}
-
-/*
- * Called from the /proc handler, which means the user script has
- * finished the enable/disable.  Find the matching identifier, and
- * respond to the CONTROLVM message with success.
- */
-static int
-parahotplug_request_complete(int id, u16 active)
-{
-	struct list_head *pos;
-	struct list_head *tmp;
-
-	spin_lock(&parahotplug_request_list_lock);
-
-	/* Look for a request matching "id". */
-	list_for_each_safe(pos, tmp, &parahotplug_request_list) {
-		struct parahotplug_request *req =
-		    list_entry(pos, struct parahotplug_request, list);
-		if (req->id == id) {
-			/* Found a match.  Remove it from the list and
-			 * respond.
-			 */
-			list_del(pos);
-			spin_unlock(&parahotplug_request_list_lock);
-			req->msg.cmd.device_change_state.state.active = active;
-			if (req->msg.hdr.flags.response_expected)
-				controlvm_respond_physdev_changestate(
-					&req->msg.hdr, CONTROLVM_RESP_SUCCESS,
-					req->msg.cmd.device_change_state.state);
-			parahotplug_request_destroy(req);
-			return 0;
-		}
-	}
-
-	spin_unlock(&parahotplug_request_list_lock);
-	return -1;
-}
-
-/*
- * Enables or disables a PCI device by kicking off a udev script
- */
-static void
-parahotplug_process_message(struct controlvm_message *inmsg)
-{
-	struct parahotplug_request *req;
-
-	req = parahotplug_request_create(inmsg);
-
-	if (!req)
-		return;
-
-	if (inmsg->cmd.device_change_state.state.active) {
-		/* For enable messages, just respond with success
-		* right away.  This is a bit of a hack, but there are
-		* issues with the early enable messages we get (with
-		* either the udev script not detecting that the device
-		* is up, or not getting called at all).  Fortunately
-		* the messages that get lost don't matter anyway, as
-		* devices are automatically enabled at
-		* initialization.
-		*/
-		parahotplug_request_kickoff(req);
-		controlvm_respond_physdev_changestate(&inmsg->hdr,
-			CONTROLVM_RESP_SUCCESS,
-			inmsg->cmd.device_change_state.state);
-		parahotplug_request_destroy(req);
-	} else {
-		/* For disable messages, add the request to the
-		* request list before kicking off the udev script.  It
-		* won't get responded to until the script has
-		* indicated it's done.
-		*/
-		spin_lock(&parahotplug_request_list_lock);
-		list_add_tail(&req->list, &parahotplug_request_list);
-		spin_unlock(&parahotplug_request_list_lock);
-
-		parahotplug_request_kickoff(req);
-	}
-}
-
-/* Process a controlvm message.
- * Return result:
- *    false - this function will return FALSE only in the case where the
- *            controlvm message was NOT processed, but processing must be
- *            retried before reading the next controlvm message; a
- *            scenario where this can occur is when we need to throttle
- *            the allocation of memory in which to copy out controlvm
- *            payload data
- *    true  - processing of the controlvm message completed,
- *            either successfully or with an error.
- */
-static bool
-handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
-{
-	struct controlvm_message_packet *cmd = &inmsg.cmd;
-	u64 parm_addr;
-	u32 parm_bytes;
-	struct parser_context *parser_ctx = NULL;
-	bool local_addr;
-	struct controlvm_message ackmsg;
-
-	/* create parsing context if necessary */
-	local_addr = (inmsg.hdr.flags.test_message == 1);
-	if (channel_addr == 0)
-		return true;
-	parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
-	parm_bytes = inmsg.hdr.payload_bytes;
-
-	/* Parameter and channel addresses within test messages actually lie
-	 * within our OS-controlled memory.  We need to know that, because it
-	 * makes a difference in how we compute the virtual address.
-	 */
-	if (parm_addr && parm_bytes) {
-		bool retry = false;
-
-		parser_ctx =
-		    parser_init_byte_stream(parm_addr, parm_bytes,
-					    local_addr, &retry);
-		if (!parser_ctx && retry)
-			return false;
-	}
-
-	if (!local_addr) {
-		controlvm_init_response(&ackmsg, &inmsg.hdr,
-					CONTROLVM_RESP_SUCCESS);
-		if (controlvm_channel)
-			visorchannel_signalinsert(controlvm_channel,
-						  CONTROLVM_QUEUE_ACK,
-						  &ackmsg);
-	}
-	switch (inmsg.hdr.id) {
-	case CONTROLVM_CHIPSET_INIT:
-		chipset_init(&inmsg);
-		break;
-	case CONTROLVM_BUS_CREATE:
-		bus_create(&inmsg);
-		break;
-	case CONTROLVM_BUS_DESTROY:
-		bus_destroy(&inmsg);
-		break;
-	case CONTROLVM_BUS_CONFIGURE:
-		bus_configure(&inmsg, parser_ctx);
-		break;
-	case CONTROLVM_DEVICE_CREATE:
-		my_device_create(&inmsg);
-		break;
-	case CONTROLVM_DEVICE_CHANGESTATE:
-		if (cmd->device_change_state.flags.phys_device) {
-			parahotplug_process_message(&inmsg);
-		} else {
-			/* save the hdr and cmd structures for later use */
-			/* when sending back the response to Command */
-			my_device_changestate(&inmsg);
-			g_devicechangestate_packet = inmsg.cmd;
-			break;
-		}
-		break;
-	case CONTROLVM_DEVICE_DESTROY:
-		my_device_destroy(&inmsg);
-		break;
-	case CONTROLVM_DEVICE_CONFIGURE:
-		/* no op for now, just send a respond that we passed */
-		if (inmsg.hdr.flags.response_expected)
-			controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
-		break;
-	case CONTROLVM_CHIPSET_READY:
-		chipset_ready(&inmsg.hdr);
-		break;
-	case CONTROLVM_CHIPSET_SELFTEST:
-		chipset_selftest(&inmsg.hdr);
-		break;
-	case CONTROLVM_CHIPSET_STOP:
-		chipset_notready(&inmsg.hdr);
-		break;
-	default:
-		if (inmsg.hdr.flags.response_expected)
-			controlvm_respond(&inmsg.hdr,
-				-CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
-		break;
-	}
-
-	if (parser_ctx) {
-		parser_done(parser_ctx);
-		parser_ctx = NULL;
-	}
-	return true;
-}
-
-static HOSTADDRESS controlvm_get_channel_address(void)
-{
-	u64 addr = 0;
-	u32 size = 0;
-
-	if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size)))
-		return 0;
-
-	return addr;
-}
-
-static void
-controlvm_periodic_work(struct work_struct *work)
-{
-	struct controlvm_message inmsg;
-	bool got_command = false;
-	bool handle_command_failed = false;
-	static u64 poll_count;
-
-	/* make sure visorbus server is registered for controlvm callbacks */
-	if (visorchipset_serverregwait && !serverregistered)
-		goto cleanup;
-	/* make sure visorclientbus server is regsitered for controlvm
-	 * callbacks
-	 */
-	if (visorchipset_clientregwait && !clientregistered)
-		goto cleanup;
-
-	poll_count++;
-	if (poll_count >= 250)
-		;	/* keep going */
-	else
-		goto cleanup;
-
-	/* Check events to determine if response to CHIPSET_READY
-	 * should be sent
-	 */
-	if (visorchipset_holdchipsetready &&
-	    (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) {
-		if (check_chipset_events() == 1) {
-			controlvm_respond(&g_chipset_msg_hdr, 0);
-			clear_chipset_events();
-			memset(&g_chipset_msg_hdr, 0,
-			       sizeof(struct controlvm_message_header));
-		}
-	}
-
-	while (visorchannel_signalremove(controlvm_channel,
-					 CONTROLVM_QUEUE_RESPONSE,
-					 &inmsg))
-		;
-	if (!got_command) {
-		if (controlvm_pending_msg_valid) {
-			/* we throttled processing of a prior
-			* msg, so try to process it again
-			* rather than reading a new one
-			*/
-			inmsg = controlvm_pending_msg;
-			controlvm_pending_msg_valid = false;
-			got_command = true;
-		} else {
-			got_command = read_controlvm_event(&inmsg);
-		}
-	}
-
-	handle_command_failed = false;
-	while (got_command && (!handle_command_failed)) {
-		most_recent_message_jiffies = jiffies;
-		if (handle_command(inmsg,
-				   visorchannel_get_physaddr
-				   (controlvm_channel)))
-			got_command = read_controlvm_event(&inmsg);
-		else {
-			/* this is a scenario where throttling
-			* is required, but probably NOT an
-			* error...; we stash the current
-			* controlvm msg so we will attempt to
-			* reprocess it on our next loop
-			*/
-			handle_command_failed = true;
-			controlvm_pending_msg = inmsg;
-			controlvm_pending_msg_valid = true;
-		}
-	}
-
-	/* parahotplug_worker */
-	parahotplug_process_list();
-
-cleanup:
-
-	if (time_after(jiffies,
-		       most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
-		/* it's been longer than MIN_IDLE_SECONDS since we
-		* processed our last controlvm message; slow down the
-		* polling
-		*/
-		if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW)
-			poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
-	} else {
-		if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST)
-			poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-	}
-
-	queue_delayed_work(periodic_controlvm_workqueue,
-			   &periodic_controlvm_work, poll_jiffies);
-}
-
-static void
-setup_crash_devices_work_queue(struct work_struct *work)
-{
-	struct controlvm_message local_crash_bus_msg;
-	struct controlvm_message local_crash_dev_msg;
-	struct controlvm_message msg;
-	u32 local_crash_msg_offset;
-	u16 local_crash_msg_count;
-
-	/* make sure visorbus server is registered for controlvm callbacks */
-	if (visorchipset_serverregwait && !serverregistered)
-		goto cleanup;
-
-	/* make sure visorclientbus server is regsitered for controlvm
-	 * callbacks
-	 */
-	if (visorchipset_clientregwait && !clientregistered)
-		goto cleanup;
-
-	POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
-	/* send init chipset msg */
-	msg.hdr.id = CONTROLVM_CHIPSET_INIT;
-	msg.cmd.init_chipset.bus_count = 23;
-	msg.cmd.init_chipset.switch_count = 0;
-
-	chipset_init(&msg);
-
-	/* get saved message count */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_count),
-			      &local_crash_msg_count, sizeof(u16)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
-		POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
-				 local_crash_msg_count,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* get saved crash message offset */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_offset),
-			      &local_crash_msg_offset, sizeof(u32)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* read create device message for storage bus offset */
-	if (visorchannel_read(controlvm_channel,
-			      local_crash_msg_offset,
-			      &local_crash_bus_msg,
-			      sizeof(struct controlvm_message)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* read create device message for storage device */
-	if (visorchannel_read(controlvm_channel,
-			      local_crash_msg_offset +
-			      sizeof(struct controlvm_message),
-			      &local_crash_dev_msg,
-			      sizeof(struct controlvm_message)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* reuse IOVM create bus message */
-	if (local_crash_bus_msg.cmd.create_bus.channel_addr) {
-		bus_create(&local_crash_bus_msg);
-	} else {
-		POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* reuse create device message for storage device */
-	if (local_crash_dev_msg.cmd.create_device.channel_addr) {
-		my_device_create(&local_crash_dev_msg);
-	} else {
-		POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-	POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO);
-	return;
-
-cleanup:
-
-	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
-
-	queue_delayed_work(periodic_controlvm_workqueue,
-			   &periodic_controlvm_work, poll_jiffies);
-}
-
-static void
-bus_create_response(u32 bus_no, int response)
-{
-	bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
-}
-
-static void
-bus_destroy_response(u32 bus_no, int response)
-{
-	bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
-}
-
-static void
-device_create_response(u32 bus_no, u32 dev_no, int response)
-{
-	device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
-}
-
-static void
-device_destroy_response(u32 bus_no, u32 dev_no, int response)
-{
-	device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
-}
-
-void
-visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
-{
-	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
-				     segment_state_standby);
-}
-EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
-
-static void
-device_resume_response(u32 bus_no, u32 dev_no, int response)
-{
-	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
-				     segment_state_running);
-}
-
-bool
-visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
-{
-	void *p = bus_find(&bus_info_list, bus_no);
-
-	if (!p)
-		return false;
-	memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
-
-bool
-visorchipset_set_bus_context(u32 bus_no, void *context)
-{
-	struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
-
-	if (!p)
-		return false;
-	p->bus_driver_context = context;
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
-
-bool
-visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-			     struct visorchipset_device_info *dev_info)
-{
-	void *p = device_find(&dev_info_list, bus_no, dev_no);
-
-	if (!p)
-		return false;
-	memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
-
-bool
-visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
-{
-	struct visorchipset_device_info *p;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-
-	if (!p)
-		return false;
-	p->bus_driver_context = context;
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
-
-/* Generic wrapper function for allocating memory from a kmem_cache pool.
- */
-void *
-visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block,
-			 char *fn, int ln)
-{
-	gfp_t gfp;
-	void *p;
-
-	if (ok_to_block)
-		gfp = GFP_KERNEL;
-	else
-		gfp = GFP_ATOMIC;
-	/* __GFP_NORETRY means "ok to fail", meaning
-	 * kmem_cache_alloc() can return NULL, implying the caller CAN
-	 * cope with failure.  If you do NOT specify __GFP_NORETRY,
-	 * Linux will go to extreme measures to get memory for you
-	 * (like, invoke oom killer), which will probably cripple the
-	 * system.
-	 */
-	gfp |= __GFP_NORETRY;
-	p = kmem_cache_alloc(pool, gfp);
-	if (!p)
-		return NULL;
-
-	return p;
-}
-
-/* Generic wrapper function for freeing memory from a kmem_cache pool.
- */
-void
-visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
-{
-	if (!p)
-		return;
-
-	kmem_cache_free(pool, p);
-}
-
-static ssize_t chipsetready_store(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf, size_t count)
-{
-	char msgtype[64];
-
-	if (sscanf(buf, "%63s", msgtype) != 1)
-		return -EINVAL;
-
-	if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) {
-		chipset_events[0] = 1;
-		return count;
-	} else if (!strcmp(msgtype, "MODULES_LOADED")) {
-		chipset_events[1] = 1;
-		return count;
-	}
-	return -EINVAL;
-}
-
-/* The parahotplug/devicedisabled interface gets called by our support script
- * when an SR-IOV device has been shut down. The ID is passed to the script
- * and then passed back when the device has been removed.
- */
-static ssize_t devicedisabled_store(struct device *dev,
-				    struct device_attribute *attr,
-				    const char *buf, size_t count)
-{
-	unsigned int id;
-
-	if (kstrtouint(buf, 10, &id))
-		return -EINVAL;
-
-	parahotplug_request_complete(id, 0);
-	return count;
-}
-
-/* The parahotplug/deviceenabled interface gets called by our support script
- * when an SR-IOV device has been recovered. The ID is passed to the script
- * and then passed back when the device has been brought back up.
- */
-static ssize_t deviceenabled_store(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf, size_t count)
-{
-	unsigned int id;
-
-	if (kstrtouint(buf, 10, &id))
-		return -EINVAL;
-
-	parahotplug_request_complete(id, 1);
-	return count;
-}
-
-static int
-visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	unsigned long physaddr = 0;
-	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
-	GUEST_PHYSICAL_ADDRESS addr = 0;
-
-	/* sv_enable_dfp(); */
-	if (offset & (PAGE_SIZE - 1))
-		return -ENXIO;	/* need aligned offsets */
-
-	switch (offset) {
-	case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
-		vma->vm_flags |= VM_IO;
-		if (!*file_controlvm_channel)
-			return -ENXIO;
-
-		visorchannel_read(*file_controlvm_channel,
-			offsetof(struct spar_controlvm_channel_protocol,
-				 gp_control_channel),
-			&addr, sizeof(addr));
-		if (!addr)
-			return -ENXIO;
-
-		physaddr = (unsigned long)addr;
-		if (remap_pfn_range(vma, vma->vm_start,
-				    physaddr >> PAGE_SHIFT,
-				    vma->vm_end - vma->vm_start,
-				    /*pgprot_noncached */
-				    (vma->vm_page_prot))) {
-			return -EAGAIN;
-		}
-		break;
-	default:
-		return -ENXIO;
-	}
-	return 0;
-}
-
-static long visorchipset_ioctl(struct file *file, unsigned int cmd,
-			       unsigned long arg)
-{
-	s64 adjustment;
-	s64 vrtc_offset;
-
-	switch (cmd) {
-	case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
-		/* get the physical rtc offset */
-		vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
-		if (copy_to_user((void __user *)arg, &vrtc_offset,
-				 sizeof(vrtc_offset))) {
-			return -EFAULT;
-		}
-		return SUCCESS;
-	case VMCALL_UPDATE_PHYSICAL_TIME:
-		if (copy_from_user(&adjustment, (void __user *)arg,
-				   sizeof(adjustment))) {
-			return -EFAULT;
-		}
-		return issue_vmcall_update_physical_time(adjustment);
-	default:
-		return -EFAULT;
-	}
-}
-
-static const struct file_operations visorchipset_fops = {
-	.owner = THIS_MODULE,
-	.open = visorchipset_open,
-	.read = NULL,
-	.write = NULL,
-	.unlocked_ioctl = visorchipset_ioctl,
-	.release = visorchipset_release,
-	.mmap = visorchipset_mmap,
-};
-
-int
-visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
-{
-	int rc = 0;
-
-	file_controlvm_channel = controlvm_channel;
-	cdev_init(&file_cdev, &visorchipset_fops);
-	file_cdev.owner = THIS_MODULE;
-	if (MAJOR(major_dev) == 0) {
-		rc = alloc_chrdev_region(&major_dev, 0, 1, "visorchipset");
-		/* dynamic major device number registration required */
-		if (rc < 0)
-			return rc;
-	} else {
-		/* static major device number registration required */
-		rc = register_chrdev_region(major_dev, 1, "visorchipset");
-		if (rc < 0)
-			return rc;
-	}
-	rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
-	if (rc < 0) {
-		unregister_chrdev_region(major_dev, 1);
-		return rc;
-	}
-	return 0;
-}
-
-
-
-static int __init
-visorchipset_init(void)
-{
-	int rc = 0, x = 0;
-	HOSTADDRESS addr;
-
-	if (!unisys_spar_platform)
-		return -ENODEV;
-
-	memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers));
-	memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers));
-	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
-	memset(&livedump_info, 0, sizeof(livedump_info));
-	atomic_set(&livedump_info.buffers_in_use, 0);
-
-	if (visorchipset_testvnic) {
-		POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
-		rc = x;
-		goto cleanup;
-	}
-
-	addr = controlvm_get_channel_address();
-	if (addr) {
-		controlvm_channel =
-		    visorchannel_create_with_lock
-		    (addr,
-		     sizeof(struct spar_controlvm_channel_protocol),
-		     spar_controlvm_channel_protocol_uuid);
-		if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
-				visorchannel_get_header(controlvm_channel))) {
-			initialize_controlvm_payload();
-		} else {
-			visorchannel_destroy(controlvm_channel);
-			controlvm_channel = NULL;
-			return -ENODEV;
-		}
-	} else {
-		return -ENODEV;
-	}
-
-	major_dev = MKDEV(visorchipset_major, 0);
-	rc = visorchipset_file_init(major_dev, &controlvm_channel);
-	if (rc < 0) {
-		POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
-		goto cleanup;
-	}
-
-	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
-	if (!visorchipset_disable_controlvm) {
-		/* if booting in a crash kernel */
-		if (is_kdump_kernel())
-			INIT_DELAYED_WORK(&periodic_controlvm_work,
-					  setup_crash_devices_work_queue);
-		else
-			INIT_DELAYED_WORK(&periodic_controlvm_work,
-					  controlvm_periodic_work);
-		periodic_controlvm_workqueue =
-		    create_singlethread_workqueue("visorchipset_controlvm");
-
-		if (!periodic_controlvm_workqueue) {
-			POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
-					 DIAG_SEVERITY_ERR);
-			rc = -ENOMEM;
-			goto cleanup;
-		}
-		most_recent_message_jiffies = jiffies;
-		poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-		rc = queue_delayed_work(periodic_controlvm_workqueue,
-					&periodic_controlvm_work, poll_jiffies);
-		if (rc < 0) {
-			POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
-					 DIAG_SEVERITY_ERR);
-			goto cleanup;
-		}
-	}
-
-	visorchipset_platform_device.dev.devt = major_dev;
-	if (platform_device_register(&visorchipset_platform_device) < 0) {
-		POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
-		rc = -1;
-		goto cleanup;
-	}
-	POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
-	rc = 0;
-cleanup:
-	if (rc) {
-		POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
-				 POSTCODE_SEVERITY_ERR);
-	}
-	return rc;
-}
-
-void
-visorchipset_file_cleanup(dev_t major_dev)
-{
-	if (file_cdev.ops)
-		cdev_del(&file_cdev);
-	file_cdev.ops = NULL;
-	unregister_chrdev_region(major_dev, 1);
-}
-
-static void
-visorchipset_exit(void)
-{
-	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
-
-	if (visorchipset_disable_controlvm) {
-		;
-	} else {
-		cancel_delayed_work(&periodic_controlvm_work);
-		flush_workqueue(periodic_controlvm_workqueue);
-		destroy_workqueue(periodic_controlvm_workqueue);
-		periodic_controlvm_workqueue = NULL;
-		destroy_controlvm_payload_info(&controlvm_payload_info);
-	}
-
-	cleanup_controlvm_structures();
-
-	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
-	visorchannel_destroy(controlvm_channel);
-
-	visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
-	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
-}
-
-module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
-module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
-module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testmsg,
-		 "1 to manufacture the chipset, bus, and switch messages");
-module_param_named(major, visorchipset_major, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_major,
-		 "major device number to use for the device node");
-module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_serverreqwait,
-		 "1 to have the module wait for the visor bus to register");
-module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
-module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testteardown,
-		 "1 to test teardown of the chipset, bus, and switch");
-module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
-		   S_IRUGO);
-MODULE_PARM_DESC(visorchipset_disable_controlvm,
-		 "1 to disable polling of controlVm channel");
-module_param_named(holdchipsetready, visorchipset_holdchipsetready,
-		   int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_holdchipsetready,
-		 "1 to hold response to CHIPSET_READY");
-
-module_init(visorchipset_init);
-module_exit(visorchipset_exit);
-
-MODULE_AUTHOR("Unisys");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
-		   VERSION);
-MODULE_VERSION(VERSION);
-- 
2.1.4


_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 039/141] staging: unisys: cleanup visorbus_private.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (37 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 038/141] staging: unisys: move visorchipset files to visorbus Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts() Benjamin Romer
                   ` (104 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

visorbus_private.h contains code that is called from visorbus into the
visorchipset code.  Now that the visorchipset code has been brought into
the visorbus directory, many of the declarations are not necessary and
can be cleaned up.

TODO: PARSER_WHICH_STRING enum only has one member used
(PARSERSTRING_NAME).

TODO: crash_obj_type appears to be unnecessary in the overall scheme of
code.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_private.h | 57 ----------------------
 drivers/staging/unisys/visorbus/visorchipset.c     | 35 ++++++++++++-
 2 files changed, 33 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 68d770f..a3d78f6 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -26,32 +26,7 @@
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
-#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
-
-/** Describes the state from the perspective of which controlvm messages have
- *  been received for a bus or device.
- */
-
-enum PARSER_WHICH_STRING {
-	PARSERSTRING_INITIATOR,
-	PARSERSTRING_TARGET,
-	PARSERSTRING_CONNECTION,
-	PARSERSTRING_NAME,
-};
-
 struct visorchannel;
-struct parser_context *parser_init(u64 addr, u32 bytes, bool isLocal,
-				   bool *tryAgain);
-struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool local,
-				       bool *retry);
-void parser_param_start(struct parser_context *ctx,
-			PARSER_WHICH_STRING which_string);
-void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
-void *parser_string_get(struct parser_context *ctx);
-uuid_le parser_id_get(struct parser_context *ctx);
-char *parser_simpleString_get(struct parser_context *ctx);
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes);
-void parser_done(struct parser_context *ctx);
 
 struct visorchipset_state {
 	u32 created:1;
@@ -75,11 +50,6 @@ enum visorchipset_addresstype {
 	ADDRTYPE_LOCALTEST,
 };
 
-enum crash_obj_type {
-	CRASH_DEV,
-	CRASH_BUS,
-};
-
 /** Attributes for a particular Supervisor channel.
  */
 struct visorchipset_channel_info {
@@ -169,18 +139,6 @@ struct visorchipset_busdev_responders {
 
 /** Register functions (in the bus driver) to get called by visorchipset
  *  whenever a bus or device appears for which this service partition is
- *  to be the server for.  visorchipset will fill in <responders>, to
- *  indicate functions the bus driver should call to indicate message
- *  responses.
- */
-void
-visorchipset_register_busdev_client(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info);
-
-/** Register functions (in the bus driver) to get called by visorchipset
- *  whenever a bus or device appears for which this service partition is
  *  to be the client for.  visorchipset will fill in <responders>, to
  *  indicate functions the bus driver should call to indicate message
  *  responses.
@@ -191,26 +149,11 @@ visorchipset_register_busdev_server(
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info);
 
-void visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response);
-
 bool visorchipset_get_bus_info(u32 bus_no,
 			       struct visorchipset_bus_info *bus_info);
 bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
 				  struct visorchipset_device_info *dev_info);
 bool visorchipset_set_bus_context(u32 bus_no, void *context);
-bool visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context);
-int visorchipset_chipset_ready(void);
-int visorchipset_chipset_selftest(void);
-int visorchipset_chipset_notready(void);
-void visorchipset_save_message(struct controlvm_message *msg,
-			       enum crash_obj_type type);
-void *visorchipset_cache_alloc(struct kmem_cache *pool,
-			       bool ok_to_block, char *fn, int ln);
-void visorchipset_cache_free(struct kmem_cache *pool, void *p,
-			     char *fn, int ln);
-int visorchipset_file_init(dev_t majorDev,
-			   struct visorchannel **pControlVm_channel);
-void visorchipset_file_cleanup(dev_t major_dev);
 
 /* visorbus init and exit functions */
 int __init visorbus_init(void);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index f3a2145..5bf8266 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -49,6 +49,9 @@
 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
 
 #define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
+
+#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
+
 /*
  * Module parameters
  */
@@ -261,6 +264,9 @@ static void device_create_response(u32 bus_no, u32 dev_no, int response);
 static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
 static void device_resume_response(u32 bus_no, u32 dev_no, int response);
 
+static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no,
+					       int response);
+
 static struct visorchipset_busdev_responders busdev_responders = {
 	.bus_create = bus_create_response,
 	.bus_destroy = bus_destroy_response,
@@ -382,6 +388,8 @@ static void controlvm_respond_physdev_changestate(
 		struct spar_segment_state state);
 
 
+static void parser_done(struct parser_context *ctx);
+
 static struct parser_context *
 parser_init_guts(u64 addr, u32 bytes, bool local,
 		 bool standard_payload_header, bool *retry)
@@ -527,8 +535,20 @@ parser_id_get(struct parser_context *ctx)
 	return phdr->id;
 }
 
+/** Describes the state from the perspective of which controlvm messages have
+ *  been received for a bus or device.
+ */
+
+enum PARSER_WHICH_STRING {
+	PARSERSTRING_INITIATOR,
+	PARSERSTRING_TARGET,
+	PARSERSTRING_CONNECTION,
+	PARSERSTRING_NAME, /* TODO: only PARSERSTRING_NAME is used ? */
+};
+
 void
-parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
+parser_param_start(struct parser_context *ctx,
+		   enum PARSER_WHICH_STRING which_string)
 {
 	struct spar_controlvm_parameters_header *phdr = NULL;
 
@@ -1032,6 +1052,12 @@ visorchipset_register_busdev_server(
 }
 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
 
+/** Register functions (in the bus driver) to get called by visorchipset
+ *  whenever a bus or device appears for which this service partition is
+ *  to be the server for.  visorchipset will fill in <responders>, to
+ *  indicate functions the bus driver should call to indicate message
+ *  responses.
+ */
 void
 visorchipset_register_busdev_client(
 			struct visorchipset_busdev_notifiers *notifiers,
@@ -1175,6 +1201,11 @@ static void controlvm_respond_physdev_changestate(
 	}
 }
 
+enum crash_obj_type {
+	CRASH_DEV,
+	CRASH_BUS,
+};
+
 void
 visorchipset_save_message(struct controlvm_message *msg,
 			  enum crash_obj_type type)
@@ -1218,7 +1249,7 @@ visorchipset_save_message(struct controlvm_message *msg,
 					 POSTCODE_SEVERITY_ERR);
 			return;
 		}
-	} else {
+	} else { /* CRASH_DEV */
 		if (visorchannel_write(controlvm_channel,
 				       crash_msg_offset +
 				       sizeof(struct controlvm_message), msg,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (38 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 039/141] staging: unisys: cleanup visorbus_private.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-06 12:15   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 041/141] staging: unisys: visorchannel some general function cleanups Benjamin Romer
                   ` (103 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

The error handling in this function was broken and while looking at that
I noticed that the whole function was in need of cleanup.  This patch
fixes the error handling, specifically

                if (!p) {
                        visorchannel_destroy(p);
                        channel = NULL;
                }

and does a lot of cleanup.  I also verified that the called functions
returned correct errors, and that led to a change in
visor_memregion_resize(), visorchannel_destroy() and
visor_memregion_destroy().

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c     | 79 ++++++++++------------
 .../staging/unisys/visorutil/memregion_direct.c    |  4 +-
 2 files changed, 36 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 33a4360..ff14a0d 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -55,60 +55,52 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 			 struct visorchannel *parent, ulong off, uuid_le guid,
 			 BOOL needs_lock)
 {
-	struct visorchannel *p = NULL;
-	void *rc = NULL;
+	struct visorchannel *channel;
+	int err;
+	size_t size = sizeof(struct channel_header);
+	struct memregion *memregion;
 
-	p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
-	if (!p) {
-		rc = NULL;
+	channel = kmalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY);
+	if (!channel)
 		goto cleanup;
-	}
-	p->memregion = NULL;
-	p->needs_lock = needs_lock;
-	spin_lock_init(&p->insert_lock);
-	spin_lock_init(&p->remove_lock);
+
+	channel->memregion = NULL;
+	channel->needs_lock = needs_lock;
+	spin_lock_init(&channel->insert_lock);
+	spin_lock_init(&channel->remove_lock);
 
 	/* prepare chan_hdr (abstraction to read/write channel memory) */
 	if (!parent)
-		p->memregion =
-		    visor_memregion_create(physaddr,
-					   sizeof(struct channel_header));
+		memregion = visor_memregion_create(physaddr, size);
 	else
-		p->memregion =
-		    visor_memregion_create_overlapped(parent->memregion,
-				off, sizeof(struct channel_header));
-	if (!p->memregion) {
-		rc = NULL;
+		memregion = visor_memregion_create_overlapped(parent->memregion,
+							      off, size);
+	if (!memregion)
 		goto cleanup;
-	}
-	if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
-				 sizeof(struct channel_header)) < 0) {
-		rc = NULL;
+	channel->memregion = memregion;
+
+	err = visor_memregion_read(channel->memregion, 0, &channel->chan_hdr,
+				   sizeof(struct channel_header));
+	if (err)
 		goto cleanup;
-	}
+
+	/* we had better be a CLIENT of this channel */
 	if (channel_bytes == 0)
-		/* we had better be a CLIENT of this channel */
-		channel_bytes = (ulong)p->chan_hdr.size;
+		channel_bytes = (ulong)channel->chan_hdr.size;
 	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
-		/* we had better be a CLIENT of this channel */
-		guid = p->chan_hdr.chtype;
-	if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
-		rc = NULL;
+		guid = channel->chan_hdr.chtype;
+
+	err = visor_memregion_resize(channel->memregion, channel_bytes);
+	if (err)
 		goto cleanup;
-	}
-	p->size = channel_bytes;
-	p->guid = guid;
 
-	rc = p;
-cleanup:
+	channel->size = channel_bytes;
+	channel->guid = guid;
+	return channel;
 
-	if (!rc) {
-		if (!p) {
-			visorchannel_destroy(p);
-			p = NULL;
-		}
-	}
-	return rc;
+cleanup:
+	visorchannel_destroy(channel);
+	return NULL;
 }
 
 struct visorchannel *
@@ -153,10 +145,7 @@ visorchannel_destroy(struct visorchannel *channel)
 {
 	if (!channel)
 		return;
-	if (channel->memregion) {
-		visor_memregion_destroy(channel->memregion);
-		channel->memregion = NULL;
-	}
+	visor_memregion_destroy(channel->memregion);
 	kfree(channel);
 }
 EXPORT_SYMBOL_GPL(visorchannel_destroy);
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index eb7422f..6bb439d 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -156,7 +156,7 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize)
 		unmapit(memregion);
 		memregion->nbytes = newsize;
 		if (!mapit(memregion))
-			return -1;
+			return -EIO;
 	}
 	return 0;
 }
@@ -197,7 +197,7 @@ EXPORT_SYMBOL_GPL(visor_memregion_write);
 void
 visor_memregion_destroy(struct memregion *memregion)
 {
-	if (memregion == NULL)
+	if (!memregion)
 		return;
 	if (!memregion->overlapped)
 		unmapit(memregion);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 041/141] staging: unisys: visorchannel some general function cleanups
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (39 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-06 12:56   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 042/141] staging: unisys: fix sig_read_data and sig_read_data functions Benjamin Romer
                   ` (102 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

Just some cleanups for visorchannel.c, and removal of
safe_sig_queue_validate() which is dead code.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 110 +++++++++----------------
 1 file changed, 41 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index ff14a0d..30bedcc 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -211,13 +211,12 @@ int
 visorchannel_read(struct visorchannel *channel, ulong offset,
 		  void *local, ulong nbytes)
 {
-	int rc = visor_memregion_read(channel->memregion, offset,
-				      local, nbytes);
-	if ((rc >= 0) && (offset == 0) &&
-	    (nbytes >= sizeof(struct channel_header))) {
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
-	}
+	int rc;
+	size_t size = sizeof(struct channel_header);
+
+	rc = visor_memregion_read(channel->memregion, offset, local, nbytes);
+	if (rc && !offset && (nbytes >= size))
+		memcpy(&channel->chan_hdr, local, size);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(visorchannel_read);
@@ -226,9 +225,10 @@ int
 visorchannel_write(struct visorchannel *channel, ulong offset,
 		   void *local, ulong nbytes)
 {
-	if (offset == 0 && nbytes >= sizeof(struct channel_header))
-		memcpy(&channel->chan_hdr, local,
-		       sizeof(struct channel_header));
+	size_t size = sizeof(struct channel_header);
+
+	if (!offset && nbytes >= size)
+		memcpy(&channel->chan_hdr, local, size);
 	return visor_memregion_write(channel->memregion, offset, local, nbytes);
 }
 EXPORT_SYMBOL_GPL(visorchannel_write);
@@ -237,38 +237,34 @@ int
 visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 		   ulong nbytes)
 {
-	int rc = -1;
+	int err;
 	int bufsize = 65536;
 	int written = 0;
-	u8 *buf = vmalloc(bufsize);
+	u8 *buf;
 
+	buf = vmalloc(bufsize);
 	if (!buf)
-		goto cleanup;
+		return -ENOMEM;
 
 	memset(buf, ch, bufsize);
 	while (nbytes > 0) {
 		ulong thisbytes = bufsize;
-		int x = -1;
 
 		if (nbytes < thisbytes)
 			thisbytes = nbytes;
-		x = visor_memregion_write(channel->memregion, offset + written,
-					  buf, thisbytes);
-		if (x < 0) {
-			rc = x;
+		err = visor_memregion_write(channel->memregion,
+					    offset + written, buf, thisbytes);
+		if (err)
 			goto cleanup;
-		}
+
 		written += thisbytes;
 		nbytes -= thisbytes;
 	}
-	rc = 0;
+	return 0;
 
 cleanup:
-	if (buf) {
-		vfree(buf);
-		buf = NULL;
-	}
-	return rc;
+	vfree(buf);
+	return err;
 }
 EXPORT_SYMBOL_GPL(visorchannel_clear);
 
@@ -307,22 +303,19 @@ static BOOL
 sig_read_header(struct visorchannel *channel, u32 queue,
 		struct signal_queue_header *sig_hdr)
 {
-	BOOL rc = FALSE;
+	int err;
 
 	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
-		goto cleanup;
+		return FALSE;
 
 	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
+	err = visor_memregion_read(channel->memregion,
+				   SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+				   sig_hdr, sizeof(struct signal_queue_header));
+	if (err)
+		return FALSE;
 
-	if (visor_memregion_read(channel->memregion,
-				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
-				 sig_hdr,
-				 sizeof(struct signal_queue_header)) < 0) {
-		goto cleanup;
-	}
-	rc = TRUE;
-cleanup:
-	return rc;
+	return TRUE;
 }
 
 static BOOL
@@ -330,24 +323,23 @@ sig_do_data(struct visorchannel *channel, u32 queue,
 	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
 	    BOOL is_write)
 {
-	BOOL rc = FALSE;
+	int err;
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 	if (is_write) {
-		if (visor_memregion_write(channel->memregion,
-					  signal_data_offset,
-					  data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
+		err = visor_memregion_write(channel->memregion,
+					    signal_data_offset,
+					    data, sig_hdr->signal_size);
+		if (err)
+			return FALSE;
 	} else {
-		if (visor_memregion_read(channel->memregion, signal_data_offset,
-					 data, sig_hdr->signal_size) < 0) {
-			goto cleanup;
-		}
+		err = visor_memregion_read(channel->memregion,
+					   signal_data_offset,
+					   data, sig_hdr->signal_size);
+		if (err)
+			return FALSE;
 	}
-	rc = TRUE;
-cleanup:
-	return rc;
+	return TRUE;
 }
 
 static inline BOOL
@@ -364,26 +356,6 @@ sig_write_data(struct visorchannel *channel, u32 queue,
 	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
 }
 
-static inline unsigned char
-safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
-			struct signal_queue_header *punsafe_sqh,
-			u32 *phead, u32 *ptail)
-{
-	if ((*phead >= psafe_sqh->max_slots) ||
-	    (*ptail >= psafe_sqh->max_slots)) {
-		/* Choose 0 or max, maybe based on current tail value */
-		*phead = 0;
-		*ptail = 0;
-
-		/* Sync with client as necessary */
-		punsafe_sqh->head = *phead;
-		punsafe_sqh->tail = *ptail;
-
-		return 0;
-	}
-	return 1;
-}				/* end safe_sig_queue_validate */
-
 static BOOL
 signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 042/141] staging: unisys: fix sig_read_data and sig_read_data functions
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (40 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 041/141] staging: unisys: visorchannel some general function cleanups Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 043/141] staging: unisys: visorchannel: visorchannel_create_overlap() is never used Benjamin Romer
                   ` (101 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

The sig_read_data() and sig_write_data() functions are involved in 2 steps
of calls.  They really don't need to be and this makes for much simpler
code.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 46 ++++++++++++--------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 30bedcc..d7ddc3a 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -318,42 +318,38 @@ sig_read_header(struct visorchannel *channel, u32 queue,
 	return TRUE;
 }
 
-static BOOL
-sig_do_data(struct visorchannel *channel, u32 queue,
-	    struct signal_queue_header *sig_hdr, u32 slot, void *data,
-	    BOOL is_write)
+static inline BOOL
+sig_read_data(struct visorchannel *channel, u32 queue,
+	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
 	int err;
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
-	if (is_write) {
-		err = visor_memregion_write(channel->memregion,
-					    signal_data_offset,
-					    data, sig_hdr->signal_size);
-		if (err)
-			return FALSE;
-	} else {
-		err = visor_memregion_read(channel->memregion,
-					   signal_data_offset,
-					   data, sig_hdr->signal_size);
-		if (err)
-			return FALSE;
-	}
-	return TRUE;
-}
 
-static inline BOOL
-sig_read_data(struct visorchannel *channel, u32 queue,
-	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
-	return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
+	err = visor_memregion_read(channel->memregion,
+				   signal_data_offset,
+				   data, sig_hdr->signal_size);
+	if (err)
+		return FALSE;
+
+	return TRUE;
 }
 
 static inline BOOL
 sig_write_data(struct visorchannel *channel, u32 queue,
 	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
-	return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
+	int err;
+	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+						 sig_hdr, slot);
+
+	err = visor_memregion_write(channel->memregion,
+				    signal_data_offset,
+				    data, sig_hdr->signal_size);
+	if (err)
+		return FALSE;
+
+	return TRUE;
 }
 
 static BOOL
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 043/141] staging: unisys: visorchannel: visorchannel_create_overlap() is never used
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (41 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 042/141] staging: unisys: fix sig_read_data and sig_read_data functions Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 044/141] staging: unisys: visorbus: visorchannel_create_guts() always has parent == NULL Benjamin Romer
                   ` (100 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      |  9 +--------
 drivers/staging/unisys/visorbus/visorchannel.c | 20 --------------------
 2 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 3956a3d..21fd785 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -167,22 +167,15 @@ void visorbus_enable_channel_interrupts(struct visor_device *dev);
 void visorbus_disable_channel_interrupts(struct visor_device *dev);
 #endif
 
-/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
+/* Note that for visorchannel_create()
  * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
  * In this case, the values can simply be read from the channel header.
  */
 struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
 					 ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
-						    struct visorchannel *parent,
-						    ulong off, uuid_le guid);
 struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
 						   ulong channel_bytes,
 						   uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped_with_lock(
-				ulong channel_bytes,
-				struct visorchannel *parent,
-				ulong off, uuid_le guid);
 void visorchannel_destroy(struct visorchannel *channel);
 int visorchannel_read(struct visorchannel *channel, ulong offset,
 		      void *local, ulong nbytes);
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index d7ddc3a..407c2b6 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -120,26 +120,6 @@ visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
 }
 EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
 
-struct visorchannel *
-visorchannel_create_overlapped(ulong channel_bytes,
-			       struct visorchannel *parent, ulong off,
-			       uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
-
-struct visorchannel *
-visorchannel_create_overlapped_with_lock(ulong channel_bytes,
-					 struct visorchannel *parent, ulong off,
-					 uuid_le guid)
-{
-	return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
-					TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
-
 void
 visorchannel_destroy(struct visorchannel *channel)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 044/141] staging: unisys: visorbus: visorchannel_create_guts() always has parent == NULL
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (42 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 043/141] staging: unisys: visorchannel: visorchannel_create_overlap() is never used Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 045/141] staging: unisys: memregion: Nothing uses overlap allocations, so nuke it Benjamin Romer
                   ` (99 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 407c2b6..faafa79 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -52,8 +52,7 @@ struct visorchannel {
  */
 static struct visorchannel *
 visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
-			 struct visorchannel *parent, ulong off, uuid_le guid,
-			 BOOL needs_lock)
+			 ulong off, uuid_le guid, BOOL needs_lock)
 {
 	struct visorchannel *channel;
 	int err;
@@ -70,11 +69,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	spin_lock_init(&channel->remove_lock);
 
 	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	if (!parent)
-		memregion = visor_memregion_create(physaddr, size);
-	else
-		memregion = visor_memregion_create_overlapped(parent->memregion,
-							      off, size);
+	memregion = visor_memregion_create(physaddr, size);
+
 	if (!memregion)
 		goto cleanup;
 	channel->memregion = memregion;
@@ -106,7 +102,7 @@ cleanup:
 struct visorchannel *
 visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
 {
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
 					FALSE);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create);
@@ -115,7 +111,7 @@ struct visorchannel *
 visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
 			      uuid_le guid)
 {
-	return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
+	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
 					TRUE);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 045/141] staging: unisys: memregion: Nothing uses overlap allocations, so nuke it
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (43 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 044/141] staging: unisys: visorbus: visorchannel_create_guts() always has parent == NULL Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 046/141] staging: unisys: memregion: Use proper errno for mapit() Benjamin Romer
                   ` (98 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorutil/memregion.h       |  2 -
 .../staging/unisys/visorutil/memregion_direct.c    | 52 +++-------------------
 2 files changed, 7 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 0c3eebc..1eb3a67 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -26,8 +26,6 @@
 struct memregion;
 
 struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes);
-struct memregion *visor_memregion_create_overlapped(struct memregion *parent,
-						    ulong offset, ulong nbytes);
 int visor_memregion_resize(struct memregion *memregion, ulong newsize);
 int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 6bb439d..93c10b4 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -30,7 +30,6 @@ struct memregion {
 	ulong nbytes;
 	void __iomem *mapped;
 	BOOL requested;
-	BOOL overlapped;
 };
 
 static BOOL mapit(struct memregion *memregion);
@@ -48,7 +47,6 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
 
 	memregion->physaddr = physaddr;
 	memregion->nbytes = nbytes;
-	memregion->overlapped = FALSE;
 	if (!mapit(memregion)) {
 		rc = NULL;
 		goto cleanup;
@@ -63,35 +61,6 @@ cleanup:
 }
 EXPORT_SYMBOL_GPL(visor_memregion_create);
 
-struct memregion *
-visor_memregion_create_overlapped(struct memregion *parent, ulong offset,
-				  ulong nbytes)
-{
-	struct memregion *memregion = NULL;
-
-	if (parent == NULL)
-		return NULL;
-
-	if (parent->mapped == NULL)
-		return NULL;
-
-	if ((offset >= parent->nbytes) ||
-	    ((offset + nbytes) >= parent->nbytes))
-		return NULL;
-
-	memregion = kzalloc(sizeof(*memregion), GFP_KERNEL|__GFP_NORETRY);
-	if (memregion == NULL)
-		return NULL;
-
-	memregion->physaddr = parent->physaddr + offset;
-	memregion->nbytes = nbytes;
-	memregion->mapped = ((u8 __iomem *)(parent->mapped)) + offset;
-	memregion->requested = FALSE;
-	memregion->overlapped = TRUE;
-	return memregion;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped);
-
 static BOOL
 mapit(struct memregion *memregion)
 {
@@ -147,17 +116,12 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize)
 {
 	if (newsize == memregion->nbytes)
 		return 0;
-	if (memregion->overlapped)
-		/* no error check here - we no longer know the
-		 * parent's range!
-		 */
-		memregion->nbytes = newsize;
-	else {
-		unmapit(memregion);
-		memregion->nbytes = newsize;
-		if (!mapit(memregion))
-			return -EIO;
-	}
+
+	unmapit(memregion);
+	memregion->nbytes = newsize;
+	if (!mapit(memregion))
+		return -EIO;
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(visor_memregion_resize);
@@ -199,9 +163,7 @@ visor_memregion_destroy(struct memregion *memregion)
 {
 	if (!memregion)
 		return;
-	if (!memregion->overlapped)
-		unmapit(memregion);
+	unmapit(memregion);
 	kfree(memregion);
 }
 EXPORT_SYMBOL_GPL(visor_memregion_destroy);
-
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 046/141] staging: unisys: memregion: Use proper errno for mapit()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (44 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 045/141] staging: unisys: memregion: Nothing uses overlap allocations, so nuke it Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 047/141] staging: unisys: memregion: Eliminate unnecessary 'requested' flag Benjamin Romer
                   ` (97 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/visorutil/memregion_direct.c    | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 93c10b4..7ba68bc 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -32,7 +32,7 @@ struct memregion {
 	BOOL requested;
 };
 
-static BOOL mapit(struct memregion *memregion);
+static int mapit(struct memregion *memregion);
 static void unmapit(struct memregion *memregion);
 
 struct memregion *
@@ -47,7 +47,7 @@ visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
 
 	memregion->physaddr = physaddr;
 	memregion->nbytes = nbytes;
-	if (!mapit(memregion)) {
+	if (mapit(memregion)) {
 		rc = NULL;
 		goto cleanup;
 	}
@@ -61,19 +61,24 @@ cleanup:
 }
 EXPORT_SYMBOL_GPL(visor_memregion_create);
 
-static BOOL
+static int
 mapit(struct memregion *memregion)
 {
 	ulong physaddr = (ulong)(memregion->physaddr);
 	ulong nbytes = memregion->nbytes;
 
 	memregion->requested = FALSE;
-	if (request_mem_region(physaddr, nbytes, MYDRVNAME))
-		memregion->requested = TRUE;
+	if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
+		return -EBUSY;
+
+	memregion->requested = TRUE;
 	memregion->mapped = ioremap_cache(physaddr, nbytes);
-	if (!memregion->mapped)
-		return FALSE;
-	return TRUE;
+	if (!memregion->mapped) {
+		memregion->requested = TRUE;
+		return -EFAULT;
+	}
+
+	return 0;
 }
 
 static void
@@ -114,15 +119,16 @@ EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
 int
 visor_memregion_resize(struct memregion *memregion, ulong newsize)
 {
+	int rc;
+
 	if (newsize == memregion->nbytes)
 		return 0;
 
 	unmapit(memregion);
 	memregion->nbytes = newsize;
-	if (!mapit(memregion))
-		return -EIO;
+	rc = mapit(memregion);
 
-	return 0;
+	return rc;
 }
 EXPORT_SYMBOL_GPL(visor_memregion_resize);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 047/141] staging: unisys: memregion: Eliminate unnecessary 'requested' flag
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (45 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 046/141] staging: unisys: memregion: Use proper errno for mapit() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 048/141] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage Benjamin Romer
                   ` (96 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorutil/memregion_direct.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 7ba68bc..0ee7cb2 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -29,7 +29,6 @@ struct memregion {
 	HOSTADDRESS physaddr;
 	ulong nbytes;
 	void __iomem *mapped;
-	BOOL requested;
 };
 
 static int mapit(struct memregion *memregion);
@@ -67,16 +66,12 @@ mapit(struct memregion *memregion)
 	ulong physaddr = (ulong)(memregion->physaddr);
 	ulong nbytes = memregion->nbytes;
 
-	memregion->requested = FALSE;
 	if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
 		return -EBUSY;
 
-	memregion->requested = TRUE;
 	memregion->mapped = ioremap_cache(physaddr, nbytes);
-	if (!memregion->mapped) {
-		memregion->requested = TRUE;
+	if (!memregion->mapped)
 		return -EFAULT;
-	}
 
 	return 0;
 }
@@ -84,14 +79,11 @@ mapit(struct memregion *memregion)
 static void
 unmapit(struct memregion *memregion)
 {
-	if (memregion->mapped != NULL) {
+	if (memregion->mapped) {
 		iounmap(memregion->mapped);
 		memregion->mapped = NULL;
-	}
-	if (memregion->requested) {
-		release_mem_region((ulong)(memregion->physaddr),
+		release_mem_region((unsigned long)memregion->physaddr,
 				   memregion->nbytes);
-		memregion->requested = FALSE;
 	}
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 048/141] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (46 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 047/141] staging: unisys: memregion: Eliminate unnecessary 'requested' flag Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 049/141] staging: unisys: visorchipset: Use ioremap direction rather than heavy visor_memregion Benjamin Romer
                   ` (95 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 5bf8266..2be8514 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -399,6 +399,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 	struct parser_context *ctx = NULL;
 	struct memregion *rgn = NULL;
 	struct spar_controlvm_parameters_header *phdr = NULL;
+	int cnt;
 
 	if (retry)
 		*retry = false;
@@ -442,7 +443,10 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 			rc = NULL;
 			goto cleanup;
 		}
-		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
+		cnt = visor_memregion_read(rgn, 0, ctx->data, bytes);
+		visor_memregion_destroy(rgn);
+
+		if (cnt < 0) {
 			rc = NULL;
 			goto cleanup;
 		}
@@ -469,10 +473,6 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 
 	rc = ctx;
 cleanup:
-	if (rgn) {
-		visor_memregion_destroy(rgn);
-		rgn = NULL;
-	}
 	if (rc) {
 		controlvm_payload_bytes_buffered += ctx->param_bytes;
 	} else {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 049/141] staging: unisys: visorchipset: Use ioremap direction rather than heavy visor_memregion
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (47 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 048/141] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 050/141] staging: unisys: visorchipset.c: No need to include memregion.h anymore Benjamin Romer
                   ` (94 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 2be8514..9390ed6 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -397,9 +397,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 	int allocbytes = sizeof(struct parser_context) + bytes;
 	struct parser_context *rc = NULL;
 	struct parser_context *ctx = NULL;
-	struct memregion *rgn = NULL;
 	struct spar_controlvm_parameters_header *phdr = NULL;
-	int cnt;
 
 	if (retry)
 		*retry = false;
@@ -438,18 +436,21 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 		p = __va((unsigned long) (addr));
 		memcpy(ctx->data, p, bytes);
 	} else {
-		rgn = visor_memregion_create(addr, bytes);
-		if (!rgn) {
+		void __iomem *mapping;
+
+		if (!request_mem_region(addr, bytes, "visorchipset")) {
 			rc = NULL;
 			goto cleanup;
 		}
-		cnt = visor_memregion_read(rgn, 0, ctx->data, bytes);
-		visor_memregion_destroy(rgn);
 
-		if (cnt < 0) {
+		mapping = ioremap_cache(addr, bytes);
+		if (!mapping) {
+			release_mem_region(addr, bytes);
 			rc = NULL;
 			goto cleanup;
 		}
+		memcpy_fromio(ctx->data, mapping, bytes);
+		release_mem_region(addr, bytes);
 	}
 	if (!standard_payload_header) {
 		ctx->byte_stream = true;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 050/141] staging: unisys: visorchipset.c: No need to include memregion.h anymore
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (48 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 049/141] staging: unisys: visorchipset: Use ioremap direction rather than heavy visor_memregion Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 051/141] staging: unisys: visorchannel_clear(): Avoid 64KB memory leak Benjamin Romer
                   ` (93 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 9390ed6..e0f8d76 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -15,7 +15,6 @@
  * details.
  */
 
-#include "memregion.h"
 #include "controlvmchannel.h"
 #include "version.h"
 #include "procobjecttree.h"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 051/141] staging: unisys: visorchannel_clear(): Avoid 64KB memory leak
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (49 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 050/141] staging: unisys: visorchipset.c: No need to include memregion.h anymore Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 052/141] staging: unisys: visorchannel_clear(): No need to use vmalloc here Benjamin Romer
                   ` (92 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index faafa79..e555476 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -236,7 +236,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 		written += thisbytes;
 		nbytes -= thisbytes;
 	}
-	return 0;
+	err = 0;
 
 cleanup:
 	vfree(buf);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 052/141] staging: unisys: visorchannel_clear(): No need to use vmalloc here
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (50 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 051/141] staging: unisys: visorchannel_clear(): Avoid 64KB memory leak Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 053/141] staging: unisys: decouple visor_memregion_{read, write}() Benjamin Romer
                   ` (91 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Using a page is sufficient, and avoids the cost of vmalloc/vfree

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index e555476..1a1e7be 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -214,17 +214,18 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 		   ulong nbytes)
 {
 	int err;
-	int bufsize = 65536;
+	int bufsize = PAGE_SIZE;
 	int written = 0;
 	u8 *buf;
 
-	buf = vmalloc(bufsize);
+	buf = (u8 *) __get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
 	memset(buf, ch, bufsize);
+
 	while (nbytes > 0) {
-		ulong thisbytes = bufsize;
+		int thisbytes = bufsize;
 
 		if (nbytes < thisbytes)
 			thisbytes = nbytes;
@@ -239,7 +240,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 	err = 0;
 
 cleanup:
-	vfree(buf);
+	free_page((unsigned long) buf);
 	return err;
 }
 EXPORT_SYMBOL_GPL(visorchannel_clear);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 053/141] staging: unisys: decouple visor_memregion_{read, write}()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (51 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 052/141] staging: unisys: visorchannel_clear(): No need to use vmalloc here Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 054/141] staging: unisys: memregion: move struct memregion to memregion.h Benjamin Romer
                   ` (90 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/visorutil/memregion_direct.c    | 26 ++++++++--------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 0ee7cb2..96460d7 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -124,35 +124,27 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize)
 }
 EXPORT_SYMBOL_GPL(visor_memregion_resize);
 
-static int
-memregion_readwrite(BOOL is_write,
-		    struct memregion *memregion, ulong offset,
-		    void *local, ulong nbytes)
+int
+visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
+		     ulong nbytes)
 {
 	if (offset + nbytes > memregion->nbytes)
 		return -EIO;
 
-	if (is_write)
-		memcpy_toio(memregion->mapped + offset, local, nbytes);
-	else
-		memcpy_fromio(local, memregion->mapped + offset, nbytes);
-
+	memcpy_fromio(dest, memregion->mapped + offset, nbytes);
 	return 0;
 }
-
-int
-visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
-		     ulong nbytes)
-{
-	return memregion_readwrite(FALSE, memregion, offset, dest, nbytes);
-}
 EXPORT_SYMBOL_GPL(visor_memregion_read);
 
 int
 visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
 		      ulong nbytes)
 {
-	return memregion_readwrite(TRUE, memregion, offset, src, nbytes);
+	if (offset + nbytes > memregion->nbytes)
+		return -EIO;
+
+	memcpy_toio(memregion->mapped + offset, src, nbytes);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(visor_memregion_write);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 054/141] staging: unisys: memregion: move struct memregion to memregion.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (52 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 053/141] staging: unisys: decouple visor_memregion_{read, write}() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 055/141] staging: unisys: memregion: Embed memregion in struct channel Benjamin Romer
                   ` (89 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorutil/memregion.h        | 6 +++++-
 drivers/staging/unisys/visorutil/memregion_direct.c | 6 ------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 1eb3a67..8f006fc 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -23,7 +23,11 @@
 /* struct memregion is an opaque structure to users.
  * Fields are declared only in the implementation .c files.
  */
-struct memregion;
+struct memregion {
+	HOSTADDRESS physaddr;
+	ulong nbytes;
+	void __iomem *mapped;
+};
 
 struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes);
 int visor_memregion_resize(struct memregion *memregion, ulong newsize);
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 96460d7..4ad25df7 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -25,12 +25,6 @@
 
 #define MYDRVNAME "memregion"
 
-struct memregion {
-	HOSTADDRESS physaddr;
-	ulong nbytes;
-	void __iomem *mapped;
-};
-
 static int mapit(struct memregion *memregion);
 static void unmapit(struct memregion *memregion);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 055/141] staging: unisys: memregion: Embed memregion in struct channel
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (53 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 054/141] staging: unisys: memregion: move struct memregion to memregion.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 056/141] staging: unisys: visorchannel_get_memregion() isn't used Benjamin Romer
                   ` (88 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This changes the API for visor_memregion_create() to require a
pre-allocated struct memregion. Embedding this in struct channel
avoids a layer of additional kmalloc()'s and error checks.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c     | 36 ++++++++++------------
 drivers/staging/unisys/visorutil/memregion.h       |  3 +-
 .../staging/unisys/visorutil/memregion_direct.c    |  9 ++----
 3 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 1a1e7be..d2e4fe0 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -30,7 +30,7 @@
 #define MYDRVNAME "visorchannel"
 
 struct visorchannel {
-	struct memregion *memregion;	/* from visor_memregion_create() */
+	struct memregion memregion;	/* from visor_memregion_create() */
 	struct channel_header chan_hdr;
 	uuid_le guid;
 	ulong size;
@@ -63,19 +63,17 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	if (!channel)
 		goto cleanup;
 
-	channel->memregion = NULL;
 	channel->needs_lock = needs_lock;
 	spin_lock_init(&channel->insert_lock);
 	spin_lock_init(&channel->remove_lock);
 
 	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	memregion = visor_memregion_create(physaddr, size);
+	memregion = visor_memregion_create(&channel->memregion, physaddr, size);
 
 	if (!memregion)
 		goto cleanup;
-	channel->memregion = memregion;
 
-	err = visor_memregion_read(channel->memregion, 0, &channel->chan_hdr,
+	err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr,
 				   sizeof(struct channel_header));
 	if (err)
 		goto cleanup;
@@ -86,7 +84,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
 		guid = channel->chan_hdr.chtype;
 
-	err = visor_memregion_resize(channel->memregion, channel_bytes);
+	err = visor_memregion_resize(&channel->memregion, channel_bytes);
 	if (err)
 		goto cleanup;
 
@@ -121,7 +119,7 @@ visorchannel_destroy(struct visorchannel *channel)
 {
 	if (!channel)
 		return;
-	visor_memregion_destroy(channel->memregion);
+	visor_memregion_destroy(&channel->memregion);
 	kfree(channel);
 }
 EXPORT_SYMBOL_GPL(visorchannel_destroy);
@@ -129,7 +127,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy);
 HOSTADDRESS
 visorchannel_get_physaddr(struct visorchannel *channel)
 {
-	return visor_memregion_get_physaddr(channel->memregion);
+	return visor_memregion_get_physaddr(&channel->memregion);
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
 
@@ -179,7 +177,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
 struct memregion *
 visorchannel_get_memregion(struct visorchannel *channel)
 {
-	return channel->memregion;
+	return &channel->memregion;
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
 
@@ -190,7 +188,7 @@ visorchannel_read(struct visorchannel *channel, ulong offset,
 	int rc;
 	size_t size = sizeof(struct channel_header);
 
-	rc = visor_memregion_read(channel->memregion, offset, local, nbytes);
+	rc = visor_memregion_read(&channel->memregion, offset, local, nbytes);
 	if (rc && !offset && (nbytes >= size))
 		memcpy(&channel->chan_hdr, local, size);
 	return rc;
@@ -205,7 +203,8 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
 
 	if (!offset && nbytes >= size)
 		memcpy(&channel->chan_hdr, local, size);
-	return visor_memregion_write(channel->memregion, offset, local, nbytes);
+	return visor_memregion_write(&channel->memregion,
+				     offset, local, nbytes);
 }
 EXPORT_SYMBOL_GPL(visorchannel_write);
 
@@ -229,7 +228,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 
 		if (nbytes < thisbytes)
 			thisbytes = nbytes;
-		err = visor_memregion_write(channel->memregion,
+		err = visor_memregion_write(&channel->memregion,
 					    offset + written, buf, thisbytes);
 		if (err)
 			goto cleanup;
@@ -270,7 +269,7 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
  *  into host memory
  */
 #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
-	(visor_memregion_write(channel->memregion,			\
+	(visor_memregion_write(&channel->memregion,			\
 			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
 			       offsetof(struct signal_queue_header, FIELD),\
 			       &((sig_hdr)->FIELD),			\
@@ -286,7 +285,7 @@ sig_read_header(struct visorchannel *channel, u32 queue,
 		return FALSE;
 
 	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
-	err = visor_memregion_read(channel->memregion,
+	err = visor_memregion_read(&channel->memregion,
 				   SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
 				   sig_hdr, sizeof(struct signal_queue_header));
 	if (err)
@@ -303,7 +302,7 @@ sig_read_data(struct visorchannel *channel, u32 queue,
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
-	err = visor_memregion_read(channel->memregion,
+	err = visor_memregion_read(&channel->memregion,
 				   signal_data_offset,
 				   data, sig_hdr->signal_size);
 	if (err)
@@ -320,7 +319,7 @@ sig_write_data(struct visorchannel *channel, u32 queue,
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
-	err = visor_memregion_write(channel->memregion,
+	err = visor_memregion_write(&channel->memregion,
 				    signal_data_offset,
 				    data, sig_hdr->signal_size);
 	if (err)
@@ -383,7 +382,7 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
 	if (sig_hdr.head == sig_hdr.tail) {
 		sig_hdr.num_overflows++;
-		visor_memregion_write(channel->memregion,
+		visor_memregion_write(&channel->memregion,
 				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
 						       queue) +
 				      offsetof(struct signal_queue_header,
@@ -495,9 +494,6 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
 
 	if (!channel)
 		return;
-	memregion = channel->memregion;
-	if (!memregion)
-		return;
 
 	addr = visor_memregion_get_physaddr(memregion);
 	nbytes_region = visor_memregion_get_nbytes(memregion);
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 8f006fc..3826fe6 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -29,7 +29,8 @@ struct memregion {
 	void __iomem *mapped;
 };
 
-struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes);
+struct memregion *visor_memregion_create(struct memregion *memregion,
+					 HOSTADDRESS physaddr, ulong nbytes);
 int visor_memregion_resize(struct memregion *memregion, ulong newsize);
 int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 4ad25df7..a575ecc 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -29,14 +29,10 @@ static int mapit(struct memregion *memregion);
 static void unmapit(struct memregion *memregion);
 
 struct memregion *
-visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
+visor_memregion_create(struct memregion *memregion,
+		       HOSTADDRESS physaddr, ulong nbytes)
 {
 	struct memregion *rc = NULL;
-	struct memregion *memregion;
-
-	memregion = kzalloc(sizeof(*memregion), GFP_KERNEL | __GFP_NORETRY);
-	if (memregion == NULL)
-		return NULL;
 
 	memregion->physaddr = physaddr;
 	memregion->nbytes = nbytes;
@@ -148,6 +144,5 @@ visor_memregion_destroy(struct memregion *memregion)
 	if (!memregion)
 		return;
 	unmapit(memregion);
-	kfree(memregion);
 }
 EXPORT_SYMBOL_GPL(visor_memregion_destroy);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 056/141] staging: unisys: visorchannel_get_memregion() isn't used
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (54 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 055/141] staging: unisys: memregion: Embed memregion in struct channel Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 057/141] staging: unisys: Eliminate unused visorchannel_dump_section() Benjamin Romer
                   ` (87 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      | 1 -
 drivers/staging/unisys/visorbus/visorchannel.c | 7 -------
 2 files changed, 8 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 21fd785..749beac 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -196,7 +196,6 @@ char *visorchannel_id(struct visorchannel *channel, char *s);
 char *visorchannel_zoneid(struct visorchannel *channel, char *s);
 u64 visorchannel_get_clientpartition(struct visorchannel *channel);
 uuid_le visorchannel_get_uuid(struct visorchannel *channel);
-struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
 char *visorchannel_uuid_id(uuid_le *guid, char *s);
 void visorchannel_debug(struct visorchannel *channel, int num_queues,
 			struct seq_file *seq, u32 off);
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index d2e4fe0..5e4a591 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -174,13 +174,6 @@ visorchannel_get_uuid(struct visorchannel *channel)
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
 
-struct memregion *
-visorchannel_get_memregion(struct visorchannel *channel)
-{
-	return &channel->memregion;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
-
 int
 visorchannel_read(struct visorchannel *channel, ulong offset,
 		  void *local, ulong nbytes)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 057/141] staging: unisys: Eliminate unused visorchannel_dump_section()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (55 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 056/141] staging: unisys: visorchannel_get_memregion() isn't used Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 058/141] staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64 Benjamin Romer
                   ` (86 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      |  2 --
 drivers/staging/unisys/visorbus/visorchannel.c | 37 --------------------------
 2 files changed, 39 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 749beac..e1c6662 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -199,8 +199,6 @@ uuid_le visorchannel_get_uuid(struct visorchannel *channel);
 char *visorchannel_uuid_id(uuid_le *guid, char *s);
 void visorchannel_debug(struct visorchannel *channel, int num_queues,
 			struct seq_file *seq, u32 off);
-void visorchannel_dump_section(struct visorchannel *chan, char *s,
-			       int off, int len, struct seq_file *seq);
 void __iomem *visorchannel_get_header(struct visorchannel *channel);
 
 #endif
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 5e4a591..150e3df 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -548,40 +548,3 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
 		   addr + off, nbytes);
 }
 EXPORT_SYMBOL_GPL(visorchannel_debug);
-
-void
-visorchannel_dump_section(struct visorchannel *chan, char *s,
-			  int off, int len, struct seq_file *seq)
-{
-	char *buf, *tbuf, *fmtbuf;
-	int fmtbufsize = 0;
-	int i;
-	int errcode = 0;
-
-	fmtbufsize = 100 * COVQ(len, 16);
-	buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
-	if (!buf)
-		return;
-	fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
-	if (!fmtbuf)
-		goto fmt_failed;
-
-	errcode = visorchannel_read(chan, off, buf, len);
-	if (errcode < 0)
-		goto read_failed;
-	seq_printf(seq, "channel %s:\n", s);
-	tbuf = buf;
-	while (len > 0) {
-		i = (len < 16) ? len : 16;
-		hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
-		seq_printf(seq, "%s\n", fmtbuf);
-		tbuf += 16;
-		len -= 16;
-	}
-
-read_failed:
-	kfree(fmtbuf);
-fmt_failed:
-	kfree(buf);
-}
-EXPORT_SYMBOL_GPL(visorchannel_dump_section);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 058/141] staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (56 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 057/141] staging: unisys: Eliminate unused visorchannel_dump_section() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 059/141] staging: unisys: remove unused enum from controlvmchannel.h Benjamin Romer
                   ` (85 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes typedef GUEST_PHYSICAL_ADDRESS to u64

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../include/channels/controlvmchannel.h            | 38 ++++++++++------------
 drivers/staging/unisys/visorbus/visorchipset.c     |  2 +-
 2 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index a66db79..435ac92 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -20,8 +20,6 @@
 #include "channel.h"
 #include "controlframework.h"
 
-typedef u64 GUEST_PHYSICAL_ADDRESS;
-
 enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE,
 	    TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE
 };
@@ -343,7 +341,7 @@ struct controlvm_message {
 };
 
 struct device_map {
-	GUEST_PHYSICAL_ADDRESS device_channel_address;
+	u64 device_channel_address;
 	u64 device_channel_size;
 	u32 ca_index;
 	u32 reserved;		/* natural alignment */
@@ -362,23 +360,23 @@ struct guest_devices  {
 
 struct spar_controlvm_channel_protocol {
 	 struct channel_header header;
-	 GUEST_PHYSICAL_ADDRESS gp_controlvm;	/* guest physical address of
+	 u64 gp_controlvm;	/* guest physical address of
 						 * this channel */
-	 GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of
+	 u64 gp_partition_tables;/* guest physical address of
 						     * partition tables */
-	 GUEST_PHYSICAL_ADDRESS gp_diag_guest;	/* guest physical address of
+	 u64 gp_diag_guest;	/* guest physical address of
 						 * diagnostic channel */
-	 GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read
+	 u64 gp_boot_romdisk;/* guest phys addr of (read
 						 * only) Boot ROM disk */
-	 GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable
+	 u64 gp_boot_ramdisk;/* guest phys addr of writable
 						 * Boot RAM disk */
-	 GUEST_PHYSICAL_ADDRESS gp_acpi_table;	/* guest phys addr of acpi
+	 u64 gp_acpi_table;	/* guest phys addr of acpi
 						 * table */
-	 GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control
+	 u64 gp_control_channel;/* guest phys addr of control
 						    * channel */
-	 GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic
+	 u64 gp_diag_romdisk;/* guest phys addr of diagnostic
 						 * ROM disk */
-	 GUEST_PHYSICAL_ADDRESS gp_nvram;	/* guest phys addr of NVRAM
+	 u64 gp_nvram;	/* guest phys addr of NVRAM
 						 * channel */
 	 u64 request_payload_offset;	/* Offset to request payload area */
 	 u64 event_payload_offset;	/* Offset to event payload area */
@@ -389,28 +387,28 @@ struct spar_controlvm_channel_protocol {
 	 u32 nvram_channel_bytes;	/* Bytes in PartitionNvram segment */
 	 u32 message_bytes;	/* sizeof(CONTROLVM_MESSAGE) */
 	 u32 message_count;	/* CONTROLVM_MESSAGE_MAX */
-	 GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS
+	 u64 gp_smbios_table;/* guest phys addr of SMBIOS
 						 * tables */
-	 GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of
+	 u64 gp_physical_smbios_table;/* guest phys addr of
 							  * SMBIOS table  */
 	 /* ULTRA_MAX_GUESTS_PER_SERVICE */
 	 struct guest_devices gp_obsolete_guest_devices[16];
 
 	 /* guest physical address of EFI firmware image base  */
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base;
+	 u64 virtual_guest_firmware_image_base;
 
 	 /* guest physical address of EFI firmware entry point  */
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point;
+	 u64 virtual_guest_firmware_entry_point;
 
 	 /* guest EFI firmware image size  */
 	 u64 virtual_guest_firmware_image_size;
 
 	 /* GPA = 1MB where EFI firmware image is copied to  */
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base;
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_image_base;
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_image_size;
+	 u64 virtual_guest_firmware_boot_base;
+	 u64 virtual_guest_image_base;
+	 u64 virtual_guest_image_size;
 	 u64 prototype_control_channel_offset;
-	 GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle;
+	 u64 virtual_guest_partition_handle;
 
 	 u16 restore_action;	/* Restore Action field to restore the guest
 				 * partition */
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index e0f8d76..107012f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2631,7 +2631,7 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	unsigned long physaddr = 0;
 	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
-	GUEST_PHYSICAL_ADDRESS addr = 0;
+	u64 addr = 0;
 
 	/* sv_enable_dfp(); */
 	if (offset & (PAGE_SIZE - 1))
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 059/141] staging: unisys: remove unused enum from controlvmchannel.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (57 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 058/141] staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64 Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 060/141] staging: unisys: remove unused #define in controlvmchannel Benjamin Romer
                   ` (84 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes this enum since it is unused

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/common-spar/include/channels/controlvmchannel.h    | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index 435ac92..4e6dec2 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -20,10 +20,6 @@
 #include "channel.h"
 #include "controlframework.h"
 
-enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE,
-	    TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE
-};
-
 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID	\
 		UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 060/141] staging: unisys: remove unused #define in controlvmchannel
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (58 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 059/141] staging: unisys: remove unused enum from controlvmchannel.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 061/141] staging: unisys: remove unused #define MAX_SERIAL_NUM Benjamin Romer
                   ` (83 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch remove unused controlvmchannel.h #defines

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/common-spar/include/channels/controlvmchannel.h   | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index 4e6dec2..ff15c45 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -47,13 +47,8 @@ static const uuid_le spar_controlvm_channel_protocol_uuid =
 		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
 		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
 
-#define MY_DEVICE_INDEX 0
-#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
 #define MAX_SERIAL_NUM	32
 
-#define DISK_ZERO_PUN_NUMBER	1  /* Target ID on the SCSI bus for LUN 0 */
-#define DISK_ZERO_LUN_NUMBER	3  /* Logical Unit Number */
-
 /* Defines for various channel queues... */
 #define CONTROLVM_QUEUE_REQUEST		0
 #define CONTROLVM_QUEUE_RESPONSE	1
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 061/141] staging: unisys: remove unused #define MAX_SERIAL_NUM
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (59 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 060/141] staging: unisys: remove unused #define in controlvmchannel Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 062/141] staging: unisys: remove server crust from visorchipset Benjamin Romer
                   ` (82 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch simply removes #define MAX_SERIAL_NUM from iochannel.h

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/common-spar/include/channels/iochannel.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
index 3bd7579..ff393c2 100644
--- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
@@ -140,10 +140,6 @@
 * MAX_SKB_FRAGS size, which is 18 which is smaller than MAX_PHYS_INFO for
 * now.  */
 
-#ifndef MAX_SERIAL_NUM
-#define MAX_SERIAL_NUM		32
-#endif				/* MAX_SERIAL_NUM */
-
 #define MAX_SCSI_BUSES		1
 #define MAX_SCSI_TARGETS	8
 #define MAX_SCSI_LUNS		16
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 062/141] staging: unisys: remove server crust from visorchipset.
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (60 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 061/141] staging: unisys: remove unused #define MAX_SERIAL_NUM Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 063/141] staging: unisys: remove unused CONTROL_VM messages from enum Benjamin Romer
                   ` (81 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

The visorchipset driver originally serviced both servers and
clients. This implementation is client only so remove some
more server side implementation.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    |   8 +-
 drivers/staging/unisys/visorbus/visorbus_private.h |   9 +-
 drivers/staging/unisys/visorbus/visorchipset.c     | 228 +++++----------------
 3 files changed, 62 insertions(+), 183 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 6c939ce..3fcd5fb 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -2066,9 +2066,9 @@ visorbus_init(void)
 	/* This enables us to receive notifications when devices appear for
 	 * which this service partition is to be a server for.
 	 */
-	visorchipset_register_busdev_server(&chipset_notifiers,
-					    &chipset_responders,
-					    &chipset_driverinfo);
+	visorchipset_register_busdev(&chipset_notifiers,
+				     &chipset_responders,
+				     &chipset_driverinfo);
 
 	rc = 0;
 
@@ -2084,7 +2084,7 @@ visorbus_exit(void)
 {
 	struct list_head *listentry, *listtmp;
 
-	visorchipset_register_busdev_server(NULL, NULL, NULL);
+	visorchipset_register_busdev(NULL, NULL, NULL);
 	remove_all_visor_devices();
 
 	flush_workqueue(periodic_dev_workqueue); /* better not be any work! */
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index a3d78f6..f9a5e01 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -138,13 +138,12 @@ struct visorchipset_busdev_responders {
 };
 
 /** Register functions (in the bus driver) to get called by visorchipset
- *  whenever a bus or device appears for which this service partition is
- *  to be the client for.  visorchipset will fill in <responders>, to
- *  indicate functions the bus driver should call to indicate message
- *  responses.
+ *  whenever a bus or device appears for which this guest is to be the
+ *  client for.  visorchipset will fill in <responders>, to indicate
+ *  functions the bus driver should call to indicate message responses.
  */
 void
-visorchipset_register_busdev_server(
+visorchipset_register_busdev(
 			struct visorchipset_busdev_notifiers *notifiers,
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 107012f..3a1ee2d 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -25,7 +25,6 @@
 #include "guestlinuxdebug.h"
 #include "visorbus_private.h"
 
-
 #include <linux/ctype.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
@@ -36,10 +35,6 @@
 #include <linux/crash_dump.h>
 
 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
-#define TEST_VNIC_PHYSITF "eth0"	/* physical network itf for
-					 * vnic loopback test */
-#define TEST_VNIC_SWITCHNO 1
-#define TEST_VNIC_BUSNO 9
 
 #define MAX_NAME_SIZE 128
 #define MAX_IP_SIZE   50
@@ -54,14 +49,8 @@
 /*
  * Module parameters
  */
-static int visorchipset_testvnic;
-static int visorchipset_testvnicclient;
-static int visorchipset_testmsg;
 static int visorchipset_major;
-static int visorchipset_serverregwait;
-static int visorchipset_clientregwait = 1;	/* default is on */
-static int visorchipset_testteardown;
-static int visorchipset_disable_controlvm;
+static int visorchipset_visorbusregwait = 1;	/* default is on */
 static int visorchipset_holdchipsetready;
 static unsigned long controlvm_payload_bytes_buffered;
 
@@ -90,8 +79,7 @@ visorchipset_release(struct inode *inode, struct file *file)
 static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
 static unsigned long most_recent_message_jiffies;	/* when we got our last
 						 * controlvm message */
-static int serverregistered;
-static int clientregistered;
+static int visorbusregistered;
 
 #define MAX_CHIPSET_EVENTS 2
 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
@@ -119,16 +107,6 @@ static u32 g_diagpool_bus_no = 0xffffff;
 static u32 g_diagpool_dev_no = 0xffffff;
 static struct controlvm_message_packet g_devicechangestate_packet;
 
-/* Only VNIC and VHBA channels are sent to visorclientbus (aka
- * "visorhackbus")
- */
-#define FOR_VISORHACKBUS(channel_type_guid) \
-	(((uuid_le_cmp(channel_type_guid,\
-		       spar_vnic_channel_protocol_uuid) == 0) ||\
-	(uuid_le_cmp(channel_type_guid,\
-			spar_vhba_channel_protocol_uuid) == 0)))
-#define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
-
 #define is_diagpool_channel(channel_type_guid) \
 	(uuid_le_cmp(channel_type_guid,\
 		     spar_diag_pool_channel_protocol_uuid) == 0)
@@ -254,8 +232,7 @@ static void parahotplug_process_list(void);
 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
  * CONTROLVM_REPORTEVENT.
  */
-static struct visorchipset_busdev_notifiers busdev_server_notifiers;
-static struct visorchipset_busdev_notifiers busdev_client_notifiers;
+static struct visorchipset_busdev_notifiers busdev_notifiers;
 
 static void bus_create_response(u32 bus_no, int response);
 static void bus_destroy_response(u32 bus_no, int response);
@@ -1028,19 +1005,19 @@ clear_chipset_events(void)
 }
 
 void
-visorchipset_register_busdev_server(
+visorchipset_register_busdev(
 			struct visorchipset_busdev_notifiers *notifiers,
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info)
 {
 	down(&notifier_lock);
 	if (!notifiers) {
-		memset(&busdev_server_notifiers, 0,
-		       sizeof(busdev_server_notifiers));
-		serverregistered = 0;	/* clear flag */
+		memset(&busdev_notifiers, 0,
+		       sizeof(busdev_notifiers));
+		visorbusregistered = 0;	/* clear flag */
 	} else {
-		busdev_server_notifiers = *notifiers;
-		serverregistered = 1;	/* set flag */
+		busdev_notifiers = *notifiers;
+		visorbusregistered = 1;	/* set flag */
 	}
 	if (responders)
 		*responders = busdev_responders;
@@ -1050,37 +1027,7 @@ visorchipset_register_busdev_server(
 
 	up(&notifier_lock);
 }
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
-
-/** Register functions (in the bus driver) to get called by visorchipset
- *  whenever a bus or device appears for which this service partition is
- *  to be the server for.  visorchipset will fill in <responders>, to
- *  indicate functions the bus driver should call to indicate message
- *  responses.
- */
-void
-visorchipset_register_busdev_client(
-			struct visorchipset_busdev_notifiers *notifiers,
-			struct visorchipset_busdev_responders *responders,
-			struct ultra_vbus_deviceinfo *driver_info)
-{
-	down(&notifier_lock);
-	if (!notifiers) {
-		memset(&busdev_client_notifiers, 0,
-		       sizeof(busdev_client_notifiers));
-		clientregistered = 0;	/* clear flag */
-	} else {
-		busdev_client_notifiers = *notifiers;
-		clientregistered = 1;	/* set flag */
-	}
-	if (responders)
-		*responders = busdev_responders;
-	if (driver_info)
-		bus_device_info_init(driver_info, "chipset(bolts)",
-				     "visorchipset", VERSION, NULL);
-	up(&notifier_lock);
-}
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
+EXPORT_SYMBOL_GPL(visorchipset_register_busdev);
 
 static void
 cleanup_controlvm_structures(void)
@@ -1377,34 +1324,14 @@ bus_epilog(u32 bus_no,
 	if (response == CONTROLVM_RESP_SUCCESS) {
 		switch (cmd) {
 		case CONTROLVM_BUS_CREATE:
-			/* We can't tell from the bus_create
-			* information which of our 2 bus flavors the
-			* devices on this bus will ultimately end up.
-			* FORTUNATELY, it turns out it is harmless to
-			* send the bus_create to both of them.  We can
-			* narrow things down a little bit, though,
-			* because we know: - BusDev_Server can handle
-			* either server or client devices
-			* - BusDev_Client can handle ONLY client
-			* devices */
-			if (busdev_server_notifiers.bus_create) {
-				(*busdev_server_notifiers.bus_create) (bus_no);
-				notified = true;
-			}
-			if ((!bus_info->flags.server) /*client */ &&
-			    busdev_client_notifiers.bus_create) {
-				(*busdev_client_notifiers.bus_create) (bus_no);
+			if (busdev_notifiers.bus_create) {
+				(*busdev_notifiers.bus_create) (bus_no);
 				notified = true;
 			}
 			break;
 		case CONTROLVM_BUS_DESTROY:
-			if (busdev_server_notifiers.bus_destroy) {
-				(*busdev_server_notifiers.bus_destroy) (bus_no);
-				notified = true;
-			}
-			if ((!bus_info->flags.server) /*client */ &&
-			    busdev_client_notifiers.bus_destroy) {
-				(*busdev_client_notifiers.bus_destroy) (bus_no);
+			if (busdev_notifiers.bus_destroy) {
+				(*busdev_notifiers.bus_destroy) (bus_no);
 				notified = true;
 			}
 			break;
@@ -1439,10 +1366,8 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 	if (!dev_info)
 		return;
 
-	if (for_visorbus)
-		notifiers = &busdev_server_notifiers;
-	else
-		notifiers = &busdev_client_notifiers;
+	notifiers = &busdev_notifiers;
+
 	if (need_response) {
 		memcpy(&dev_info->pending_msg_hdr, msg_hdr,
 		       sizeof(struct controlvm_message_header));
@@ -1692,8 +1617,7 @@ cleanup:
 	}
 	device_epilog(bus_no, dev_no, segment_state_running,
 		      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
-		      inmsg->hdr.flags.response_expected == 1,
-		      FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
+		      inmsg->hdr.flags.response_expected == 1, 1);
 }
 
 static void
@@ -1719,9 +1643,7 @@ my_device_changestate(struct controlvm_message *inmsg)
 	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
 		device_epilog(bus_no, dev_no, state,
 			      CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
-			      inmsg->hdr.flags.response_expected == 1,
-			      FOR_VISORBUS(
-					dev_info->chan_info.channel_type_uuid));
+			      inmsg->hdr.flags.response_expected == 1, 1);
 }
 
 static void
@@ -1742,9 +1664,7 @@ my_device_destroy(struct controlvm_message *inmsg)
 	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
 		device_epilog(bus_no, dev_no, segment_state_running,
 			      CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
-			      inmsg->hdr.flags.response_expected == 1,
-			      FOR_VISORBUS(
-					dev_info->chan_info.channel_type_uuid));
+			      inmsg->hdr.flags.response_expected == 1, 1);
 }
 
 /* When provided with the physical address of the controlvm channel
@@ -2251,12 +2171,7 @@ controlvm_periodic_work(struct work_struct *work)
 	static u64 poll_count;
 
 	/* make sure visorbus server is registered for controlvm callbacks */
-	if (visorchipset_serverregwait && !serverregistered)
-		goto cleanup;
-	/* make sure visorclientbus server is regsitered for controlvm
-	 * callbacks
-	 */
-	if (visorchipset_clientregwait && !clientregistered)
+	if (visorchipset_visorbusregwait && !visorbusregistered)
 		goto cleanup;
 
 	poll_count++;
@@ -2347,14 +2262,8 @@ setup_crash_devices_work_queue(struct work_struct *work)
 	u32 local_crash_msg_offset;
 	u16 local_crash_msg_count;
 
-	/* make sure visorbus server is registered for controlvm callbacks */
-	if (visorchipset_serverregwait && !serverregistered)
-		goto cleanup;
-
-	/* make sure visorclientbus server is regsitered for controlvm
-	 * callbacks
-	 */
-	if (visorchipset_clientregwait && !clientregistered)
+	/* make sure visorbus is registered for controlvm callbacks */
+	if (visorchipset_visorbusregwait && !visorbusregistered)
 		goto cleanup;
 
 	POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
@@ -2739,18 +2648,11 @@ visorchipset_init(void)
 	if (!unisys_spar_platform)
 		return -ENODEV;
 
-	memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers));
-	memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers));
+	memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
 	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
 	memset(&livedump_info, 0, sizeof(livedump_info));
 	atomic_set(&livedump_info.buffers_in_use, 0);
 
-	if (visorchipset_testvnic) {
-		POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
-		rc = x;
-		goto cleanup;
-	}
-
 	addr = controlvm_get_channel_address();
 	if (addr) {
 		controlvm_channel =
@@ -2779,32 +2681,30 @@ visorchipset_init(void)
 
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-	if (!visorchipset_disable_controlvm) {
-		/* if booting in a crash kernel */
-		if (is_kdump_kernel())
-			INIT_DELAYED_WORK(&periodic_controlvm_work,
-					  setup_crash_devices_work_queue);
-		else
-			INIT_DELAYED_WORK(&periodic_controlvm_work,
-					  controlvm_periodic_work);
-		periodic_controlvm_workqueue =
-		    create_singlethread_workqueue("visorchipset_controlvm");
-
-		if (!periodic_controlvm_workqueue) {
-			POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
-					 DIAG_SEVERITY_ERR);
-			rc = -ENOMEM;
-			goto cleanup;
-		}
-		most_recent_message_jiffies = jiffies;
-		poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-		rc = queue_delayed_work(periodic_controlvm_workqueue,
-					&periodic_controlvm_work, poll_jiffies);
-		if (rc < 0) {
-			POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
-					 DIAG_SEVERITY_ERR);
-			goto cleanup;
-		}
+	/* if booting in a crash kernel */
+	if (is_kdump_kernel())
+		INIT_DELAYED_WORK(&periodic_controlvm_work,
+				  setup_crash_devices_work_queue);
+	else
+		INIT_DELAYED_WORK(&periodic_controlvm_work,
+				  controlvm_periodic_work);
+	periodic_controlvm_workqueue =
+	    create_singlethread_workqueue("visorchipset_controlvm");
+
+	if (!periodic_controlvm_workqueue) {
+		POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
+				 DIAG_SEVERITY_ERR);
+		rc = -ENOMEM;
+		goto cleanup;
+	}
+	most_recent_message_jiffies = jiffies;
+	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+	rc = queue_delayed_work(periodic_controlvm_workqueue,
+				&periodic_controlvm_work, poll_jiffies);
+	if (rc < 0) {
+		POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
+				 DIAG_SEVERITY_ERR);
+		goto cleanup;
 	}
 
 	visorchipset_platform_device.dev.devt = major_dev;
@@ -2840,15 +2740,11 @@ visorchipset_exit(void)
 
 	visorbus_exit();
 
-	if (visorchipset_disable_controlvm) {
-		;
-	} else {
-		cancel_delayed_work(&periodic_controlvm_work);
-		flush_workqueue(periodic_controlvm_workqueue);
-		destroy_workqueue(periodic_controlvm_workqueue);
-		periodic_controlvm_workqueue = NULL;
-		destroy_controlvm_payload_info(&controlvm_payload_info);
-	}
+	cancel_delayed_work(&periodic_controlvm_work);
+	flush_workqueue(periodic_controlvm_workqueue);
+	destroy_workqueue(periodic_controlvm_workqueue);
+	periodic_controlvm_workqueue = NULL;
+	destroy_controlvm_payload_info(&controlvm_payload_info);
 
 	cleanup_controlvm_structures();
 
@@ -2860,28 +2756,12 @@ visorchipset_exit(void)
 	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 }
 
-module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
-module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
-module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testmsg,
-		 "1 to manufacture the chipset, bus, and switch messages");
 module_param_named(major, visorchipset_major, int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_major,
 		 "major device number to use for the device node");
-module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_serverreqwait,
+module_param_named(visorbusregwait, visorchipset_visorbusregwait, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_visorbusreqwait,
 		 "1 to have the module wait for the visor bus to register");
-module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
-module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testteardown,
-		 "1 to test teardown of the chipset, bus, and switch");
-module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
-		   S_IRUGO);
-MODULE_PARM_DESC(visorchipset_disable_controlvm,
-		 "1 to disable polling of controlVm channel");
 module_param_named(holdchipsetready, visorchipset_holdchipsetready,
 		   int, S_IRUGO);
 MODULE_PARM_DESC(visorchipset_holdchipsetready,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 063/141] staging: unisys: remove unused CONTROL_VM messages from enum
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (61 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 062/141] staging: unisys: remove server crust from visorchipset Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 064/141] staging: unisys: rename variable to reserverd since it is unused Benjamin Romer
                   ` (80 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes CONTROL_VM  disk messages from enum since they
are completely unused.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/common-spar/include/channels/controlvmchannel.h   | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index ff15c45..cd15409 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -88,11 +88,6 @@ enum controlvm_id {
 	CONTROLVM_DEVICE_CHANGESTATE = 0x204,	/* CP --> SP, GP */
 	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */
 	CONTROLVM_DEVICE_RECONFIGURE = 0x206,	/* CP --> Boot */
-/* DISK commands required Parameter: BusNumber, DeviceNumber  */
-	CONTROLVM_DISK_CREATE = 0x221,	/* CP --> SP */
-	CONTROLVM_DISK_DESTROY = 0x222,	/* CP --> SP */
-	CONTROLVM_DISK_CONFIGURE = 0x223,	/* CP --> SP */
-	CONTROLVM_DISK_CHANGESTATE = 0x224,	/* CP --> SP */
 /* CHIPSET commands */
 	CONTROLVM_CHIPSET_INIT = 0x301,	/* CP --> SP, GP */
 	CONTROLVM_CHIPSET_STOP = 0x302,	/* CP --> SP, GP */
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 064/141] staging: unisys: rename variable to reserverd since it is unused
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (62 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 063/141] staging: unisys: remove unused CONTROL_VM messages from enum Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 065/141] staging: unisys: controlvmchannel.h comment aligment and cleanup Benjamin Romer
                   ` (79 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch renames send_irq_handle to reserved1 since this variable
is unused in the guest side.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index cd15409..d3c1aab 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -106,7 +106,7 @@ struct irq_info {
 	  *   interrupt.  Currently this is used by IOPart-SP to wake
 	  *   up GP when Data Channel transitions from empty to
 	  *   non-empty.*/
-	u64 send_irq_handle;
+	u64 reserved1;
 
 	 /**< specifies interrupt handle. It is used to retrieve the
 	  *   corresponding interrupt pin from Monitor; and the
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 065/141] staging: unisys: controlvmchannel.h comment aligment and cleanup
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (63 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 064/141] staging: unisys: rename variable to reserverd since it is unused Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 066/141] staging: unisys: remove unused device_map and guest_devices struct Benjamin Romer
                   ` (78 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch is a comment aligment and cleanup for
controlvmchannel.h.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../include/channels/controlvmchannel.h            | 231 ++++++++++-----------
 1 file changed, 107 insertions(+), 124 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index d3c1aab..8830d70 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -23,20 +23,21 @@
 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID	\
 		UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
-				0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
+			0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
 
 static const uuid_le spar_controlvm_channel_protocol_uuid =
 	SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
 
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
 	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-#define CONTROLVM_MESSAGE_MAX     64
+#define CONTROLVM_MESSAGE_MAX 64
 
 /* Must increment this whenever you insert or delete fields within
-* this channel struct.  Also increment whenever you change the meaning
-* of fields within this channel struct so as to break pre-existing
-* software.  Note that you can usually add fields to the END of the
-* channel struct withOUT needing to increment this. */
+ * this channel struct.  Also increment whenever you change the meaning
+ * of fields within this channel struct so as to break pre-existing
+ * software.  Note that you can usually add fields to the END of the
+ * channel struct withOUT needing to increment this.
+ */
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
 
 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
@@ -49,17 +50,16 @@ static const uuid_le spar_controlvm_channel_protocol_uuid =
 
 #define MAX_SERIAL_NUM	32
 
-/* Defines for various channel queues... */
+/* Defines for various channel queues */
 #define CONTROLVM_QUEUE_REQUEST		0
 #define CONTROLVM_QUEUE_RESPONSE	1
-#define	CONTROLVM_QUEUE_EVENT		2
+#define CONTROLVM_QUEUE_EVENT		2
 #define CONTROLVM_QUEUE_ACK		3
 
-/* Max number of messages stored during IOVM creation to be reused
- * after crash */
+/* Max num of messages stored during IOVM creation to be reused after crash */
 #define CONTROLVM_CRASHMSG_MAX		2
 
-/** Ids for commands that may appear in either queue of a ControlVm channel.
+/* Ids for commands that may appear in either queue of a ControlVm channel.
  *
  *  Commands that are initiated by the command partition (CP), by an IO or
  *  console service partition (SP), or by a guest partition (GP)are:
@@ -73,55 +73,50 @@ static const uuid_le spar_controlvm_channel_protocol_uuid =
  */
 enum controlvm_id {
 	CONTROLVM_INVALID = 0,
-	/* SWITCH commands required Parameter: SwitchNumber  */
-	/* BUS commands required Parameter: BusNumber  */
-	CONTROLVM_BUS_CREATE = 0x101,	/* CP --> SP, GP */
-	CONTROLVM_BUS_DESTROY = 0x102,	/* CP --> SP, GP */
-	CONTROLVM_BUS_CONFIGURE = 0x104,	/* CP --> SP */
-	CONTROLVM_BUS_CHANGESTATE = 0x105,	/* CP --> SP, GP */
-	CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */
-/* DEVICE commands required Parameter: BusNumber, DeviceNumber  */
-
-	CONTROLVM_DEVICE_CREATE = 0x201,	/* CP --> SP, GP */
-	CONTROLVM_DEVICE_DESTROY = 0x202,	/* CP --> SP, GP */
-	CONTROLVM_DEVICE_CONFIGURE = 0x203,	/* CP --> SP */
-	CONTROLVM_DEVICE_CHANGESTATE = 0x204,	/* CP --> SP, GP */
-	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */
-	CONTROLVM_DEVICE_RECONFIGURE = 0x206,	/* CP --> Boot */
+	/* SWITCH commands required Parameter: SwitchNumber */
+	/* BUS commands required Parameter: BusNumber */
+	CONTROLVM_BUS_CREATE = 0x101,			/* CP --> SP, GP */
+	CONTROLVM_BUS_DESTROY = 0x102,			/* CP --> SP, GP */
+	CONTROLVM_BUS_CONFIGURE = 0x104,		/* CP --> SP */
+	CONTROLVM_BUS_CHANGESTATE = 0x105,		/* CP --> SP, GP */
+	CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106,	/* SP, GP --> CP */
+/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
+
+	CONTROLVM_DEVICE_CREATE = 0x201,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_DESTROY = 0x202,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_CONFIGURE = 0x203,		/* CP --> SP */
+	CONTROLVM_DEVICE_CHANGESTATE = 0x204,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205,	/* SP, GP --> CP */
+	CONTROLVM_DEVICE_RECONFIGURE = 0x206,		/* CP --> Boot */
 /* CHIPSET commands */
-	CONTROLVM_CHIPSET_INIT = 0x301,	/* CP --> SP, GP */
-	CONTROLVM_CHIPSET_STOP = 0x302,	/* CP --> SP, GP */
-	CONTROLVM_CHIPSET_SHUTDOWN = 0x303,	/* CP --> SP */
-	CONTROLVM_CHIPSET_READY = 0x304,	/* CP --> SP */
-	CONTROLVM_CHIPSET_SELFTEST = 0x305,	/* CP --> SP */
+	CONTROLVM_CHIPSET_INIT = 0x301,			/* CP --> SP, GP */
+	CONTROLVM_CHIPSET_STOP = 0x302,			/* CP --> SP, GP */
+	CONTROLVM_CHIPSET_SHUTDOWN = 0x303,		/* CP --> SP */
+	CONTROLVM_CHIPSET_READY = 0x304,		/* CP --> SP */
+	CONTROLVM_CHIPSET_SELFTEST = 0x305,		/* CP --> SP */
 
 };
 
 struct irq_info {
-	 /**< specifies interrupt info. It is used to send interrupts
-	  *   for this channel. The peer at the end of this channel
-	  *   who has registered an interrupt (using recv fields
-	  *   above) will receive the interrupt. Passed as a parameter
-	  *   to Issue_VMCALL_IO_QUEUE_TRANSITION, which generates the
-	  *   interrupt.  Currently this is used by IOPart-SP to wake
-	  *   up GP when Data Channel transitions from empty to
-	  *   non-empty.*/
 	u64 reserved1;
 
-	 /**< specifies interrupt handle. It is used to retrieve the
+	 /* specifies interrupt handle. It is used to retrieve the
 	  *   corresponding interrupt pin from Monitor; and the
 	  *   interrupt pin is used to connect to the corresponding
-	  *   interrupt.  Used by IOPart-GP only. */
+	  *   interrupt.  Used by IOPart-GP only.
+	  */
 	u64 recv_irq_handle;
 
-	 /**< specifies interrupt vector. It, interrupt pin, and shared are
+	 /* specifies interrupt vector. It, interrupt pin, and shared are
 	  *   used to connect to the corresponding interrupt.  Used by
-	  *   IOPart-GP only. */
+	  *   IOPart-GP only.
+	  */
 	u32 recv_irq_vector;
 
-    /**< specifies if the recvInterrupt is shared.  It, interrupt pin
-     *   and vector are used to connect to 0 = not shared; 1 = shared.
-     *   the corresponding interrupt.  Used by IOPart-GP only. */
+    /* specifies if the recvInterrupt is shared.  It, interrupt pin
+     * and vector are used to connect to 0 = not shared; 1 = shared.
+     * the corresponding interrupt.  Used by IOPart-GP only.
+     */
 	u8 recv_irq_shared;
 	u8 reserved[3];	/* Natural alignment purposes */
 };
@@ -135,10 +130,10 @@ struct pci_id {
 };
 
 struct efi_spar_indication  {
-	u64 boot_to_fw_ui:1;	/* Bit 0: Stop in uefi ui */
-	u64 clear_nvram:1;	/* Bit 1: Clear NVRAM */
-	u64 clear_cmos:1;	/* Bit 2: Clear CMOS */
-	u64 boot_to_tool:1;	/* Bit 3: Run install tool */
+	u64 boot_to_fw_ui:1;		/* Bit 0: Stop in uefi ui */
+	u64 clear_nvram:1;		/* Bit 1: Clear NVRAM */
+	u64 clear_cmos:1;		/* Bit 2: Clear CMOS */
+	u64 boot_to_tool:1;		/* Bit 3: Run install tool */
 	/* remaining bits are available */
 };
 
@@ -148,7 +143,7 @@ enum ultra_chipset_feature {
 	ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004
 };
 
-/** This is the common structure that is at the beginning of every
+/* This is the common structure that is at the beginning of every
  *  ControlVm message (both commands and responses) in any ControlVm
  *  queue.  Commands are easily distinguished from responses by
  *  looking at the flags.response field.
@@ -165,26 +160,26 @@ struct controlvm_message_header  {
 	u32 completion_status;	/* Error status code or result of
 				 * message completion */
 	struct  {
-		u32 failed:1;		   /**< =1 in a response to * signify
+		u32 failed:1;		   /* =1 in a response to * signify
 					    * failure */
-		u32 response_expected:1;   /**< =1 in all messages that expect a
-					   * response (Control ignores this
-					   * bit) */
-		u32 server:1;		   /**< =1 in all bus & device-related
+		u32 response_expected:1;   /* =1 in all messages that expect a
+					    * response (Control ignores this
+					    * bit) */
+		u32 server:1;		   /* =1 in all bus & device-related
 					    * messages where the message
 					    * receiver is to act as the bus or
 					    * device server */
-		u32 test_message:1;	   /**< =1 for testing use only
+		u32 test_message:1;	   /* =1 for testing use only
 					    * (Control and Command ignore this
 					    * bit) */
-		u32 partial_completion:1;  /**< =1 if there are forthcoming
-					   * responses/acks associated
-					   * with this message */
-		u32 preserve:1;	       /**< =1 this is to let us know to
-					* preserve channel contents
-					* (for running guests)*/
-		u32 writer_in_diag:1;	/**< =1 the DiagWriter is active in the
-					 * Diagnostic Partition*/
+		u32 partial_completion:1;  /* =1 if there are forthcoming
+					    * responses/acks associated
+					    * with this message */
+		u32 preserve:1;		   /* =1 this is to let us know to
+					    * preserve channel contents
+					    * (for running guests)*/
+		u32 writer_in_diag:1;	   /* =1 the DiagWriter is active in the
+					    * Diagnostic Partition*/
 	} flags;
 	u32 reserved;		/* Natural alignment */
 	u64 message_handle;	/* Identifies the particular message instance,
@@ -200,8 +195,8 @@ struct controlvm_message_header  {
 };
 
 struct controlvm_packet_device_create  {
-	u32 bus_no;	/* bus # (0..n-1) from the msg receiver's end */
-	u32 dev_no;	/* bus-relative (0..n-1) device number */
+	u32 bus_no;		/* bus # (0..n-1) from the msg receiver's end */
+	u32 dev_no;		/* bus-relative (0..n-1) device number */
 	u64 channel_addr;	/* Guest physical address of the channel, which
 				 * can be dereferenced by the receiver of this
 				 * ControlVm command */
@@ -212,11 +207,10 @@ struct controlvm_packet_device_create  {
 };	/* for CONTROLVM_DEVICE_CREATE */
 
 struct controlvm_packet_device_configure  {
-	u32 bus_no;	      /**< bus # (0..n-1) from the msg
+	u32 bus_no;	      /* bus # (0..n-1) from the msg
 			       * receiver's perspective */
-
-	    /* Control uses header SegmentIndex field to access bus number... */
-	u32 dev_no;	      /**< bus-relative (0..n-1) device number */
+	/* Control uses header SegmentIndex field to access bus number... */
+	u32 dev_no;	      /* bus-relative (0..n-1) device number */
 } ;	/* for CONTROLVM_DEVICE_CONFIGURE */
 
 struct controlvm_message_device_create {
@@ -334,7 +328,7 @@ struct device_map {
 	u64 reserved2;		/* Align structure on 32-byte boundary */
 };
 
-struct guest_devices  {
+struct guest_devices {
 	struct device_map video_channel;
 	struct device_map keyboard_channel;
 	struct device_map network_channel;
@@ -345,58 +339,47 @@ struct guest_devices  {
 };
 
 struct spar_controlvm_channel_protocol {
-	 struct channel_header header;
-	 u64 gp_controlvm;	/* guest physical address of
-						 * this channel */
-	 u64 gp_partition_tables;/* guest physical address of
-						     * partition tables */
-	 u64 gp_diag_guest;	/* guest physical address of
-						 * diagnostic channel */
-	 u64 gp_boot_romdisk;/* guest phys addr of (read
-						 * only) Boot ROM disk */
-	 u64 gp_boot_ramdisk;/* guest phys addr of writable
-						 * Boot RAM disk */
-	 u64 gp_acpi_table;	/* guest phys addr of acpi
-						 * table */
-	 u64 gp_control_channel;/* guest phys addr of control
-						    * channel */
-	 u64 gp_diag_romdisk;/* guest phys addr of diagnostic
-						 * ROM disk */
-	 u64 gp_nvram;	/* guest phys addr of NVRAM
-						 * channel */
-	 u64 request_payload_offset;	/* Offset to request payload area */
-	 u64 event_payload_offset;	/* Offset to event payload area */
-	 u32 request_payload_bytes;	/* Bytes available in request payload
+	struct channel_header header;
+	u64 gp_controlvm;	/* guest phys addr of this channel */
+	u64 gp_partition_tables;/* guest phys addr of partition tables */
+	u64 gp_diag_guest;	/* guest phys addr of diagnostic channel */
+	u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */
+	u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */
+	u64 gp_acpi_table;	/* guest phys addr of acpi table */
+	u64 gp_control_channel;/* guest phys addr of control channel */
+	u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */
+	u64 gp_nvram;	/* guest phys addr of NVRAM channel */
+	u64 request_payload_offset;	/* Offset to request payload area */
+	u64 event_payload_offset;	/* Offset to event payload area */
+	u32 request_payload_bytes;	/* Bytes available in request payload
 					 * area */
-	 u32 event_payload_bytes;/* Bytes available in event payload area */
-	 u32 control_channel_bytes;
-	 u32 nvram_channel_bytes;	/* Bytes in PartitionNvram segment */
-	 u32 message_bytes;	/* sizeof(CONTROLVM_MESSAGE) */
-	 u32 message_count;	/* CONTROLVM_MESSAGE_MAX */
-	 u64 gp_smbios_table;/* guest phys addr of SMBIOS
-						 * tables */
-	 u64 gp_physical_smbios_table;/* guest phys addr of
-							  * SMBIOS table  */
-	 /* ULTRA_MAX_GUESTS_PER_SERVICE */
-	 struct guest_devices gp_obsolete_guest_devices[16];
-
-	 /* guest physical address of EFI firmware image base  */
-	 u64 virtual_guest_firmware_image_base;
-
-	 /* guest physical address of EFI firmware entry point  */
-	 u64 virtual_guest_firmware_entry_point;
-
-	 /* guest EFI firmware image size  */
-	 u64 virtual_guest_firmware_image_size;
-
-	 /* GPA = 1MB where EFI firmware image is copied to  */
-	 u64 virtual_guest_firmware_boot_base;
-	 u64 virtual_guest_image_base;
-	 u64 virtual_guest_image_size;
-	 u64 prototype_control_channel_offset;
-	 u64 virtual_guest_partition_handle;
-
-	 u16 restore_action;	/* Restore Action field to restore the guest
+	u32 event_payload_bytes;/* Bytes available in event payload area */
+	u32 control_channel_bytes;
+	u32 nvram_channel_bytes;	/* Bytes in PartitionNvram segment */
+	u32 message_bytes;		/* sizeof(CONTROLVM_MESSAGE) */
+	u32 message_count;		/* CONTROLVM_MESSAGE_MAX */
+	u64 gp_smbios_table;		/* guest phys addr of SMBIOS tables */
+	u64 gp_physical_smbios_table;	/* guest phys addr of SMBIOS table  */
+	/* ULTRA_MAX_GUESTS_PER_SERVICE */
+	struct guest_devices gp_obsolete_guest_devices[16];
+
+	/* guest physical address of EFI firmware image base  */
+	u64 virtual_guest_firmware_image_base;
+
+	/* guest physical address of EFI firmware entry point  */
+	u64 virtual_guest_firmware_entry_point;
+
+	/* guest EFI firmware image size  */
+	u64 virtual_guest_firmware_image_size;
+
+	/* GPA = 1MB where EFI firmware image is copied to  */
+	u64 virtual_guest_firmware_boot_base;
+	u64 virtual_guest_image_base;
+	u64 virtual_guest_image_size;
+	u64 prototype_control_channel_offset;
+	u64 virtual_guest_partition_handle;
+
+	u16 restore_action;	/* Restore Action field to restore the guest
 				 * partition */
 	u16 dump_action;	/* For Windows guests it shows if the visordisk
 				 * is running in dump mode */
@@ -446,7 +429,7 @@ struct spar_controlvm_channel_protocol {
 	 struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
 };
 
-/* Offsets for VM channel attributes... */
+/* Offsets for VM channel attributes */
 #define VM_CH_REQ_QUEUE_OFFSET \
 	offsetof(struct spar_controlvm_channel_protocol, request_queue)
 #define VM_CH_RESP_QUEUE_OFFSET \
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 066/141] staging: unisys: remove unused device_map and guest_devices struct
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (64 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 065/141] staging: unisys: controlvmchannel.h comment aligment and cleanup Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 067/141] staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN Benjamin Romer
                   ` (77 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes unused struct in the controlvm_channel message
and replaces it with a char reserved inorder to mantain same
message size.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/controlvmchannel.h  | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index 8830d70..045c922 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -320,24 +320,6 @@ struct controlvm_message {
 	struct controlvm_message_packet cmd;
 };
 
-struct device_map {
-	u64 device_channel_address;
-	u64 device_channel_size;
-	u32 ca_index;
-	u32 reserved;		/* natural alignment */
-	u64 reserved2;		/* Align structure on 32-byte boundary */
-};
-
-struct guest_devices {
-	struct device_map video_channel;
-	struct device_map keyboard_channel;
-	struct device_map network_channel;
-	struct device_map storage_channel;
-	struct device_map console_channel;
-	u32 partition_index;
-	u32 pad;
-};
-
 struct spar_controlvm_channel_protocol {
 	struct channel_header header;
 	u64 gp_controlvm;	/* guest phys addr of this channel */
@@ -361,7 +343,7 @@ struct spar_controlvm_channel_protocol {
 	u64 gp_smbios_table;		/* guest phys addr of SMBIOS tables */
 	u64 gp_physical_smbios_table;	/* guest phys addr of SMBIOS table  */
 	/* ULTRA_MAX_GUESTS_PER_SERVICE */
-	struct guest_devices gp_obsolete_guest_devices[16];
+	char gp_reserved[2688];
 
 	/* guest physical address of EFI firmware image base  */
 	u64 virtual_guest_firmware_image_base;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 067/141] staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (65 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 066/141] staging: unisys: remove unused device_map and guest_devices struct Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 068/141] staging: unisys: remove unused chipset feature PCIVBUS Benjamin Romer
                   ` (76 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

this patch removes unused chipset command on the guest
CONTROLVM_CHIPSET_SHUTDOWN

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index 045c922..a15095c 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -91,7 +91,6 @@ enum controlvm_id {
 /* CHIPSET commands */
 	CONTROLVM_CHIPSET_INIT = 0x301,			/* CP --> SP, GP */
 	CONTROLVM_CHIPSET_STOP = 0x302,			/* CP --> SP, GP */
-	CONTROLVM_CHIPSET_SHUTDOWN = 0x303,		/* CP --> SP */
 	CONTROLVM_CHIPSET_READY = 0x304,		/* CP --> SP */
 	CONTROLVM_CHIPSET_SELFTEST = 0x305,		/* CP --> SP */
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 068/141] staging: unisys: remove unused chipset feature PCIVBUS
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (66 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 067/141] staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 069/141] staging: unisys: remove unused #define in iochannel.h Benjamin Romer
                   ` (75 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes unused chipset feature
ULTRA_CHIPSET_FEATURE_PCIVBUS

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index a15095c..d8ed52e 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -139,7 +139,6 @@ struct efi_spar_indication  {
 enum ultra_chipset_feature {
 	ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
 	ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
-	ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004
 };
 
 /* This is the common structure that is at the beginning of every
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 069/141] staging: unisys: remove unused #define in iochannel.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (67 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 068/141] staging: unisys: remove unused chipset feature PCIVBUS Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 070/141] staging: unisys: cleanup and align iochannel.h comments Benjamin Romer
                   ` (74 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch simply remove all unused #define's in iochannel.h

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/iochannel.h       | 137 ---------------------
 1 file changed, 137 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
index ff393c2..fad7fe9 100644
--- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
@@ -86,41 +86,10 @@
  * ioguestparts */
 #define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to
 			    * iopart */
-#define IOCHAN_FROM_GUESTPART 0 /* used by iopart to 'remove' signals from
-				 * ioguestpart - same queue as previous queue */
 
-#define IOCHAN_TO_GUESTPART 1 /* used by iopart to 'insert' signals to
-			       * ioguestpart */
 #define IOCHAN_FROM_IOPART 1 /* used by ioguestpart to 'remove' signals from
 			      * iopart - same queue as previous queue */
 
-/* these define the two queues per control channel between controlpart and "its"
- * guests, which includes the iopart  */
-#define CTRLCHAN_TO_CTRLGUESTPART 0 /* used by ctrlguestpart to 'insert' signals
-				     * to ctrlpart */
-#define CTLRCHAN_FROM_CTRLPART 0 /* used by ctrlpart to 'remove' signals from
-				  * ctrlquestpart - same queue as previous
-				  * queue */
-
-#define CTRLCHAN_TO_CTRLPART 1 /* used by ctrlpart to 'insert' signals to
-				* ctrlguestpart */
-#define CTRLCHAN_FROM_CTRLGUESTPART 1 /* used by ctrguestpart to 'remove'
-				       * signals from ctrlpart - same queue as
-				       * previous queue */
-
-/* these define the Event & Ack queues per control channel Events are generated
-* by CTRLGUESTPART and sent to CTRLPART; Acks are generated by CTRLPART and sent
-* to CTRLGUESTPART. */
-#define CTRLCHAN_EVENT_TO_CTRLPART 2 /* used by ctrlguestpart to 'insert' Events
-				      * to ctrlpart */
-#define CTRLCHAN_EVENT_FROM_CTRLGUESTPART 2 /* used by ctrlpart to 'remove'
-					     * Events from ctrlguestpart */
-
-#define CTRLCHAN_ACK_TO_CTRLGUESTPART 3	/* used by ctrlpart to 'insert' Acks to
-					 * ctrlguestpart */
-#define CTRLCHAN_ACK_FROM_CTRLPART 3 /* used by ctrlguestpart to 'remove' Events
-				      * from ctrlpart */
-
 /* size of cdb - i.e., scsi cmnd */
 #define MAX_CMND_SIZE 16
 
@@ -128,24 +97,6 @@
 
 #define MAX_PHYS_INFO 64
 
-/* Because GuestToGuestCopy is limited to 4KiB segments, and we have limited the
-* Emulex Driver to 256 scatter list segments via the lpfc_sg_seg_cnt parameter
-* to 256, the maximum I/O size is limited to 256 * 4 KiB = 1 MB */
-#define MAX_IO_SIZE   (1024*1024)	/* 1 MB */
-
-/* NOTE 1: lpfc defines its support for segments in
-* #define LPFC_SG_SEG_CNT 64
-*
-* NOTE 2: In Linux, frags array in skb is currently allocated to be
-* MAX_SKB_FRAGS size, which is 18 which is smaller than MAX_PHYS_INFO for
-* now.  */
-
-#define MAX_SCSI_BUSES		1
-#define MAX_SCSI_TARGETS	8
-#define MAX_SCSI_LUNS		16
-#define MAX_SCSI_FROM_HOST	0xFFFFFFFF	/* Indicator to use Physical HBA
-						 * SCSI Host value */
-
 /* various types of network packets that can be sent in cmdrsp */
 enum net_types {
 	NET_RCV_POST = 0,	/* submit buffer to hold receiving
@@ -178,19 +129,12 @@ enum net_types {
 #define		ETH_MIN_DATA_SIZE 46	/* minimum eth data size */
 #define		ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE)
 
-#define     ETH_DEF_DATA_SIZE 1500	/* default data size */
-#define     ETH_DEF_PACKET_SIZE (ETH_HEADER_SIZE + ETH_DEF_DATA_SIZE)
-
 #define		ETH_MAX_MTU 16384	/* maximum data size */
 
 #ifndef MAX_MACADDR_LEN
 #define MAX_MACADDR_LEN 6	/* number of bytes in MAC address */
 #endif				/* MAX_MACADDR_LEN */
 
-#define ETH_IS_LOCALLY_ADMINISTERED(address) \
-	(((u8 *)(address))[0] & ((u8)0x02))
-#define NIC_VENDOR_ID 0x0008000B
-
 /* various types of scsi task mgmt commands  */
 enum task_mgmt_types {
 	TASK_MGMT_ABORT_TASK = 1,
@@ -205,20 +149,6 @@ enum vdisk_mgmt_types {
 	VDISK_MGMT_RELEASE,
 };
 
-/* this is used in the vdest field  */
-#define VDEST_ALL 0xFFFF
-
-#define MIN_NUMSIGNALS 64
-#define MAX_NUMSIGNALS 4096
-
-/* MAX_NET_RCV_BUF specifies the number of rcv buffers that are created by each
-* guest's virtnic and posted to uisnic.  Uisnic, for each channel, keeps the rcv
-* buffers posted and uses them to receive data on behalf of the guest's virtnic.
-* NOTE: the num_rcv_bufs is configurable for each VNIC. So the following is
-* simply an upperlimit on what each VNIC can provide.  Setting it to half of the
-* NUMSIGNALS to prevent queue full deadlocks */
-#define MAX_NET_RCV_BUFS (MIN_NUMSIGNALS / 2)
-
 /*
  * structs with pragma pack  */
 
@@ -283,13 +213,7 @@ struct uiscmdrsp_scsi {
 	u8 scsistat;		/* the scsi status */
 	u8 addlstat;		/* non-scsi status - covers cases like timeout
 				 * needed by windows guests */
-#define ADDL_RESET		1
-#define ADDL_TIMEOUT		2
-#define ADDL_INTERNAL_ERROR	3
 #define ADDL_SEL_TIMEOUT	4
-#define ADDL_CMD_TIMEOUT	5
-#define ADDL_BAD_TARGET		6
-#define ADDL_RETRY		7
 
 	/* the following fields are need to determine the result of command */
 	 u8 sensebuf[MAX_SENSE_SIZE];	/* sense info in case cmd failed; */
@@ -320,7 +244,6 @@ struct uiscmdrsp_scsi {
  *connected to this logical unit.
  */
 
-#define DEV_NOT_PRESENT 0x7f	/* old name - compatibility */
 #define DEV_NOT_CAPABLE 0x7f	/* peripheral qualifier of 0x3  */
     /* peripheral type of 0x1f */
     /* specifies no device but target present */
@@ -329,10 +252,6 @@ struct uiscmdrsp_scsi {
     /* peripheral type of 0 - disk */
     /* specifies device capable, but not present */
 
-#define DEV_PROC_CAPABLE_NOT_PRESENT 0x23 /* peripheral qualifier of 0x1 */
-    /* peripheral type of 3 - processor */
-    /* specifies device capable, but not present */
-
 #define DEV_HISUPPORT 0x10	/* HiSup = 1; shows support for report luns */
     /* must be returned for lun 0. */
 
@@ -423,37 +342,6 @@ struct sense_data {
 	u8 sense_key_specific[3];
 };
 
-/* some SCSI ADSENSE codes */
-#ifndef SCSI_ADSENSE_LUN_NOT_READY
-#define SCSI_ADSENSE_LUN_NOT_READY 0x04
-#endif	/*  */
-#ifndef SCSI_ADSENSE_ILLEGAL_COMMAND
-#define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
-#endif	/*  */
-#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK
-#endif	/*  */
-#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK
-#define SCSI_ADSENSE_ILLEGAL_BLOCK  0x21
-#endif	/*  */
-#ifndef SCSI_ADSENSE_INVALID_CDB
-#define SCSI_ADSENSE_INVALID_CDB    0x24
-#endif	/*  */
-#ifndef SCSI_ADSENSE_INVALID_LUN
-#define SCSI_ADSENSE_INVALID_LUN    0x25
-#endif	/*  */
-#ifndef SCSI_ADWRITE_PROTECT
-#define SCSI_ADWRITE_PROTECT        0x27
-#endif	/*  */
-#ifndef SCSI_ADSENSE_MEDIUM_CHANGED
-#define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
-#endif	/*  */
-#ifndef SCSI_ADSENSE_BUS_RESET
-#define SCSI_ADSENSE_BUS_RESET      0x29
-#endif	/*  */
-#ifndef SCSI_ADSENSE_NO_MEDIA_IN_DEVICE
-#define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
-#endif	/*  */
-
 struct net_pkt_xmt {
 	int len;	/* full length of data in the packet */
 	int num_frags;	/* number of fragments in frags containing data */
@@ -484,8 +372,6 @@ struct net_pkt_xmt {
 
 struct net_pkt_xmtdone {
 	u32 xmt_done_result;	/* result of NET_XMIT */
-#define XMIT_SUCCESS 0
-#define XMIT_FAILED 1
 };
 
 /* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The
@@ -582,7 +468,6 @@ struct uiscmdrsp_scsitaskmgmt {
 
 	    /* result of taskmgmt command - set by IOPart - values are: */
 #define TASK_MGMT_FAILED  0
-#define TASK_MGMT_SUCCESS 1
 };
 
 /* The following is used by uissd to send disk add/remove notifications to
@@ -629,7 +514,6 @@ struct uiscmdrsp_vdiskmgmt {
 
 	    /* result of taskmgmt command - set by IOPart - values are: */
 #define VDISK_MGMT_FAILED  0
-#define VDISK_MGMT_SUCCESS 1
 };
 
 /* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */
@@ -684,26 +568,6 @@ struct spar_io_channel_protocol {
 #pragma pack(pop)
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
 
-/* define offsets to members of struct uiscmdrsp */
-#define OFFSET_CMDTYPE offsetof(struct uiscmdrsp, cmdtype)
-#define OFFSET_SCSI offsetof(struct uiscmdrsp, scsi)
-#define OFFSET_NET offsetof(struct uiscmdrsp, net)
-#define OFFSET_SCSITASKMGMT offsetof(struct uiscmdrsp, scsitaskmgmt)
-#define OFFSET_NEXT offsetof(struct uiscmdrsp, next)
-
-/* define offsets to members of struct uiscmdrsp_net */
-#define OFFSET_TYPE offsetof(struct uiscmdrsp_net, type)
-#define OFFSET_BUF offsetof(struct uiscmdrsp_net, buf)
-#define OFFSET_XMT offsetof(struct uiscmdrsp_net, xmt)
-#define OFFSET_XMT_DONE_RESULT offsetof(struct uiscmdrsp_net, xmtdone)
-#define OFFSET_RCVPOST offsetof(struct uiscmdrsp_net, rcvpost)
-#define OFFSET_RCV_DONE_LEN offsetof(struct uiscmdrsp_net, rcv)
-#define OFFSET_ENBDIS offsetof(struct uiscmdrsp_net, enbdis)
-
-/* define offsets to members of struct net_pkt_rcvpost */
-#define OFFSET_TOTALLEN offsetof(struct net_pkt_rcvpost, totallen)
-#define	OFFSET_FRAG offsetof(struct net_pkt_rcvpost, frag)
-
 /*
 * INLINE functions for initializing and accessing I/O data channels
 */
@@ -724,7 +588,6 @@ struct spar_io_channel_protocol {
 /* Guest and IOPartition. */
 #define PI_PAGE_SIZE  0x1000
 #define PI_PAGE_MASK  0x0FFF
-#define PI_PAGE_SHIFT 12
 
 /* returns next non-zero index on success or zero on failure (i.e. out of
  * room)
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 070/141] staging: unisys: cleanup and align iochannel.h comments
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (68 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 069/141] staging: unisys: remove unused #define in iochannel.h Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 071/141] staging: unisys: get rid of serialloopbacktest Benjamin Romer
                   ` (73 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch reorganizes, aligns, and corrects grammar mistakes on
comments.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/iochannel.h       | 240 +++++++++++----------
 1 file changed, 124 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
index fad7fe9..cbb5875 100644
--- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
@@ -4,29 +4,29 @@
 #define __IOCHANNEL_H__
 
 /*
-* Everything needed for IOPart-GuestPart communication is define in
-* this file.  Note: Everything is OS-independent because this file is
-* used by Windows, Linux and possible EFI drivers.  */
+ * Everything needed for IOPart-GuestPart communication is define in
+ * this file.  Note: Everything is OS-independent because this file is
+ * used by Windows, Linux and possible EFI drivers.  */
 
 /*
-* Communication flow between the IOPart and GuestPart uses the channel headers
-* channel state.  The following states are currently being used:
-*       UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
-*
-* additional states will be used later.  No locking is needed to switch between
-* states due to the following rules:
-*
-*      1.  IOPart is only the only partition allowed to change from UNIT
-*      2.  IOPart is only the only partition allowed to change from
-*		CHANNEL_ATTACHING
-*      3.  GuestPart is only the only partition allowed to change from
-*		CHANNEL_ATTACHED
-*
-* The state changes are the following: IOPart sees the channel is in UNINIT,
-*        UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
-*        CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
-*        CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
-*/
+ * Communication flow between the IOPart and GuestPart uses the channel headers
+ * channel state.  The following states are currently being used:
+ *       UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
+ *
+ * additional states will be used later.  No locking is needed to switch between
+ * states due to the following rules:
+ *
+ *      1.  IOPart is only the only partition allowed to change from UNIT
+ *      2.  IOPart is only the only partition allowed to change from
+ *		CHANNEL_ATTACHING
+ *      3.  GuestPart is only the only partition allowed to change from
+ *		CHANNEL_ATTACHED
+ *
+ * The state changes are the following: IOPart sees the channel is in UNINIT,
+ *        UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
+ *        CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
+ *        CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
+ */
 
 #include <linux/uuid.h>
 
@@ -38,11 +38,6 @@
 #include "vbuschannel.h"
 #undef _ULTRA_CONTROLVM_CHANNEL_INLINE_
 #include "channel.h"
-
-/*
- * CHANNEL Guids
- */
-
 #include "channel_guid.h"
 
 #define ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
@@ -51,10 +46,11 @@
 	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
 
 /* Must increment these whenever you insert or delete fields within this channel
-* struct.  Also increment whenever you change the meaning of fields within this
-* channel struct so as to break pre-existing software.  Note that you can
-* usually add fields to the END of the channel struct withOUT needing to
-* increment this. */
+ * struct.  Also increment whenever you change the meaning of fields within this
+ * channel struct so as to break pre-existing software.  Note that you can
+ * usually add fields to the END of the channel struct withOUT needing to
+ * increment this.
+ */
 #define ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID 2
 #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
@@ -72,18 +68,20 @@
 				   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
 
 /*
-* Everything necessary to handle SCSI & NIC traffic between Guest Partition and
-* IO Partition is defined below.  */
+ * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
+ * IO Partition is defined below.
+ */
 
 /*
-* Defines and enums.
-*/
+ * Defines and enums.
+ */
 
 #define MINNUM(a, b) (((a) < (b)) ? (a) : (b))
 #define MAXNUM(a, b) (((a) > (b)) ? (a) : (b))
 
 /* these define the two queues per data channel between iopart and
- * ioguestparts */
+ * ioguestparts
+ */
 #define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to
 			    * iopart */
 
@@ -120,7 +118,7 @@ enum net_types {
 	/* uisnic -> virtnic */
 	NET_MACADDR,		/* indicates the client has requested to update
 				 * its MAC addr */
-	NET_MACADDR_ACK,	/* MAC address  */
+	NET_MACADDR_ACK,	/* MAC address */
 
 };
 
@@ -149,8 +147,7 @@ enum vdisk_mgmt_types {
 	VDISK_MGMT_RELEASE,
 };
 
-/*
- * structs with pragma pack  */
+/* structs with pragma pack  */
 
 /* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
 /* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
@@ -221,17 +218,19 @@ struct uiscmdrsp_scsi {
 	/* see that struct for details. */
 	void *vdisk; /* contains pointer to the vdisk so that we can clean up
 		      * when the IO completes. */
-	int no_disk_result;	/* used to return no disk inquiry result */
-	/* when no_disk_result is set to 1,  */
-	/* scsi.scsistat is SAM_STAT_GOOD */
-	/* scsi.addlstat is 0 */
-	/* scsi.linuxstat is SAM_STAT_GOOD */
-	/* That is, there is NO error. */
+	int no_disk_result;
+	/* used to return no disk inquiry result
+	 * when no_disk_result is set to 1,
+	 * scsi.scsistat is SAM_STAT_GOOD
+	 * scsi.addlstat is 0
+	 * scsi.linuxstat is SAM_STAT_GOOD
+	 * That is, there is NO error.
+	 */
 };
 
-/*
-* Defines to support sending correct inquiry result when no disk is
-* configured.  */
+/* Defines to support sending correct inquiry result when no disk is
+ * configured.
+ */
 
 /* From SCSI SPC2 -
  *
@@ -245,20 +244,21 @@ struct uiscmdrsp_scsi {
  */
 
 #define DEV_NOT_CAPABLE 0x7f	/* peripheral qualifier of 0x3  */
-    /* peripheral type of 0x1f */
-    /* specifies no device but target present */
+				/* peripheral type of 0x1f */
+				/* specifies no device but target present */
 
 #define DEV_DISK_CAPABLE_NOT_PRESENT 0x20 /* peripheral qualifier of 0x1 */
     /* peripheral type of 0 - disk */
     /* specifies device capable, but not present */
 
 #define DEV_HISUPPORT 0x10	/* HiSup = 1; shows support for report luns */
-    /* must be returned for lun 0. */
+				/* must be returned for lun 0. */
 
 /* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
-* in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
-* & revision.  Yikes! So let us always send back 36 bytes, the minimum for
-* inquiry result. */
+ * in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
+ * & revision.  Yikes! So let us always send back 36 bytes, the minimum for
+ * inquiry result.
+ */
 #define NO_DISK_INQUIRY_RESULT_LEN 36
 
 #define MIN_INQUIRY_RESULT_LEN 5 /* we need at least 5 bytes minimum for inquiry
@@ -309,21 +309,21 @@ struct uiscmdrsp_scsi {
 	} while (0)
 
 /*
-* Struct & Defines to support sense information.
-*/
+ * Struct & Defines to support sense information.
+ */
 
 /* The following struct is returned in sensebuf field in uiscmdrsp_scsi.  It is
-* initialized in exactly the manner that is recommended in Windows (hence the
-* odd values).
-* When set, these fields will have the following values:
-* ErrorCode = 0x70		indicates current error
-* Valid = 1			indicates sense info is valid
-* SenseKey			contains sense key as defined by SCSI specs.
-* AdditionalSenseCode		contains sense key as defined by SCSI specs.
-* AdditionalSenseCodeQualifier	contains qualifier to sense code as defined by
-*				scsi docs.
-* AdditionalSenseLength		contains will be sizeof(sense_data)-8=10.
-*/
+ * initialized in exactly the manner that is recommended in Windows (hence the
+ * odd values).
+ * When set, these fields will have the following values:
+ * ErrorCode = 0x70		indicates current error
+ * Valid = 1			indicates sense info is valid
+ * SenseKey			contains sense key as defined by SCSI specs.
+ * AdditionalSenseCode		contains sense key as defined by SCSI specs.
+ * AdditionalSenseCodeQualifier	contains qualifier to sense code as defined by
+ *				scsi docs.
+ * AdditionalSenseLength	contains will be sizeof(sense_data)-8=10.
+ */
 struct sense_data {
 	u8 errorcode:7;
 	u8 valid:1;
@@ -375,24 +375,25 @@ struct net_pkt_xmtdone {
 };
 
 /* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The
-* reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
-* virtnic requires that there is "overhead" in the buffer, and pads 16 bytes.  I
-* prefer to use 1 full cache line size for "overhead" so that transfers are
-* better.  IOVM requires that a buffer be represented by 1 phys_info structure
-* which can only cover page_size. */
+ * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
+ * virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I
+ * prefer to use 1 full cache line size for "overhead" so that transfers are
+ * better.  IOVM requires that a buffer be represented by 1 phys_info structure
+ * which can only cover page_size.
+ */
 #define RCVPOST_BUF_SIZE 4032
 #define MAX_NET_RCV_CHAIN \
 	((ETH_MAX_MTU+ETH_HEADER_SIZE + RCVPOST_BUF_SIZE-1) / RCVPOST_BUF_SIZE)
 
 struct net_pkt_rcvpost {
 	    /* rcv buf size must be large enough to include ethernet data len +
-	    * ethernet header len - we are choosing 2K because it is guaranteed
-	    * to be describable */
+	     * ethernet header len - we are choosing 2K because it is guaranteed
+	     * to be describable */
 	    struct phys_info frag;	/* physical page information for the
 					 * single fragment 2K rcv buf */
 	    u64 unique_num;		/* This is used to make sure that
 					 * receive posts are returned to  */
-	    /* the Adapter which sent them origonally. */
+	    /* the Adapter which we sent them originally. */
 };
 
 struct net_pkt_rcv {
@@ -424,14 +425,14 @@ struct uiscmdrsp_net {
 	enum net_types type;
 	void *buf;
 	union {
-		struct net_pkt_xmt xmt;	/* used for NET_XMIT */
+		struct net_pkt_xmt xmt;		/* used for NET_XMIT */
 		struct net_pkt_xmtdone xmtdone;	/* used for NET_XMIT_DONE */
 		struct net_pkt_rcvpost rcvpost;	/* used for NET_RCV_POST */
-		struct net_pkt_rcv rcv;	/* used for NET_RCV */
+		struct net_pkt_rcv rcv;		/* used for NET_RCV */
 		struct net_pkt_enbdis enbdis;	/* used for NET_RCV_ENBDIS, */
-		/* NET_RCV_ENBDIS_ACK,  */
-		/* NET_RCV_PROMSIC, */
-		/* and NET_CONNECT_STATUS */
+						/* NET_RCV_ENBDIS_ACK,  */
+						/* NET_RCV_PROMSIC, */
+						/* and NET_CONNECT_STATUS */
 		struct net_pkt_macaddr macaddr;
 	};
 };
@@ -446,24 +447,27 @@ struct uiscmdrsp_scsitaskmgmt {
 	void *scsicmd;
 
 	    /* This is some handle that the guest has saved off for its own use.
-	    * Its value is preserved by iopart & returned as is in the task mgmt
-	    * rsp. */
+	     * Its value is preserved by iopart & returned as is in the task
+	     * mgmt rsp.
+	     */
 	void *notify;
 
-	    /* For linux guests, this is a pointer to wait_queue_head that a
+	   /* For linux guests, this is a pointer to wait_queue_head that a
 	    * thread is waiting on to see if the taskmgmt command has completed.
 	    * For windows guests, this is a pointer to a location that a waiting
 	    * thread is testing to see if the taskmgmt command has completed.
 	    * When the rsp is received by guest, the thread receiving the
 	    * response uses this to notify the thread waiting for taskmgmt
 	    * command completion.  Its value is preserved by iopart & returned
-	    * as is in the task mgmt rsp. */
+	    * as is in the task mgmt rsp.
+	    */
 	void *notifyresult;
 
 	    /* this is a handle to location in guest where the result of the
-	    * taskmgmt command (result field) is to saved off when the response
-	    * is handled.  Its value is preserved by iopart & returned as is in
-	    * the task mgmt rsp. */
+	     * taskmgmt command (result field) is to saved off when the response
+	     * is handled.  Its value is preserved by iopart & returned as is in
+	     * the task mgmt rsp.
+	     */
 	char result;
 
 	    /* result of taskmgmt command - set by IOPart - values are: */
@@ -474,14 +478,14 @@ struct uiscmdrsp_scsitaskmgmt {
  * Guest */
 /* Note that the vHba pointer is not used by the Client/Guest side. */
 struct uiscmdrsp_disknotify {
-	u8 add;		/* 0-remove, 1-add */
+	u8 add;			/* 0-remove, 1-add */
 	void *v_hba;		/* Pointer to vhba_info for channel info to
 				 * route msg */
 	u32 channel, id, lun;	/* SCSI Path of Disk to added or removed */
 };
 
 /* The following is used by virthba/vSCSI to send the Acquire/Release commands
-* to the IOVM.  */
+ * to the IOVM. */
 struct uiscmdrsp_vdiskmgmt {
 	enum vdisk_mgmt_types vdisktype;
 
@@ -492,24 +496,27 @@ struct uiscmdrsp_vdiskmgmt {
 	void *scsicmd;
 
 	    /* This is some handle that the guest has saved off for its own use.
-	    * Its value is preserved by iopart & returned as is in the task mgmt
-	    * rsp. */
+	     * Its value is preserved by iopart & returned as is in the task
+	     * mgmt rsp.
+	     */
 	void *notify;
 
 	    /* For linux guests, this is a pointer to wait_queue_head that a
-	    * thread is waiting on to see if the taskmgmt command has completed.
-	    * For windows guests, this is a pointer to a location that a waiting
-	    * thread is testing to see if the taskmgmt command has completed.
-	    * When the rsp is received by guest, the thread receiving the
-	    * response uses this to notify the thread waiting for taskmgmt
-	    * command completion.  Its value is preserved by iopart & returned
-	    * as is in the task mgmt rsp. */
+	     * thread is waiting on to see if the tskmgmt command has completed.
+	     * For win32 guests, this is a pointer to a location that a waiting
+	     * thread is testing to see if the taskmgmt command has completed.
+	     * When the rsp is received by guest, the thread receiving the
+	     * response uses this to notify the thread waiting for taskmgmt
+	     * command completion.  Its value is preserved by iopart & returned
+	     * as is in the task mgmt rsp.
+	     */
 	void *notifyresult;
 
 	    /* this is a handle to location in guest where the result of the
-	    * taskmgmt command (result field) is to saved off when the response
-	    * is handled.  Its value is preserved by iopart & returned as is in
-	    * the task mgmt rsp. */
+	     * taskmgmt command (result field) is to saved off when the response
+	     * is handled.  Its value is preserved by iopart & returned as is in
+	     * the task mgmt rsp.
+	     */
 	char result;
 
 	    /* result of taskmgmt command - set by IOPart - values are: */
@@ -520,7 +527,7 @@ struct uiscmdrsp_vdiskmgmt {
 struct uiscmdrsp {
 	char cmdtype;
 
-	    /* describes what type of information is in the struct */
+/* describes what type of information is in the struct */
 #define CMD_SCSI_TYPE		1
 #define CMD_NET_TYPE		2
 #define CMD_SCSITASKMGMT_TYPE	3
@@ -534,30 +541,31 @@ struct uiscmdrsp {
 		struct uiscmdrsp_vdiskmgmt vdiskmgmt;
 	};
 	void *private_data;	/* used to send the response when the cmd is
-				 * done (scsi & scsittaskmgmt).  */
+				 * done (scsi & scsittaskmgmt). */
 	struct uiscmdrsp *next;	/* General Purpose Queue Link */
 	struct uiscmdrsp *activeQ_next;	/* Used to track active commands */
-	struct uiscmdrsp *activeQ_prev;	/* Used to track active commands  */
+	struct uiscmdrsp *activeQ_prev;	/* Used to track active commands */
 };
 
 /* This is just the header of the IO channel.  It is assumed that directly after
-* this header there is a large region of memory which contains the command and
-* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. */
+ * this header there is a large region of memory which contains the command and
+ * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS.
+ */
 struct spar_io_channel_protocol {
 	struct channel_header channel_header;
 	struct signal_queue_header cmd_q;
 	struct signal_queue_header rsp_q;
 	union {
 		struct {
-			struct vhba_wwnn wwnn;	/* 8 bytes */
+			struct vhba_wwnn wwnn;		/* 8 bytes */
 			struct vhba_config_max max;	/* 20 bytes */
-		} vhba;		/* 28 */
+		} vhba;					/* total = 28 bytes */
 		struct {
 			u8 macaddr[MAX_MACADDR_LEN];	/* 6 bytes */
-			u32 num_rcv_bufs;	/* 4 */
-			u32 mtu;	/* 4 */
-			uuid_le zone_uuid;	/* 16 */
-		} vnic;		/* total     30 */
+			u32 num_rcv_bufs;		/* 4 bytes */
+			u32 mtu;			/* 4 bytes */
+			uuid_le zone_uuid;		/* 16 bytes */
+		} vnic;					/* total = 30 bytes */
 	};
 
 #define MAX_CLIENTSTRING_LEN 1024
@@ -569,8 +577,8 @@ struct spar_io_channel_protocol {
 /* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
 
 /*
-* INLINE functions for initializing and accessing I/O data channels
-*/
+ * INLINE functions for initializing and accessing I/O data channels
+ */
 
 #define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
 #define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
@@ -579,9 +587,9 @@ struct spar_io_channel_protocol {
 				  2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
 
 /*
-* INLINE function for expanding a guest's pfn-off-size into multiple 4K page
-* pfn-off-size entires.
-*/
+ * INLINE function for expanding a guest's pfn-off-size into multiple 4K page
+ * pfn-off-size entires.
+ */
 
 /* we deal with 4K page sizes when we it comes to passing page information
  * between */
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 071/141] staging: unisys: get rid of serialloopbacktest
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (69 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 070/141] staging: unisys: cleanup and align iochannel.h comments Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 072/141] staging: unisys: Eliminate visor_memregion_create() Benjamin Romer
                   ` (72 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

serialloopbacktest is no longer supported. Get rid of it.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 7 -------
 drivers/staging/unisys/visorbus/visorchipset.c  | 2 +-
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 3fcd5fb..b00782d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -35,7 +35,6 @@ int visorbus_forcenomatch;
 #define MAXDEVICETEST 4
 int visorbus_devicetest;
 int visorbus_debugref;
-int visorbus_serialloopbacktest;
 #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
 
 /** This is the private data that we store for each bus device instance.
@@ -2131,12 +2130,6 @@ module_param_named(debugref, visorbus_debugref, int, S_IRUGO);
 MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting");
 int visorbus_debugref = 0;
 
-module_param_named(serialloopbacktest, visorbus_serialloopbacktest,
-		   int, S_IRUGO);
-MODULE_PARM_DESC(visorbus_serialloopbacktest,
-		 "non-0 to just create 2 serial devices on the same channel");
-int visorbus_serialloopbacktest = 0;
-
 MODULE_AUTHOR("Unisys");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 3a1ee2d..d93ac15 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2642,7 +2642,7 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
 static int __init
 visorchipset_init(void)
 {
-	int rc = 0, x = 0;
+	int rc = 0;
 	HOSTADDRESS addr;
 
 	if (!unisys_spar_platform)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 072/141] staging: unisys: Eliminate visor_memregion_create()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (70 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 071/141] staging: unisys: get rid of serialloopbacktest Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 073/141] staging: unisys: memregion: Eliminate visor_memregion_destroy() Benjamin Romer
                   ` (71 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c     | 15 ++++++++++-----
 drivers/staging/unisys/visorutil/memregion.h       |  2 --
 .../staging/unisys/visorutil/memregion_direct.c    | 22 ----------------------
 3 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 150e3df..f278739 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -57,9 +57,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	struct visorchannel *channel;
 	int err;
 	size_t size = sizeof(struct channel_header);
-	struct memregion *memregion;
 
-	channel = kmalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY);
+	channel = kzalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY);
 	if (!channel)
 		goto cleanup;
 
@@ -67,11 +66,17 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	spin_lock_init(&channel->insert_lock);
 	spin_lock_init(&channel->remove_lock);
 
-	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	memregion = visor_memregion_create(&channel->memregion, physaddr, size);
+	if (!request_mem_region(physaddr, size, MYDRVNAME))
+		goto cleanup;
 
-	if (!memregion)
+	channel->memregion.mapped = ioremap_cache(physaddr, size);
+	if (!channel->memregion.mapped) {
+		release_mem_region(physaddr, size);
 		goto cleanup;
+	}
+
+	channel->memregion.physaddr = physaddr;
+	channel->memregion.nbytes = size;
 
 	err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr,
 				   sizeof(struct channel_header));
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 3826fe6..cb3dbc5 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -29,8 +29,6 @@ struct memregion {
 	void __iomem *mapped;
 };
 
-struct memregion *visor_memregion_create(struct memregion *memregion,
-					 HOSTADDRESS physaddr, ulong nbytes);
 int visor_memregion_resize(struct memregion *memregion, ulong newsize);
 int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index a575ecc..0c7bed0 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -28,28 +28,6 @@
 static int mapit(struct memregion *memregion);
 static void unmapit(struct memregion *memregion);
 
-struct memregion *
-visor_memregion_create(struct memregion *memregion,
-		       HOSTADDRESS physaddr, ulong nbytes)
-{
-	struct memregion *rc = NULL;
-
-	memregion->physaddr = physaddr;
-	memregion->nbytes = nbytes;
-	if (mapit(memregion)) {
-		rc = NULL;
-		goto cleanup;
-	}
-	rc = memregion;
-cleanup:
-	if (rc == NULL) {
-		visor_memregion_destroy(memregion);
-		memregion = NULL;
-	}
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_create);
-
 static int
 mapit(struct memregion *memregion)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 073/141] staging: unisys: memregion: Eliminate visor_memregion_destroy()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (71 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 072/141] staging: unisys: Eliminate visor_memregion_create() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 074/141] staging: unisys: memregion: Eliminate visor_memregion_resize() Benjamin Romer
                   ` (70 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c      | 6 +++++-
 drivers/staging/unisys/visorutil/memregion.h        | 1 -
 drivers/staging/unisys/visorutil/memregion_direct.c | 9 ---------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index f278739..42fabea 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -124,7 +124,11 @@ visorchannel_destroy(struct visorchannel *channel)
 {
 	if (!channel)
 		return;
-	visor_memregion_destroy(&channel->memregion);
+	if (channel->memregion.mapped) {
+		iounmap(channel->memregion.mapped);
+		release_mem_region(channel->memregion.physaddr,
+				   channel->memregion.nbytes);
+	}
 	kfree(channel);
 }
 EXPORT_SYMBOL_GPL(visorchannel_destroy);
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index cb3dbc5..60d0dc9 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -34,7 +34,6 @@ int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
 int visor_memregion_write(struct memregion *memregion,
 			  ulong offset, void *src, ulong nbytes);
-void visor_memregion_destroy(struct memregion *memregion);
 HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion);
 ulong visor_memregion_get_nbytes(struct memregion *memregion);
 void memregion_dump(struct memregion *memregion, char *s,
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 0c7bed0..79ef4c5 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -115,12 +115,3 @@ visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(visor_memregion_write);
-
-void
-visor_memregion_destroy(struct memregion *memregion)
-{
-	if (!memregion)
-		return;
-	unmapit(memregion);
-}
-EXPORT_SYMBOL_GPL(visor_memregion_destroy);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 074/141] staging: unisys: memregion: Eliminate visor_memregion_resize()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (72 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 073/141] staging: unisys: memregion: Eliminate visor_memregion_destroy() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 075/141] staging: unisys: memregion: Eliminate visor_memregion_get_*() functions Benjamin Romer
                   ` (69 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c      | 17 +++++++++++++++--
 drivers/staging/unisys/visorutil/memregion.h        |  1 -
 drivers/staging/unisys/visorutil/memregion_direct.c | 16 ----------------
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 42fabea..cfbb19f 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -89,9 +89,22 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
 		guid = channel->chan_hdr.chtype;
 
-	err = visor_memregion_resize(&channel->memregion, channel_bytes);
-	if (err)
+	iounmap(channel->memregion.mapped);
+	release_mem_region(channel->memregion.physaddr,
+			   channel->memregion.nbytes);
+	channel->memregion.mapped = NULL;
+	if (!request_mem_region(channel->memregion.physaddr, channel_bytes,
+				MYDRVNAME))
+		goto cleanup;
+
+	channel->memregion.mapped = ioremap_cache(channel->memregion.physaddr,
+						  channel_bytes);
+	if (!channel->memregion.mapped) {
+		release_mem_region(channel->memregion.physaddr, channel_bytes);
 		goto cleanup;
+	}
+
+	channel->memregion.nbytes = channel_bytes;
 
 	channel->size = channel_bytes;
 	channel->guid = guid;
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 60d0dc9..57d617f 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -29,7 +29,6 @@ struct memregion {
 	void __iomem *mapped;
 };
 
-int visor_memregion_resize(struct memregion *memregion, ulong newsize);
 int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
 int visor_memregion_write(struct memregion *memregion,
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 79ef4c5..fa7a406 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -77,22 +77,6 @@ visor_memregion_get_pointer(struct memregion *memregion)
 EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
 
 int
-visor_memregion_resize(struct memregion *memregion, ulong newsize)
-{
-	int rc;
-
-	if (newsize == memregion->nbytes)
-		return 0;
-
-	unmapit(memregion);
-	memregion->nbytes = newsize;
-	rc = mapit(memregion);
-
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_resize);
-
-int
 visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
 		     ulong nbytes)
 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 075/141] staging: unisys: memregion: Eliminate visor_memregion_get_*() functions
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (73 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 074/141] staging: unisys: memregion: Eliminate visor_memregion_resize() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 076/141] staging: unisys: memregion: {un, }mapit() are no longer used Benjamin Romer
                   ` (68 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c      |  7 +++----
 drivers/staging/unisys/visorutil/memregion.h        |  3 ---
 drivers/staging/unisys/visorutil/memregion_direct.c | 21 ---------------------
 3 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index cfbb19f..bf2f17a 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy);
 HOSTADDRESS
 visorchannel_get_physaddr(struct visorchannel *channel)
 {
-	return visor_memregion_get_physaddr(&channel->memregion);
+	return channel->memregion.physaddr;
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
 
@@ -501,7 +501,6 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
 {
 	HOSTADDRESS addr = 0;
 	ulong nbytes = 0, nbytes_region = 0;
-	struct memregion *memregion = NULL;
 	struct channel_header hdr;
 	struct channel_header *phdr = &hdr;
 	int i = 0;
@@ -510,8 +509,8 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
 	if (!channel)
 		return;
 
-	addr = visor_memregion_get_physaddr(memregion);
-	nbytes_region = visor_memregion_get_nbytes(memregion);
+	addr = visorchannel_get_physaddr(channel);
+	nbytes_region = visorchannel_get_nbytes(channel);
 	errcode = visorchannel_read(channel, off,
 				    phdr, sizeof(struct channel_header));
 	if (errcode < 0) {
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 57d617f..6893937 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -33,10 +33,7 @@ int visor_memregion_read(struct memregion *memregion,
 			 ulong offset, void *dest, ulong nbytes);
 int visor_memregion_write(struct memregion *memregion,
 			  ulong offset, void *src, ulong nbytes);
-HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion);
-ulong visor_memregion_get_nbytes(struct memregion *memregion);
 void memregion_dump(struct memregion *memregion, char *s,
 		    ulong off, ulong len, struct seq_file *seq);
-void __iomem *visor_memregion_get_pointer(struct memregion *memregion);
 
 #endif
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index fa7a406..238e62f 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -55,27 +55,6 @@ unmapit(struct memregion *memregion)
 	}
 }
 
-HOSTADDRESS
-visor_memregion_get_physaddr(struct memregion *memregion)
-{
-	return memregion->physaddr;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_physaddr);
-
-ulong
-visor_memregion_get_nbytes(struct memregion *memregion)
-{
-	return memregion->nbytes;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_nbytes);
-
-void __iomem *
-visor_memregion_get_pointer(struct memregion *memregion)
-{
-	return memregion->mapped;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
-
 int
 visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
 		     ulong nbytes)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 076/141] staging: unisys: memregion: {un, }mapit() are no longer used
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (74 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 075/141] staging: unisys: memregion: Eliminate visor_memregion_get_*() functions Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 077/141] staging: unisys: visorchannel_write(): Use memcpy_toio() directly Benjamin Romer
                   ` (67 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../staging/unisys/visorutil/memregion_direct.c    | 30 ----------------------
 1 file changed, 30 deletions(-)

diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 238e62f..82fb263 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -25,36 +25,6 @@
 
 #define MYDRVNAME "memregion"
 
-static int mapit(struct memregion *memregion);
-static void unmapit(struct memregion *memregion);
-
-static int
-mapit(struct memregion *memregion)
-{
-	ulong physaddr = (ulong)(memregion->physaddr);
-	ulong nbytes = memregion->nbytes;
-
-	if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
-		return -EBUSY;
-
-	memregion->mapped = ioremap_cache(physaddr, nbytes);
-	if (!memregion->mapped)
-		return -EFAULT;
-
-	return 0;
-}
-
-static void
-unmapit(struct memregion *memregion)
-{
-	if (memregion->mapped) {
-		iounmap(memregion->mapped);
-		memregion->mapped = NULL;
-		release_mem_region((unsigned long)memregion->physaddr,
-				   memregion->nbytes);
-	}
-}
-
 int
 visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
 		     ulong nbytes)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 077/141] staging: unisys: visorchannel_write(): Use memcpy_toio() directly
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (75 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 076/141] staging: unisys: memregion: {un, }mapit() are no longer used Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 078/141] staging: unisys: visorchannel_read(): Use memcpy_fromio() directly Benjamin Romer
                   ` (66 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index bf2f17a..bf75aa0 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -216,10 +216,15 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
 {
 	size_t size = sizeof(struct channel_header);
 
+	if (offset + nbytes > channel->memregion.nbytes)
+		return -EIO;
+
 	if (!offset && nbytes >= size)
 		memcpy(&channel->chan_hdr, local, size);
-	return visor_memregion_write(&channel->memregion,
-				     offset, local, nbytes);
+
+	memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(visorchannel_write);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 078/141] staging: unisys: visorchannel_read(): Use memcpy_fromio() directly
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (76 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 077/141] staging: unisys: visorchannel_write(): Use memcpy_toio() directly Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes Benjamin Romer
                   ` (65 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Note, this changes the behavior of visorchannel_read(). The old code
would return the channel header, if the offset argument was 0, and the
caller tried to read beyond the size of the visorchannel. Note this
only worked for offset == 0, but not for
(offset > 0) && (offset < header_size), which was inconsistent.

The new implementation returns an error if someone tries to read
beyond the visorchannel size.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index bf75aa0..cae62fed 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -200,13 +200,12 @@ int
 visorchannel_read(struct visorchannel *channel, ulong offset,
 		  void *local, ulong nbytes)
 {
-	int rc;
-	size_t size = sizeof(struct channel_header);
+	if (offset + nbytes > channel->memregion.nbytes)
+		return -EIO;
 
-	rc = visor_memregion_read(&channel->memregion, offset, local, nbytes);
-	if (rc && !offset && (nbytes >= size))
-		memcpy(&channel->chan_hdr, local, size);
-	return rc;
+	memcpy_fromio(local, channel->memregion.mapped + offset, nbytes);
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(visorchannel_read);
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (77 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 078/141] staging: unisys: visorchannel_read(): Use memcpy_fromio() directly Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-06 13:46   ` Dan Carpenter
  2015-05-05 22:36 ` [PATCH 080/141] staging: unisys: visorchannel_create_guts(): Use visorchannel_read() Benjamin Romer
                   ` (64 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index cae62fed..da7bd9c 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -213,13 +213,16 @@ int
 visorchannel_write(struct visorchannel *channel, ulong offset,
 		   void *local, ulong nbytes)
 {
-	size_t size = sizeof(struct channel_header);
+	size_t chdr_size = sizeof(struct channel_header);
+	size_t copy_size;
 
 	if (offset + nbytes > channel->memregion.nbytes)
 		return -EIO;
 
-	if (!offset && nbytes >= size)
-		memcpy(&channel->chan_hdr, local, size);
+	if (offset < chdr_size) {
+		copy_size = min(chdr_size, nbytes) - offset;
+		memcpy(&channel->chan_hdr + offset, local, copy_size);
+	}
 
 	memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 080/141] staging: unisys: visorchannel_create_guts(): Use visorchannel_read()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (78 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 081/141] staging: unisys: Eliminate visor_memregion_read() Benjamin Romer
                   ` (63 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

There is no benefit to calling visor_memregion_read() at this point.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index da7bd9c..6d7ea8b 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -78,8 +78,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	channel->memregion.physaddr = physaddr;
 	channel->memregion.nbytes = size;
 
-	err = visor_memregion_read(&channel->memregion, 0, &channel->chan_hdr,
-				   sizeof(struct channel_header));
+	err = visorchannel_read(channel, 0, &channel->chan_hdr,
+				sizeof(struct channel_header));
 	if (err)
 		goto cleanup;
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 081/141] staging: unisys: Eliminate visor_memregion_read()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (79 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 080/141] staging: unisys: visorchannel_create_guts(): Use visorchannel_read() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:36 ` [PATCH 082/141] staging: unisys: Eliminate visor_memregion_write() Benjamin Romer
                   ` (62 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c      | 11 +++++------
 drivers/staging/unisys/visorutil/memregion.h        |  2 --
 drivers/staging/unisys/visorutil/memregion_direct.c | 12 ------------
 3 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 6d7ea8b..549128d 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -307,9 +307,9 @@ sig_read_header(struct visorchannel *channel, u32 queue,
 		return FALSE;
 
 	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
-	err = visor_memregion_read(&channel->memregion,
-				   SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
-				   sig_hdr, sizeof(struct signal_queue_header));
+	err = visorchannel_read(channel,
+				SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+				sig_hdr, sizeof(struct signal_queue_header));
 	if (err)
 		return FALSE;
 
@@ -324,9 +324,8 @@ sig_read_data(struct visorchannel *channel, u32 queue,
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
-	err = visor_memregion_read(&channel->memregion,
-				   signal_data_offset,
-				   data, sig_hdr->signal_size);
+	err = visorchannel_read(channel, signal_data_offset,
+				data, sig_hdr->signal_size);
 	if (err)
 		return FALSE;
 
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 6893937..4122b48 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -29,8 +29,6 @@ struct memregion {
 	void __iomem *mapped;
 };
 
-int visor_memregion_read(struct memregion *memregion,
-			 ulong offset, void *dest, ulong nbytes);
 int visor_memregion_write(struct memregion *memregion,
 			  ulong offset, void *src, ulong nbytes);
 void memregion_dump(struct memregion *memregion, char *s,
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 82fb263..17b1033 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -26,18 +26,6 @@
 #define MYDRVNAME "memregion"
 
 int
-visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
-		     ulong nbytes)
-{
-	if (offset + nbytes > memregion->nbytes)
-		return -EIO;
-
-	memcpy_fromio(dest, memregion->mapped + offset, nbytes);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_read);
-
-int
 visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
 		      ulong nbytes)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 082/141] staging: unisys: Eliminate visor_memregion_write()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (80 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 081/141] staging: unisys: Eliminate visor_memregion_read() Benjamin Romer
@ 2015-05-05 22:36 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 083/141] staging: unisys: Finally remove the last remnants of memregion Benjamin Romer
                   ` (61 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:36 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

visorchannel's signal code should call visorchannel_write() directly.
This is more consistent and cleaner, and allows us to remove the last
memregion call.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c     | 34 ++++++++++------------
 drivers/staging/unisys/visorutil/memregion.h       |  2 --
 .../staging/unisys/visorutil/memregion_direct.c    | 12 --------
 3 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 549128d..564d325 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -250,8 +250,8 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 
 		if (nbytes < thisbytes)
 			thisbytes = nbytes;
-		err = visor_memregion_write(&channel->memregion,
-					    offset + written, buf, thisbytes);
+		err = visorchannel_write(channel, offset + written,
+					 buf, thisbytes);
 		if (err)
 			goto cleanup;
 
@@ -290,12 +290,12 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
 /** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
  *  into host memory
  */
-#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			\
-	(visor_memregion_write(&channel->memregion,			\
-			       SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
-			       offsetof(struct signal_queue_header, FIELD),\
-			       &((sig_hdr)->FIELD),			\
-			       sizeof((sig_hdr)->FIELD)) >= 0)
+#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD)			 \
+	(visorchannel_write(channel,					 \
+			    SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
+			    offsetof(struct signal_queue_header, FIELD), \
+			    &((sig_hdr)->FIELD),			 \
+			    sizeof((sig_hdr)->FIELD)) >= 0)
 
 static BOOL
 sig_read_header(struct visorchannel *channel, u32 queue,
@@ -340,9 +340,8 @@ sig_write_data(struct visorchannel *channel, u32 queue,
 	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
-	err = visor_memregion_write(&channel->memregion,
-				    signal_data_offset,
-				    data, sig_hdr->signal_size);
+	err = visorchannel_write(channel, signal_data_offset,
+				 data, sig_hdr->signal_size);
 	if (err)
 		return FALSE;
 
@@ -403,13 +402,12 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
 	if (sig_hdr.head == sig_hdr.tail) {
 		sig_hdr.num_overflows++;
-		visor_memregion_write(&channel->memregion,
-				      SIG_QUEUE_OFFSET(&channel->chan_hdr,
-						       queue) +
-				      offsetof(struct signal_queue_header,
-					       num_overflows),
-				      &(sig_hdr.num_overflows),
-				      sizeof(sig_hdr.num_overflows));
+		visorchannel_write(channel,
+				   SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) +
+				   offsetof(struct signal_queue_header,
+					    num_overflows),
+				   &(sig_hdr.num_overflows),
+				   sizeof(sig_hdr.num_overflows));
 		return FALSE;
 	}
 
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
index 4122b48..62036cd 100644
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ b/drivers/staging/unisys/visorutil/memregion.h
@@ -29,8 +29,6 @@ struct memregion {
 	void __iomem *mapped;
 };
 
-int visor_memregion_write(struct memregion *memregion,
-			  ulong offset, void *src, ulong nbytes);
 void memregion_dump(struct memregion *memregion, char *s,
 		    ulong off, ulong len, struct seq_file *seq);
 
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
index 17b1033..818f6a8 100644
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ b/drivers/staging/unisys/visorutil/memregion_direct.c
@@ -24,15 +24,3 @@
 #include "memregion.h"
 
 #define MYDRVNAME "memregion"
-
-int
-visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
-		      ulong nbytes)
-{
-	if (offset + nbytes > memregion->nbytes)
-		return -EIO;
-
-	memcpy_toio(memregion->mapped + offset, src, nbytes);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_write);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 083/141] staging: unisys: Finally remove the last remnants of memregion
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (81 preceding siblings ...)
  2015-05-05 22:36 ` [PATCH 082/141] staging: unisys: Eliminate visor_memregion_write() Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 084/141] staging: unisys: remove BOOL,TRUE,FALSE definitions Benjamin Romer
                   ` (60 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h          |  1 -
 drivers/staging/unisys/visorbus/visorchannel.c     | 53 ++++++++++------------
 drivers/staging/unisys/visorchannel/globals.h      |  1 -
 drivers/staging/unisys/visorutil/Makefile          |  2 +-
 drivers/staging/unisys/visorutil/memregion.h       | 35 --------------
 .../staging/unisys/visorutil/memregion_direct.c    | 26 -----------
 6 files changed, 25 insertions(+), 93 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorutil/memregion.h
 delete mode 100644 drivers/staging/unisys/visorutil/memregion_direct.c

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index e1c6662..87ffff4 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -36,7 +36,6 @@
 
 #include "periodic_work.h"
 #include "channel.h"
-#include "memregion.h"
 
 #ifndef HOSTADDRESS
 #define HOSTADDRESS u64
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 564d325..ed652a0 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -17,12 +17,9 @@
 
 /*
  *  This provides Supervisor channel communication primitives, which are
- *  independent of the mechanism used to access the channel data.  All channel
- *  data is accessed using the memregion abstraction.  (memregion has both
- *  a CM2 implementation and a direct memory implementation.)
+ *  independent of the mechanism used to access the channel data.
  */
 
-#include "memregion.h"
 #include "version.h"
 #include "visorbus.h"
 #include <linux/uuid.h>
@@ -30,7 +27,9 @@
 #define MYDRVNAME "visorchannel"
 
 struct visorchannel {
-	struct memregion memregion;	/* from visor_memregion_create() */
+	HOSTADDRESS physaddr;
+	ulong nbytes;
+	void __iomem *mapped;
 	struct channel_header chan_hdr;
 	uuid_le guid;
 	ulong size;
@@ -69,14 +68,14 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	if (!request_mem_region(physaddr, size, MYDRVNAME))
 		goto cleanup;
 
-	channel->memregion.mapped = ioremap_cache(physaddr, size);
-	if (!channel->memregion.mapped) {
+	channel->mapped = ioremap_cache(physaddr, size);
+	if (!channel->mapped) {
 		release_mem_region(physaddr, size);
 		goto cleanup;
 	}
 
-	channel->memregion.physaddr = physaddr;
-	channel->memregion.nbytes = size;
+	channel->physaddr = physaddr;
+	channel->nbytes = size;
 
 	err = visorchannel_read(channel, 0, &channel->chan_hdr,
 				sizeof(struct channel_header));
@@ -89,22 +88,19 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
 	if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
 		guid = channel->chan_hdr.chtype;
 
-	iounmap(channel->memregion.mapped);
-	release_mem_region(channel->memregion.physaddr,
-			   channel->memregion.nbytes);
-	channel->memregion.mapped = NULL;
-	if (!request_mem_region(channel->memregion.physaddr, channel_bytes,
-				MYDRVNAME))
+	iounmap(channel->mapped);
+	release_mem_region(channel->physaddr, channel->nbytes);
+	channel->mapped = NULL;
+	if (!request_mem_region(channel->physaddr, channel_bytes, MYDRVNAME))
 		goto cleanup;
 
-	channel->memregion.mapped = ioremap_cache(channel->memregion.physaddr,
-						  channel_bytes);
-	if (!channel->memregion.mapped) {
-		release_mem_region(channel->memregion.physaddr, channel_bytes);
+	channel->mapped = ioremap_cache(channel->physaddr, channel_bytes);
+	if (!channel->mapped) {
+		release_mem_region(channel->physaddr, channel_bytes);
 		goto cleanup;
 	}
 
-	channel->memregion.nbytes = channel_bytes;
+	channel->nbytes = channel_bytes;
 
 	channel->size = channel_bytes;
 	channel->guid = guid;
@@ -137,10 +133,9 @@ visorchannel_destroy(struct visorchannel *channel)
 {
 	if (!channel)
 		return;
-	if (channel->memregion.mapped) {
-		iounmap(channel->memregion.mapped);
-		release_mem_region(channel->memregion.physaddr,
-				   channel->memregion.nbytes);
+	if (channel->mapped) {
+		iounmap(channel->mapped);
+		release_mem_region(channel->physaddr, channel->nbytes);
 	}
 	kfree(channel);
 }
@@ -149,7 +144,7 @@ EXPORT_SYMBOL_GPL(visorchannel_destroy);
 HOSTADDRESS
 visorchannel_get_physaddr(struct visorchannel *channel)
 {
-	return channel->memregion.physaddr;
+	return channel->physaddr;
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
 
@@ -200,10 +195,10 @@ int
 visorchannel_read(struct visorchannel *channel, ulong offset,
 		  void *local, ulong nbytes)
 {
-	if (offset + nbytes > channel->memregion.nbytes)
+	if (offset + nbytes > channel->nbytes)
 		return -EIO;
 
-	memcpy_fromio(local, channel->memregion.mapped + offset, nbytes);
+	memcpy_fromio(local, channel->mapped + offset, nbytes);
 
 	return 0;
 }
@@ -216,7 +211,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
 	size_t chdr_size = sizeof(struct channel_header);
 	size_t copy_size;
 
-	if (offset + nbytes > channel->memregion.nbytes)
+	if (offset + nbytes > channel->nbytes)
 		return -EIO;
 
 	if (offset < chdr_size) {
@@ -224,7 +219,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
 		memcpy(&channel->chan_hdr + offset, local, copy_size);
 	}
 
-	memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
+	memcpy_toio(channel->mapped + offset, local, nbytes);
 
 	return 0;
 }
diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h
index 0ed8e1d..6530413 100644
--- a/drivers/staging/unisys/visorchannel/globals.h
+++ b/drivers/staging/unisys/visorchannel/globals.h
@@ -19,7 +19,6 @@
 #define __VISORCHANNEL_GLOBALS_H__
 
 #include "timskmod.h"
-#include "memregion.h"
 #include "version.h"
 
 #define MYDRVNAME "visorchannel"
diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile
index d9ab5a3..f299787 100644
--- a/drivers/staging/unisys/visorutil/Makefile
+++ b/drivers/staging/unisys/visorutil/Makefile
@@ -4,6 +4,6 @@
 
 obj-$(CONFIG_UNISYS_VISORUTIL)	+= visorutil.o
 
-visorutil-y := charqueue.o  periodic_work.o  memregion_direct.o visorkmodutils.o
+visorutil-y := charqueue.o periodic_work.o visorkmodutils.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
deleted file mode 100644
index 62036cd..0000000
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* memregion.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __MEMREGION_H__
-#define __MEMREGION_H__
-
-#include "timskmod.h"
-
-/* struct memregion is an opaque structure to users.
- * Fields are declared only in the implementation .c files.
- */
-struct memregion {
-	HOSTADDRESS physaddr;
-	ulong nbytes;
-	void __iomem *mapped;
-};
-
-void memregion_dump(struct memregion *memregion, char *s,
-		    ulong off, ulong len, struct seq_file *seq);
-
-#endif
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
deleted file mode 100644
index 818f6a8..0000000
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* memregion_direct.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  This is an implementation of memory regions that can be used to read/write
- *  channel memory (in main memory of the host system) from code running in
- *  a virtual partition.
- */
-#include "timskmod.h"
-#include "memregion.h"
-
-#define MYDRVNAME "memregion"
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 084/141] staging: unisys: remove BOOL,TRUE,FALSE definitions
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (82 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 083/141] staging: unisys: Finally remove the last remnants of memregion Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 085/141] staging: unisys: add acpi pnp driver Benjamin Romer
                   ` (59 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Prarit Bhargava, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

These shouldn't be defined in the code and can be replaced with the
standard bool, true, and false usage that the kernel uses.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/periodic_work.h    |  6 +--
 drivers/staging/unisys/include/timskmod.h         |  5 --
 drivers/staging/unisys/include/visorbus.h         |  4 +-
 drivers/staging/unisys/visorbus/visorbus_main.c   | 34 ++++++------
 drivers/staging/unisys/visorbus/visorchannel.c    | 64 +++++++++++------------
 drivers/staging/unisys/visorbus/visorchipset.c    |  2 +-
 drivers/staging/unisys/visorutil/charqueue.c      |  4 +-
 drivers/staging/unisys/visorutil/charqueue.h      |  2 +-
 drivers/staging/unisys/visorutil/periodic_work.c  | 52 +++++++++---------
 drivers/staging/unisys/visorutil/visorkmodutils.c |  2 +-
 10 files changed, 85 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h
index 26ec10b..21939db 100644
--- a/drivers/staging/unisys/include/periodic_work.h
+++ b/drivers/staging/unisys/include/periodic_work.h
@@ -31,8 +31,8 @@ struct periodic_work *visor_periodic_work_create(ulong jiffy_interval,
 					void *workfuncarg,
 					const char *devnam);
 void visor_periodic_work_destroy(struct periodic_work *pw);
-BOOL visor_periodic_work_nextperiod(struct periodic_work *pw);
-BOOL visor_periodic_work_start(struct periodic_work *pw);
-BOOL visor_periodic_work_stop(struct periodic_work *pw);
+bool visor_periodic_work_nextperiod(struct periodic_work *pw);
+bool visor_periodic_work_start(struct periodic_work *pw);
+bool visor_periodic_work_stop(struct periodic_work *pw);
 
 #endif
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h
index cde2494..2ee2275 100644
--- a/drivers/staging/unisys/include/timskmod.h
+++ b/drivers/staging/unisys/include/timskmod.h
@@ -52,11 +52,6 @@
 #include <linux/mm.h>
 
 /* #define DEBUG */
-#ifndef BOOL
-#define BOOL    int
-#endif
-#define FALSE   0
-#define TRUE    1
 #if !defined SUCCESS
 #define SUCCESS 0
 #endif
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 87ffff4..bce8aa2 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -182,9 +182,9 @@ int visorchannel_write(struct visorchannel *channel, ulong offset,
 		       void *local, ulong nbytes);
 int visorchannel_clear(struct visorchannel *channel, ulong offset,
 		       u8 ch, ulong nbytes);
-BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
+bool visorchannel_signalremove(struct visorchannel *channel, u32 queue,
 			       void *msg);
-BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
+bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
 			       void *msg);
 int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
 					 u32 queue);
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index b00782d..f7976ca 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1076,7 +1076,7 @@ visordriver_probe_device(struct device *xdev)
 	drv = to_visor_driver(xdev->driver);
 	dev = to_visor_device(xdev);
 	down(&dev->visordriver_callback_lock);
-	dev->being_removed = FALSE;
+	dev->being_removed = false;
 	/*
 	 * ensure that the dev->being_removed flag is cleared before
 	 * we start the probe
@@ -1106,7 +1106,7 @@ away:
 	 *  initialized.
 	 */
 	if (!dev->responded_to_device_create) {
-		dev->responded_to_device_create = TRUE;
+		dev->responded_to_device_create = true;
 		if (chipset_responders.device_create)
 			(*chipset_responders.device_create)(dev->chipset_bus_no,
 							    dev->chipset_dev_no,
@@ -1129,7 +1129,7 @@ visordriver_remove_device(struct device *xdev)
 	dev = to_visor_device(xdev);
 	drv = to_visor_driver(xdev->driver);
 	down(&dev->visordriver_callback_lock);
-	dev->being_removed = TRUE;
+	dev->being_removed = true;
 	/*
 	 * ensure that the dev->being_removed flag is set before we start the
 	 * actual removal
@@ -1303,7 +1303,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 	int rc = -1;
 	struct visorchannel *visorchannel = NULL;
 	struct visor_device *dev = NULL;
-	bool gotten = FALSE, registered1 = FALSE, registered2 = FALSE;
+	bool gotten = false, registered1 = false, registered2 = false;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
 			 POSTCODE_SEVERITY_INFO);
@@ -1337,7 +1337,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 	dev->device.release = visorbus_release_device;
 	/* keep a reference just for us (now 2) */
 	get_device(&dev->device);
-	gotten = TRUE;
+	gotten = true;
 	dev->periodic_work =
 		visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL,
 					   periodic_dev_workqueue,
@@ -1387,7 +1387,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 		goto away;
 	}
 
-	registered1 = TRUE;
+	registered1 = true;
 
 	rc = register_devmajorminor_attributes(dev);
 	if (rc < 0) {
@@ -1396,7 +1396,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 		goto away;
 	}
 
-	registered2 = TRUE;
+	registered2 = true;
 	rc = 0;
 
 away:
@@ -1687,7 +1687,7 @@ create_bus_instance(int id)
 				if (get_vbus_header_info(devdata->chan,
 							 &devdata->
 							 vbus_hdr_info) >= 0) {
-					devdata->vbus_valid = TRUE;
+					devdata->vbus_valid = true;
 					write_vbus_chp_info(devdata->chan,
 							    &devdata->
 							    vbus_hdr_info,
@@ -1775,7 +1775,7 @@ remove_all_visor_devices(void)
 	}
 }
 
-static bool entered_testing_mode = FALSE;
+static bool entered_testing_mode;
 static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST];
 static unsigned long test_bus_nos[MAXDEVICETEST];
 static unsigned long test_dev_nos[MAXDEVICETEST];
@@ -1909,7 +1909,7 @@ pause_state_change_complete(struct visor_device *dev, int status)
 	if (!dev->pausing)
 			return;
 
-	dev->pausing = FALSE;
+	dev->pausing = false;
 	if (!chipset_responders.device_pause) /* this can never happen! */
 			return;
 
@@ -1930,7 +1930,7 @@ resume_state_change_complete(struct visor_device *dev, int status)
 	if (!dev->resuming)
 			return;
 
-	dev->resuming = FALSE;
+	dev->resuming = false;
 	if (!chipset_responders.device_resume) /* this can never happen! */
 			return;
 
@@ -1986,7 +1986,7 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
 		if (!drv->pause)
 				goto away;
 
-		dev->pausing = TRUE;
+		dev->pausing = true;
 		x = drv->pause(dev, pause_state_change_complete);
 	} else {
 		/* This should be done at BUS resume time, but an
@@ -1998,14 +1998,14 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
 		if (!drv->resume)
 				goto away;
 
-		dev->resuming = TRUE;
+		dev->resuming = true;
 		x = drv->resume(dev, resume_state_change_complete);
 	}
 	if (x < 0) {
 		if (is_pause)
-			dev->pausing = FALSE;
+			dev->pausing = false;
 		else
-			dev->resuming = FALSE;
+			dev->resuming = false;
 		goto away;
 	}
 	rc = 0;
@@ -2019,13 +2019,13 @@ away:
 static void
 chipset_device_pause(u32 bus_no, u32 dev_no)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, TRUE);
+	initiate_chipset_device_pause_resume(bus_no, dev_no, true);
 }
 
 static void
 chipset_device_resume(u32 bus_no, u32 dev_no)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, FALSE);
+	initiate_chipset_device_pause_resume(bus_no, dev_no, false);
 }
 
 struct channel_size_info {
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index ed652a0..bf1e039 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -33,7 +33,7 @@ struct visorchannel {
 	struct channel_header chan_hdr;
 	uuid_le guid;
 	ulong size;
-	BOOL needs_lock;	/* channel creator knows if more than one
+	bool needs_lock;	/* channel creator knows if more than one
 				 * thread will be inserting or removing */
 	spinlock_t insert_lock; /* protect head writes in chan_hdr */
 	spinlock_t remove_lock;	/* protect tail writes in chan_hdr */
@@ -51,7 +51,7 @@ struct visorchannel {
  */
 static struct visorchannel *
 visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
-			 ulong off, uuid_le guid, BOOL needs_lock)
+			 ulong off, uuid_le guid, bool needs_lock)
 {
 	struct visorchannel *channel;
 	int err;
@@ -115,7 +115,7 @@ struct visorchannel *
 visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
 {
 	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
-					FALSE);
+					false);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create);
 
@@ -124,7 +124,7 @@ visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
 			      uuid_le guid)
 {
 	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
-					TRUE);
+					true);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
 
@@ -292,26 +292,26 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
 			    &((sig_hdr)->FIELD),			 \
 			    sizeof((sig_hdr)->FIELD)) >= 0)
 
-static BOOL
+static bool
 sig_read_header(struct visorchannel *channel, u32 queue,
 		struct signal_queue_header *sig_hdr)
 {
 	int err;
 
 	if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
-		return FALSE;
+		return false;
 
 	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
 	err = visorchannel_read(channel,
 				SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
 				sig_hdr, sizeof(struct signal_queue_header));
 	if (err)
-		return FALSE;
+		return false;
 
-	return TRUE;
+	return true;
 }
 
-static inline BOOL
+static inline bool
 sig_read_data(struct visorchannel *channel, u32 queue,
 	      struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
@@ -322,12 +322,12 @@ sig_read_data(struct visorchannel *channel, u32 queue,
 	err = visorchannel_read(channel, signal_data_offset,
 				data, sig_hdr->signal_size);
 	if (err)
-		return FALSE;
+		return false;
 
-	return TRUE;
+	return true;
 }
 
-static inline BOOL
+static inline bool
 sig_write_data(struct visorchannel *channel, u32 queue,
 	       struct signal_queue_header *sig_hdr, u32 slot, void *data)
 {
@@ -338,24 +338,24 @@ sig_write_data(struct visorchannel *channel, u32 queue,
 	err = visorchannel_write(channel, signal_data_offset,
 				 data, sig_hdr->signal_size);
 	if (err)
-		return FALSE;
+		return false;
 
-	return TRUE;
+	return true;
 }
 
-static BOOL
+static bool
 signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
 {
 	struct signal_queue_header sig_hdr;
 
 	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
+		return false;
 	if (sig_hdr.head == sig_hdr.tail)
-		return FALSE;	/* no signals to remove */
+		return false;	/* no signals to remove */
 
 	sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
 	if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
-		return FALSE;
+		return false;
 	sig_hdr.num_received++;
 
 	/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
@@ -363,16 +363,16 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
 	 */
 	mb(); /* required for channel synch */
 	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
-		return FALSE;
+		return false;
 	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
-		return FALSE;
-	return TRUE;
+		return false;
+	return true;
 }
 
-BOOL
+bool
 visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
 {
-	BOOL rc;
+	bool rc;
 
 	if (channel->needs_lock) {
 		spin_lock(&channel->remove_lock);
@@ -386,13 +386,13 @@ visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalremove);
 
-static BOOL
+static bool
 signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 {
 	struct signal_queue_header sig_hdr;
 
 	if (!sig_read_header(channel, queue, &sig_hdr))
-		return FALSE;
+		return false;
 
 	sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
 	if (sig_hdr.head == sig_hdr.tail) {
@@ -403,11 +403,11 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 					    num_overflows),
 				   &(sig_hdr.num_overflows),
 				   sizeof(sig_hdr.num_overflows));
-		return FALSE;
+		return false;
 	}
 
 	if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
-		return FALSE;
+		return false;
 
 	sig_hdr.num_sent++;
 
@@ -416,17 +416,17 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 	 */
 	mb(); /* required for channel synch */
 	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
-		return FALSE;
+		return false;
 	if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
-		return FALSE;
+		return false;
 
-	return TRUE;
+	return true;
 }
 
-BOOL
+bool
 visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
 {
-	BOOL rc;
+	bool rc;
 
 	if (channel->needs_lock) {
 		spin_lock(&channel->insert_lock);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index d93ac15..76923bf 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2045,7 +2045,7 @@ parahotplug_process_message(struct controlvm_message *inmsg)
 
 /* Process a controlvm message.
  * Return result:
- *    false - this function will return FALSE only in the case where the
+ *    false - this function will return false only in the case where the
  *            controlvm message was NOT processed, but processing must be
  *            retried before reading the next controlvm message; a
  *            scenario where this can occur is when we need to throttle
diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c
index c91752a..f222719 100644
--- a/drivers/staging/unisys/visorutil/charqueue.c
+++ b/drivers/staging/unisys/visorutil/charqueue.c
@@ -64,9 +64,9 @@ void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c)
 }
 EXPORT_SYMBOL_GPL(visor_charqueue_enqueue);
 
-BOOL visor_charqueue_is_empty(struct charqueue *charqueue)
+bool visor_charqueue_is_empty(struct charqueue *charqueue)
 {
-	BOOL b;
+	bool b;
 
 	spin_lock(&charqueue->lock);
 	b = IS_EMPTY(charqueue);
diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h
index f46a776..70fe26b 100644
--- a/drivers/staging/unisys/visorutil/charqueue.h
+++ b/drivers/staging/unisys/visorutil/charqueue.h
@@ -30,7 +30,7 @@ void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c);
 int charqueue_dequeue(struct charqueue *charqueue);
 int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf,
 			      int n);
-BOOL visor_charqueue_is_empty(struct charqueue *charqueue);
+bool visor_charqueue_is_empty(struct charqueue *charqueue);
 void visor_charqueue_destroy(struct charqueue *charqueue);
 
 #endif
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c
index abbfb48..aa357a2 100644
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ b/drivers/staging/unisys/visorutil/periodic_work.c
@@ -29,8 +29,8 @@ struct periodic_work {
 	struct delayed_work work;
 	void (*workfunc)(void *);
 	void *workfuncarg;
-	BOOL is_scheduled;
-	BOOL want_to_stop;
+	bool is_scheduled;
+	bool want_to_stop;
 	ulong jiffy_interval;
 	struct workqueue_struct *workqueue;
 	const char *devnam;
@@ -74,64 +74,64 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_destroy);
 
 /** Call this from your periodic work worker function to schedule the next
  *  call.
- *  If this function returns FALSE, there was a failure and the
+ *  If this function returns false, there was a failure and the
  *  periodic work is no longer scheduled
  */
-BOOL visor_periodic_work_nextperiod(struct periodic_work *pw)
+bool visor_periodic_work_nextperiod(struct periodic_work *pw)
 {
-	BOOL rc = FALSE;
+	bool rc = false;
 
 	write_lock(&pw->lock);
 	if (pw->want_to_stop) {
-		pw->is_scheduled = FALSE;
-		pw->want_to_stop = FALSE;
-		rc = TRUE;  /* yes, TRUE; see visor_periodic_work_stop() */
+		pw->is_scheduled = false;
+		pw->want_to_stop = false;
+		rc = true;  /* yes, true; see visor_periodic_work_stop() */
 		goto unlock;
 	} else if (queue_delayed_work(pw->workqueue, &pw->work,
 				      pw->jiffy_interval) < 0) {
-		pw->is_scheduled = FALSE;
-		rc = FALSE;
+		pw->is_scheduled = false;
+		rc = false;
 		goto unlock;
 	}
-	rc = TRUE;
+	rc = true;
 unlock:
 	write_unlock(&pw->lock);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod);
 
-/** This function returns TRUE iff new periodic work was actually started.
- *  If this function returns FALSE, then no work was started
+/** This function returns true iff new periodic work was actually started.
+ *  If this function returns false, then no work was started
  *  (either because it was already started, or because of a failure).
  */
-BOOL visor_periodic_work_start(struct periodic_work *pw)
+bool visor_periodic_work_start(struct periodic_work *pw)
 {
-	BOOL rc = FALSE;
+	bool rc = false;
 
 	write_lock(&pw->lock);
 	if (pw->is_scheduled) {
-		rc = FALSE;
+		rc = false;
 		goto unlock;
 	}
 	if (pw->want_to_stop) {
-		rc = FALSE;
+		rc = false;
 		goto unlock;
 	}
 	INIT_DELAYED_WORK(&pw->work, &periodic_work_func);
 	if (queue_delayed_work(pw->workqueue, &pw->work,
 			       pw->jiffy_interval) < 0) {
-		rc = FALSE;
+		rc = false;
 		goto unlock;
 	}
-	pw->is_scheduled = TRUE;
-	rc = TRUE;
+	pw->is_scheduled = true;
+	rc = true;
 unlock:
 	write_unlock(&pw->lock);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(visor_periodic_work_start);
 
-/** This function returns TRUE iff your call actually stopped the periodic
+/** This function returns true iff your call actually stopped the periodic
  *  work.
  *
  *  -- PAY ATTENTION... this is important --
@@ -165,20 +165,20 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_start);
  *     this deadlock, you will get hung up in an infinite loop saying
  *     "waiting for delayed work...".
  */
-BOOL visor_periodic_work_stop(struct periodic_work *pw)
+bool visor_periodic_work_stop(struct periodic_work *pw)
 {
-	BOOL stopped_something = FALSE;
+	bool stopped_something = false;
 
 	write_lock(&pw->lock);
 	stopped_something = pw->is_scheduled && (!pw->want_to_stop);
 	while (pw->is_scheduled) {
-		pw->want_to_stop = TRUE;
+		pw->want_to_stop = true;
 		if (cancel_delayed_work(&pw->work)) {
 			/* We get here if the delayed work was pending as
 			 * delayed work, but was NOT run.
 			 */
 			WARN_ON(!pw->is_scheduled);
-			pw->is_scheduled = FALSE;
+			pw->is_scheduled = false;
 		} else {
 			/* If we get here, either the delayed work:
 			 * - was run, OR,
@@ -195,7 +195,7 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw)
 			SLEEPJIFFIES(10);
 			write_lock(&pw->lock);
 		} else {
-			pw->want_to_stop = FALSE;
+			pw->want_to_stop = false;
 		}
 	}
 	write_unlock(&pw->lock);
diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c
index 62f0f70..0b8f5c1 100644
--- a/drivers/staging/unisys/visorutil/visorkmodutils.c
+++ b/drivers/staging/unisys/visorutil/visorkmodutils.c
@@ -53,7 +53,7 @@ static __init uint32_t visorutil_spar_detect(void)
 static __init int visorutil_mod_init(void)
 {
 	if (visorutil_spar_detect()) {
-		unisys_spar_platform = TRUE;
+		unisys_spar_platform = true;
 		return 0;
 	} else {
 		return -ENODEV;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 085/141] staging: unisys: add acpi pnp driver
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (83 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 084/141] staging: unisys: remove BOOL,TRUE,FALSE definitions Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 086/141] staging: unisys: add ACPI and PCI requirement to Kconfig Benjamin Romer
                   ` (58 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Prarit Bhargava, driverdev-devel, sparmaintainer, Benjamin Romer

From: Prarit Bhargava <prarit@redhat.com>

According to Unisys, another OS detects the PNP0A07 as the auto load
device.  We can also do this in the linux kernel by simply converting the
driver over to the ACPI driver model.

Notes: This changes the usage of __init and it had to be removed from some
functions to avoid a !__init function calling an __init function.
Additionally I also cleaned up the headers in visorchipset.c since I was
adding a header file.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    |  2 +-
 drivers/staging/unisys/visorbus/visorbus_private.h |  2 +-
 drivers/staging/unisys/visorbus/visorchipset.c     | 77 ++++++++++++++++------
 3 files changed, 58 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index f7976ca..b522ea4 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -2034,7 +2034,7 @@ struct channel_size_info {
 	unsigned long max_size;
 };
 
-int __init
+int
 visorbus_init(void)
 {
 	int rc = 0;
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index f9a5e01..1153c99 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -155,6 +155,6 @@ bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
 bool visorchipset_set_bus_context(u32 bus_no, void *context);
 
 /* visorbus init and exit functions */
-int __init visorbus_init(void);
+int visorbus_init(void);
 void visorbus_exit(void);
 #endif
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 76923bf..fde8993 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -15,16 +15,7 @@
  * details.
  */
 
-#include "controlvmchannel.h"
-#include "version.h"
-#include "procobjecttree.h"
-#include "visorbus.h"
-#include "periodic_work.h"
-#include "uisutils.h"
-#include "controlvmcompletionstatus.h"
-#include "guestlinuxdebug.h"
-#include "visorbus_private.h"
-
+#include <linux/acpi.h>
 #include <linux/ctype.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
@@ -34,6 +25,16 @@
 #include <linux/uuid.h>
 #include <linux/crash_dump.h>
 
+#include "controlvmchannel.h"
+#include "controlvmcompletionstatus.h"
+#include "guestlinuxdebug.h"
+#include "periodic_work.h"
+#include "procobjecttree.h"
+#include "uisutils.h"
+#include "version.h"
+#include "visorbus.h"
+#include "visorbus_private.h"
+
 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
 
 #define MAX_NAME_SIZE 128
@@ -2637,17 +2638,12 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
 	return 0;
 }
 
-
-
-static int __init
-visorchipset_init(void)
+static int
+visorchipset_init(struct acpi_device *acpi_device)
 {
 	int rc = 0;
 	HOSTADDRESS addr;
 
-	if (!unisys_spar_platform)
-		return -ENODEV;
-
 	memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
 	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
 	memset(&livedump_info, 0, sizeof(livedump_info));
@@ -2733,8 +2729,8 @@ visorchipset_file_cleanup(dev_t major_dev)
 	unregister_chrdev_region(major_dev, 1);
 }
 
-static void
-visorchipset_exit(void)
+static int
+visorchipset_exit(struct acpi_device *acpi_device)
 {
 	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 
@@ -2754,6 +2750,45 @@ visorchipset_exit(void)
 
 	visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
 	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
+
+	return 0;
+}
+
+static const struct acpi_device_id unisys_device_ids[] = {
+	{"PNP0A07", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, unisys_device_ids);
+
+static struct acpi_driver unisys_acpi_driver = {
+	.name = "unisys_acpi",
+	.class = "unisys_acpi_class",
+	.owner = THIS_MODULE,
+	.ids = unisys_device_ids,
+	.ops = {
+		.add = visorchipset_init,
+		.remove = visorchipset_exit,
+		},
+};
+
+static int init_unisys(void)
+{
+	int result;
+
+	if (!unisys_spar_platform)
+		return -ENODEV;
+
+	result = acpi_bus_register_driver(&unisys_acpi_driver);
+	if (result)
+		return -ENODEV;
+
+	pr_info("Unisys Visorchipset Driver Loaded.\n");
+	return 0;
+};
+
+static void exit_unisys(void)
+{
+	acpi_bus_unregister_driver(&unisys_acpi_driver);
 }
 
 module_param_named(major, visorchipset_major, int, S_IRUGO);
@@ -2767,8 +2802,8 @@ module_param_named(holdchipsetready, visorchipset_holdchipsetready,
 MODULE_PARM_DESC(visorchipset_holdchipsetready,
 		 "1 to hold response to CHIPSET_READY");
 
-module_init(visorchipset_init);
-module_exit(visorchipset_exit);
+module_init(init_unisys);
+module_exit(exit_unisys);
 
 MODULE_AUTHOR("Unisys");
 MODULE_LICENSE("GPL");
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 086/141] staging: unisys: add ACPI and PCI requirement to Kconfig
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (84 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 085/141] staging: unisys: add acpi pnp driver Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 087/141] staging: unisys: move timskmod.h functionality Benjamin Romer
                   ` (57 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Benjamin Romer

Later patches will require PCI and ACPI support in the kernel, so add these
features to the Kconfig.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index 50223c7..e0562f1 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -4,6 +4,8 @@
 menuconfig UNISYSSPAR
 	bool "Unisys SPAR driver support"
 	depends on X86_64
+	select PCI
+	select ACPI
 	---help---
 	Support for the Unisys SPAR drivers
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 087/141] staging: unisys: move timskmod.h functionality
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (85 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 086/141] staging: unisys: add ACPI and PCI requirement to Kconfig Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 088/141] staging: unisys: remove charqueue.c Benjamin Romer
                   ` (56 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes all timksmod.h pound defines. It also removes
visorkmodutils.c since it no longer has any use by itself. Since
visorkmodutils.c is no longer needed the module_init for
visorchipset.c is modified to call visorutil_spar_detect directly
instead of the extern variable in timksmod.h.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/periodic_work.h     |  1 +
 drivers/staging/unisys/include/timskmod.h          | 94 ----------------------
 drivers/staging/unisys/include/visorbus.h          | 10 +--
 drivers/staging/unisys/visorbus/visorbus_main.c    |  9 ++-
 drivers/staging/unisys/visorbus/visorbus_private.h |  2 +-
 drivers/staging/unisys/visorbus/visorchannel.c     | 14 ++--
 drivers/staging/unisys/visorbus/visorchipset.c     | 38 ++++++---
 drivers/staging/unisys/visorutil/Makefile          |  2 +-
 drivers/staging/unisys/visorutil/periodic_work.c   |  4 +-
 drivers/staging/unisys/visorutil/visorkmodutils.c  | 71 ----------------
 10 files changed, 50 insertions(+), 195 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorutil/visorkmodutils.c

diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h
index 21939db..65bad08 100644
--- a/drivers/staging/unisys/include/periodic_work.h
+++ b/drivers/staging/unisys/include/periodic_work.h
@@ -20,6 +20,7 @@
 
 #include "timskmod.h"
 
+
 /* PERIODIC_WORK an opaque structure to users.
  * Fields are declared only in the implementation .c files.
  */
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h
index 2ee2275..30d8e7a 100644
--- a/drivers/staging/unisys/include/timskmod.h
+++ b/drivers/staging/unisys/include/timskmod.h
@@ -51,98 +51,4 @@
 #include <linux/seq_file.h>
 #include <linux/mm.h>
 
-/* #define DEBUG */
-#if !defined SUCCESS
-#define SUCCESS 0
-#endif
-#define MIN(a, b)     (((a) < (b)) ? (a) : (b))
-#define MAX(a, b)     (((a) > (b)) ? (a) : (b))
-#define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0)
-#ifndef HOSTADDRESS
-#define HOSTADDRESS unsigned long long
-#endif
-
-#define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
-/** "Covered quotient" function */
-#define COVQ(v, d)  (((v) + (d) - 1) / (d))
-#define SWAPPOINTERS(p1, p2)				\
-	do {						\
-		void *SWAPPOINTERS_TEMP = (void *)p1;	\
-		(void *)(p1) = (void *)(p2);            \
-		(void *)(p2) = SWAPPOINTERS_TEMP;	\
-	} while (0)
-
-#define WARNDRV(fmt, args...)   LOGWRN(fmt, ## args)
-#define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args)
-
-#define PRINTKDEV(devname, fmt, args...)  LOGINFDEV(devname, fmt, ## args)
-#define TBDDEV(devname, fmt, args...)     LOGERRDEV(devname, fmt, ## args)
-#define HUHDEV(devname, fmt, args...)     LOGERRDEV(devname, fmt, ## args)
-#define ERRDEV(devname, fmt, args...)     LOGERRDEV(devname, fmt, ## args)
-#define ERRDEVX(devno, fmt, args...)	  LOGERRDEVX(devno, fmt, ## args)
-#define WARNDEV(devname, fmt, args...)    LOGWRNDEV(devname, fmt, ## args)
-#define SECUREDEV(devname, fmt, args...)  LOGWRNDEV(devname, fmt, ## args)
-#define INFODEV(devname, fmt, args...)    LOGINFDEV(devname, fmt, ## args)
-#define INFODEVX(devno, fmt, args...)     LOGINFDEVX(devno, fmt, ## args)
-
-/** Verifies the consistency of your PRIVATEDEVICEDATA structure using
- *  conventional "signature" fields:
- *  <p>
- *  - sig1 should contain the size of the structure
- *  - sig2 should contain a pointer to the beginning of the structure
- */
-#define DDLOOKSVALID(dd)                                 \
-		((dd != NULL)                             &&	\
-		 ((dd)->sig1 == sizeof(PRIVATEDEVICEDATA)) &&	\
-		 ((dd)->sig2 == dd))
-
-/** Verifies the consistency of your PRIVATEFILEDATA structure using
- *  conventional "signature" fields:
- *  <p>
- *  - sig1 should contain the size of the structure
- *  - sig2 should contain a pointer to the beginning of the structure
- */
-#define FDLOOKSVALID(fd)                               \
-	((fd != NULL)                           &&     \
-	 ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) &&    \
-	 ((fd)->sig2 == fd))
-
-/** Sleep for an indicated number of seconds (for use in kernel mode).
- *  x - the number of seconds to sleep.
- */
-#define SLEEP(x)					     \
-	do { __set_current_state(TASK_INTERRUPTIBLE);        \
-		schedule_timeout((x)*HZ);		     \
-	} while (0)
-
-/** Sleep for an indicated number of jiffies (for use in kernel mode).
- *  x - the number of jiffies to sleep.
- */
-#define SLEEPJIFFIES(x)						    \
-	do { __set_current_state(TASK_INTERRUPTIBLE);		    \
-		schedule_timeout(x);				    \
-	} while (0)
-
-static inline struct cdev *cdev_alloc_init(struct module *owner,
-					   const struct file_operations *fops)
-{
-	struct cdev *cdev = NULL;
-
-	cdev = cdev_alloc();
-	if (!cdev)
-		return NULL;
-	cdev->ops = fops;
-	cdev->owner = owner;
-
-	/* Note that the memory allocated for cdev will be deallocated
-	 * when the usage count drops to 0, because it is controlled
-	 * by a kobject of type ktype_cdev_dynamic.  (This
-	 * deallocation could very well happen outside of our kernel
-	 * module, like via the cdev_put in __fput() for example.)
-	 */
-	return cdev;
-}
-
-extern int unisys_spar_platform;
-
 #endif
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index bce8aa2..f97e203 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -37,10 +37,6 @@
 #include "periodic_work.h"
 #include "channel.h"
 
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-
 struct visor_driver;
 struct visor_device;
 
@@ -170,9 +166,9 @@ void visorbus_disable_channel_interrupts(struct visor_device *dev);
  * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
  * In this case, the values can simply be read from the channel header.
  */
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
+struct visorchannel *visorchannel_create(u64 physaddr,
 					 ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
+struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
 						   ulong channel_bytes,
 						   uuid_le guid);
 void visorchannel_destroy(struct visorchannel *channel);
@@ -189,7 +185,7 @@ bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
 int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
 					 u32 queue);
 int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
+u64 visorchannel_get_physaddr(struct visorchannel *channel);
 ulong visorchannel_get_nbytes(struct visorchannel *channel);
 char *visorchannel_id(struct visorchannel *channel, char *s);
 char *visorchannel_zoneid(struct visorchannel *channel, char *s);
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index b522ea4..914298b 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1428,7 +1428,7 @@ remove_visor_device(struct visor_device *dev)
 }
 
 static struct visor_device *
-find_visor_device_by_channel(HOSTADDRESS channel_physaddr)
+find_visor_device_by_channel(u64 channel_physaddr)
 {
 	struct list_head *listentry, *listtmp;
 
@@ -1607,8 +1607,9 @@ fix_vbus_dev_info(struct visor_device *visordev)
 	 * type name
 	 */
 	for (i = 0; visordrv->channel_types[i].name; i++) {
-		if (STRUCTSEQUAL(visordrv->channel_types[i].guid,
-				 visordev->channel_type_guid)) {
+		if (memcmp(&visordrv->channel_types[i].guid,
+			   &visordev->channel_type_guid,
+			   sizeof(visordrv->channel_types[i].guid)) == 0) {
 			chan_type_name = visordrv->channel_types[i].name;
 			break;
 		}
@@ -1667,7 +1668,7 @@ create_bus_instance(int id)
 	if ((visorchipset_get_bus_info(id, &bus_info)) &&
 	    (bus_info.chan_info.channel_addr > 0) &&
 	    (bus_info.chan_info.n_channel_bytes > 0)) {
-		HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr;
+		u64 channel_addr = bus_info.chan_info.channel_addr;
 		unsigned long n_channel_bytes =
 				(unsigned long)
 				bus_info.chan_info.n_channel_bytes;
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 1153c99..32e26ed 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -54,7 +54,7 @@ enum visorchipset_addresstype {
  */
 struct visorchipset_channel_info {
 	enum visorchipset_addresstype addr_type;
-	HOSTADDRESS channel_addr;
+	u64 channel_addr;
 	struct irq_info intr;
 	u64 n_channel_bytes;
 	uuid_le channel_type_uuid;
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index bf1e039..44ea434 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -27,7 +27,7 @@
 #define MYDRVNAME "visorchannel"
 
 struct visorchannel {
-	HOSTADDRESS physaddr;
+	u64 physaddr;
 	ulong nbytes;
 	void __iomem *mapped;
 	struct channel_header chan_hdr;
@@ -50,7 +50,7 @@ struct visorchannel {
  * but does NOT modify this data area.
  */
 static struct visorchannel *
-visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
+visorchannel_create_guts(u64 physaddr, ulong channel_bytes,
 			 ulong off, uuid_le guid, bool needs_lock)
 {
 	struct visorchannel *channel;
@@ -112,7 +112,7 @@ cleanup:
 }
 
 struct visorchannel *
-visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
+visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid)
 {
 	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
 					false);
@@ -120,7 +120,7 @@ visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
 EXPORT_SYMBOL_GPL(visorchannel_create);
 
 struct visorchannel *
-visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
+visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes,
 			      uuid_le guid)
 {
 	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
@@ -141,7 +141,7 @@ visorchannel_destroy(struct visorchannel *channel)
 }
 EXPORT_SYMBOL_GPL(visorchannel_destroy);
 
-HOSTADDRESS
+u64
 visorchannel_get_physaddr(struct visorchannel *channel)
 {
 	return channel->physaddr;
@@ -177,7 +177,7 @@ visorchannel_zoneid(struct visorchannel *channel, char *s)
 }
 EXPORT_SYMBOL_GPL(visorchannel_zoneid);
 
-HOSTADDRESS
+u64
 visorchannel_get_clientpartition(struct visorchannel *channel)
 {
 	return channel->chan_hdr.partition_handle;
@@ -498,7 +498,7 @@ void
 visorchannel_debug(struct visorchannel *channel, int num_queues,
 		   struct seq_file *seq, u32 off)
 {
-	HOSTADDRESS addr = 0;
+	u64 addr = 0;
 	ulong nbytes = 0, nbytes_region = 0;
 	struct channel_header hdr;
 	struct channel_header *phdr = &hdr;
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index fde8993..8ff79c0 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -47,6 +47,14 @@
 
 #define VISORCHIPSET_MMAP_CONTROLCHANOFFSET	0x00000000
 
+
+#define UNISYS_SPAR_LEAF_ID 0x40000000
+
+/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
+#define UNISYS_SPAR_ID_EBX 0x73696e55
+#define UNISYS_SPAR_ID_ECX 0x70537379
+#define UNISYS_SPAR_ID_EDX 0x34367261
+
 /*
  * Module parameters
  */
@@ -1675,7 +1683,7 @@ my_device_destroy(struct controlvm_message *inmsg)
  * for failure.
  */
 static int
-initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
+initialize_controlvm_payload_info(u64 phys_addr, u64 offset, u32 bytes,
 				  struct visor_controlvm_payload_info *info)
 {
 	u8 __iomem *payload = NULL;
@@ -1723,7 +1731,7 @@ destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
 static void
 initialize_controlvm_payload(void)
 {
-	HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
+	u64 phys_addr = visorchannel_get_physaddr(controlvm_channel);
 	u64 payload_offset = 0;
 	u32 payload_bytes = 0;
 
@@ -2056,7 +2064,7 @@ parahotplug_process_message(struct controlvm_message *inmsg)
  *            either successfully or with an error.
  */
 static bool
-handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
+handle_command(struct controlvm_message inmsg, u64 channel_addr)
 {
 	struct controlvm_message_packet *cmd = &inmsg.cmd;
 	u64 parm_addr;
@@ -2152,7 +2160,7 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
 	return true;
 }
 
-static HOSTADDRESS controlvm_get_channel_address(void)
+static u64 controlvm_get_channel_address(void)
 {
 	u64 addr = 0;
 	u32 size = 0;
@@ -2589,7 +2597,7 @@ static long visorchipset_ioctl(struct file *file, unsigned int cmd,
 				 sizeof(vrtc_offset))) {
 			return -EFAULT;
 		}
-		return SUCCESS;
+		return 0;
 	case VMCALL_UPDATE_PHYSICAL_TIME:
 		if (copy_from_user(&adjustment, (void __user *)arg,
 				   sizeof(adjustment))) {
@@ -2642,7 +2650,7 @@ static int
 visorchipset_init(struct acpi_device *acpi_device)
 {
 	int rc = 0;
-	HOSTADDRESS addr;
+	u64 addr;
 
 	memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
 	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
@@ -2758,7 +2766,6 @@ static const struct acpi_device_id unisys_device_ids[] = {
 	{"PNP0A07", 0},
 	{"", 0},
 };
-MODULE_DEVICE_TABLE(acpi, unisys_device_ids);
 
 static struct acpi_driver unisys_acpi_driver = {
 	.name = "unisys_acpi",
@@ -2770,12 +2777,25 @@ static struct acpi_driver unisys_acpi_driver = {
 		.remove = visorchipset_exit,
 		},
 };
+static __init uint32_t visorutil_spar_detect(void)
+{
+	unsigned int eax, ebx, ecx, edx;
+
+	if (cpu_has_hypervisor) {
+		/* check the ID */
+		cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
+		return  (ebx == UNISYS_SPAR_ID_EBX) &&
+			(ecx == UNISYS_SPAR_ID_ECX) &&
+			(edx == UNISYS_SPAR_ID_EDX);
+	} else {
+		return 0;
+	}
+}
 
 static int init_unisys(void)
 {
 	int result;
-
-	if (!unisys_spar_platform)
+	if (!visorutil_spar_detect())
 		return -ENODEV;
 
 	result = acpi_bus_register_driver(&unisys_acpi_driver);
diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile
index f299787..88db085 100644
--- a/drivers/staging/unisys/visorutil/Makefile
+++ b/drivers/staging/unisys/visorutil/Makefile
@@ -4,6 +4,6 @@
 
 obj-$(CONFIG_UNISYS_VISORUTIL)	+= visorutil.o
 
-visorutil-y := charqueue.o periodic_work.o visorkmodutils.o
+visorutil-y := charqueue.o periodic_work.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c
index aa357a2..aa0c1f8 100644
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ b/drivers/staging/unisys/visorutil/periodic_work.c
@@ -18,6 +18,7 @@
 /*
  *  Helper functions to schedule periodic work in Linux kernel mode.
  */
+#include <linux/sched.h>
 
 #include "timskmod.h"
 #include "periodic_work.h"
@@ -192,7 +193,8 @@ bool visor_periodic_work_stop(struct periodic_work *pw)
 		}
 		if (pw->is_scheduled) {
 			write_unlock(&pw->lock);
-			SLEEPJIFFIES(10);
+			__set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(10);
 			write_lock(&pw->lock);
 		} else {
 			pw->want_to_stop = false;
diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c
deleted file mode 100644
index 0b8f5c1..0000000
--- a/drivers/staging/unisys/visorutil/visorkmodutils.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* timskmodutils.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#include "timskmod.h"
-
-#define MYDRVNAME "timskmodutils"
-
-/* s-Par uses the Intel processor's VT-X features to separate groups of
- * processors into partitions. The firmware sets the hypervisor bit and
- * reports an ID in the HV capabilities leaf so that the partition's OS
- * knows s-Par is present and managing the processors.
- */
-
-#define UNISYS_SPAR_LEAF_ID 0x40000000
-
-/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
-#define UNISYS_SPAR_ID_EBX 0x73696e55
-#define UNISYS_SPAR_ID_ECX 0x70537379
-#define UNISYS_SPAR_ID_EDX 0x34367261
-
-int unisys_spar_platform;
-EXPORT_SYMBOL_GPL(unisys_spar_platform);
-
-static __init uint32_t visorutil_spar_detect(void)
-{
-	unsigned int eax, ebx, ecx, edx;
-
-	if (cpu_has_hypervisor) {
-		/* check the ID */
-		cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
-		return  (ebx == UNISYS_SPAR_ID_EBX) &&
-			(ecx == UNISYS_SPAR_ID_ECX) &&
-			(edx == UNISYS_SPAR_ID_EDX);
-	} else {
-		return 0;
-	}
-}
-
-static __init int visorutil_mod_init(void)
-{
-	if (visorutil_spar_detect()) {
-		unisys_spar_platform = true;
-		return 0;
-	} else {
-		return -ENODEV;
-	}
-}
-
-static __exit void
-visorutil_mod_exit(void)
-{
-}
-
-module_init(visorutil_mod_init);
-module_exit(visorutil_mod_exit);
-
-MODULE_LICENSE("GPL");
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 088/141] staging: unisys: remove charqueue.c
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (86 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 087/141] staging: unisys: move timskmod.h functionality Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 089/141] staging: unisys: remove timskmod.h and procobjecttree.h Benjamin Romer
                   ` (55 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, Erik Arfvidson, Benjamin Romer

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes charqueue.[ch] since it no longer called

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorutil/Makefile    |   2 +-
 drivers/staging/unisys/visorutil/charqueue.c | 127 ---------------------------
 drivers/staging/unisys/visorutil/charqueue.h |  37 --------
 3 files changed, 1 insertion(+), 165 deletions(-)
 delete mode 100644 drivers/staging/unisys/visorutil/charqueue.c
 delete mode 100644 drivers/staging/unisys/visorutil/charqueue.h

diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile
index 88db085..8f6a3e3 100644
--- a/drivers/staging/unisys/visorutil/Makefile
+++ b/drivers/staging/unisys/visorutil/Makefile
@@ -4,6 +4,6 @@
 
 obj-$(CONFIG_UNISYS_VISORUTIL)	+= visorutil.o
 
-visorutil-y := charqueue.o periodic_work.o
+visorutil-y := periodic_work.o
 
 ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c
deleted file mode 100644
index f222719..0000000
--- a/drivers/staging/unisys/visorutil/charqueue.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* charqueue.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  Simple character queue implementation for Linux kernel mode.
- */
-
-#include "charqueue.h"
-
-#define MYDRVNAME "charqueue"
-
-#define IS_EMPTY(charqueue) (charqueue->head == charqueue->tail)
-
-struct charqueue {
-	int alloc_size;
-	int nslots;
-	spinlock_t lock; /* read/write lock for this structure */
-	int head, tail;
-	unsigned char buf[0];
-};
-
-struct charqueue *visor_charqueue_create(ulong nslots)
-{
-	int alloc_size = sizeof(struct charqueue) + nslots + 1;
-	struct charqueue *cq;
-
-	cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY);
-	if (cq == NULL)
-		return NULL;
-	cq->alloc_size = alloc_size;
-	cq->nslots = nslots;
-	cq->head = 0;
-	cq->tail = 0;
-	spin_lock_init(&cq->lock);
-	return cq;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_create);
-
-void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c)
-{
-	int alloc_slots = charqueue->nslots+1;  /* 1 slot is always empty */
-
-	spin_lock(&charqueue->lock);
-	charqueue->head = (charqueue->head+1) % alloc_slots;
-	if (charqueue->head == charqueue->tail)
-		/* overflow; overwrite the oldest entry */
-		charqueue->tail = (charqueue->tail+1) % alloc_slots;
-	charqueue->buf[charqueue->head] = c;
-	spin_unlock(&charqueue->lock);
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_enqueue);
-
-bool visor_charqueue_is_empty(struct charqueue *charqueue)
-{
-	bool b;
-
-	spin_lock(&charqueue->lock);
-	b = IS_EMPTY(charqueue);
-	spin_unlock(&charqueue->lock);
-	return b;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_is_empty);
-
-static int charqueue_dequeue_1(struct charqueue *charqueue)
-{
-	int alloc_slots = charqueue->nslots + 1;  /* 1 slot is always empty */
-
-	if (IS_EMPTY(charqueue))
-		return -1;
-	charqueue->tail = (charqueue->tail+1) % alloc_slots;
-	return charqueue->buf[charqueue->tail];
-}
-
-int charqueue_dequeue(struct charqueue *charqueue)
-{
-	int rc;
-
-	spin_lock(&charqueue->lock);
-	rc = charqueue_dequeue_1(charqueue);
-	spin_unlock(&charqueue->lock);
-	return rc;
-}
-
-int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf,
-			      int n)
-{
-	int rc, counter = 0, c;
-
-	spin_lock(&charqueue->lock);
-	for (;;) {
-		if (n <= 0)
-			break;  /* no more buffer space */
-		c = charqueue_dequeue_1(charqueue);
-		if (c < 0)
-			break;  /* no more input */
-		*buf = (unsigned char)(c);
-		buf++;
-		n--;
-		counter++;
-	}
-	rc = counter;
-	spin_unlock(&charqueue->lock);
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_dequeue_n);
-
-void visor_charqueue_destroy(struct charqueue *charqueue)
-{
-	if (charqueue == NULL)
-		return;
-	kfree(charqueue);
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_destroy);
diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h
deleted file mode 100644
index 70fe26b..0000000
--- a/drivers/staging/unisys/visorutil/charqueue.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* charqueue.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CHARQUEUE_H__
-#define __CHARQUEUE_H__
-
-#include "timskmod.h"
-
-/* struct charqueue is an opaque structure to users.
- * Fields are declared only in the implementation .c files.
- */
-struct charqueue;
-
-struct charqueue *visor_charqueue_create(ulong nslots);
-void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c);
-int charqueue_dequeue(struct charqueue *charqueue);
-int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf,
-			      int n);
-bool visor_charqueue_is_empty(struct charqueue *charqueue);
-void visor_charqueue_destroy(struct charqueue *charqueue);
-
-#endif
-
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 089/141] staging: unisys: remove timskmod.h and procobjecttree.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (87 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 088/141] staging: unisys: remove charqueue.c Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 090/141] staging: unisys: move periodic_work.c into the visorbus directory Benjamin Romer
                   ` (54 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch move the needed linux include files from timskmod.h
to the files that calls those include. Also procobjecttree.h is
removed since it is dead code.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/periodic_work.h     |  3 +-
 drivers/staging/unisys/include/procobjecttree.h    | 47 -------------------
 drivers/staging/unisys/include/sparstop.h          |  1 -
 drivers/staging/unisys/include/timskmod.h          | 54 ----------------------
 drivers/staging/unisys/include/visorbus.h          |  1 +
 drivers/staging/unisys/visorbus/visorbus_main.c    |  1 -
 drivers/staging/unisys/visorbus/visorbus_private.h |  1 -
 drivers/staging/unisys/visorbus/visorchipset.c     |  2 +-
 drivers/staging/unisys/visorchannel/globals.h      |  1 -
 drivers/staging/unisys/visorutil/periodic_work.c   |  1 -
 10 files changed, 4 insertions(+), 108 deletions(-)
 delete mode 100644 drivers/staging/unisys/include/procobjecttree.h
 delete mode 100644 drivers/staging/unisys/include/timskmod.h

diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h
index 65bad08..4e19c28 100644
--- a/drivers/staging/unisys/include/periodic_work.h
+++ b/drivers/staging/unisys/include/periodic_work.h
@@ -18,7 +18,8 @@
 #ifndef __PERIODIC_WORK_H__
 #define __PERIODIC_WORK_H__
 
-#include "timskmod.h"
+#include <linux/seq_file.h>
+#include <linux/slab.h>
 
 
 /* PERIODIC_WORK an opaque structure to users.
diff --git a/drivers/staging/unisys/include/procobjecttree.h b/drivers/staging/unisys/include/procobjecttree.h
deleted file mode 100644
index 809c679..0000000
--- a/drivers/staging/unisys/include/procobjecttree.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* procobjecttree.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/** @file *********************************************************************
- *
- *  This describes the interfaces necessary for creating a tree of types,
- *  objects, and properties in /proc.
- *
- ******************************************************************************
- */
-
-#ifndef __PROCOBJECTTREE_H__
-#define __PROCOBJECTTREE_H__
-
-#include "timskmod.h"
-
-/* These are opaque structures to users.
- * Fields are declared only in the implementation .c files.
- */
-typedef struct MYPROCOBJECT_Tag MYPROCOBJECT;
-typedef struct MYPROCTYPE_Tag   MYPROCTYPE;
-
-MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, const char *name,
-				      void *context);
-void          visor_proc_DestroyObject(MYPROCOBJECT *obj);
-MYPROCTYPE   *visor_proc_CreateType(struct proc_dir_entry *procRootDir,
-				    const char **name,
-				    const char **propertyNames,
-				    void (*show_property)(struct seq_file *,
-							  void *, int));
-void          visor_proc_DestroyType(MYPROCTYPE *type);
-
-#endif
diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h
index 0583739..6150d2d 100644
--- a/drivers/staging/unisys/include/sparstop.h
+++ b/drivers/staging/unisys/include/sparstop.h
@@ -18,7 +18,6 @@
 #ifndef __SPARSTOP_H__
 #define __SPARSTOP_H__
 
-#include "timskmod.h"
 #include "version.h"
 #include <linux/ctype.h>
 
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h
deleted file mode 100644
index 30d8e7a..0000000
--- a/drivers/staging/unisys/include/timskmod.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* timskmod.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __TIMSKMOD_H__
-#define __TIMSKMOD_H__
-
-#include <linux/version.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/kobject.h>
-#include <linux/sysfs.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/wait.h>
-#include <linux/vmalloc.h>
-#include <linux/proc_fs.h>
-#include <linux/cdev.h>
-#include <linux/types.h>
-#include <asm/irq.h>
-#include <linux/io.h>
-#include <asm/dma.h>
-#include <linux/uaccess.h>
-#include <linux/list.h>
-#include <linux/poll.h>
-/* #define EXPORT_SYMTAB */
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/fcntl.h>
-#include <linux/workqueue.h>
-#include <linux/kthread.h>
-#include <linux/seq_file.h>
-#include <linux/mm.h>
-
-#endif
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index f97e203..0f1966c 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -31,6 +31,7 @@
 
 #include <linux/device.h>
 #include <linux/module.h>
+#include <linux/poll.h>
 #include <linux/kernel.h>
 #include <linux/uuid.h>
 
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 914298b..2e00e42 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -20,7 +20,6 @@
 #include "visorbus.h"
 #include "visorbus_private.h"
 #include "version.h"
-#include "timskmod.h"
 #include "periodic_work.h"
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 32e26ed..8326e4d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -22,7 +22,6 @@
 
 #include "channel.h"
 #include "controlvmchannel.h"
-#include "procobjecttree.h"
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 8ff79c0..776bf2e 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -16,6 +16,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/cdev.h>
 #include <linux/ctype.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
@@ -29,7 +30,6 @@
 #include "controlvmcompletionstatus.h"
 #include "guestlinuxdebug.h"
 #include "periodic_work.h"
-#include "procobjecttree.h"
 #include "uisutils.h"
 #include "version.h"
 #include "visorbus.h"
diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h
index 6530413..1c3c427 100644
--- a/drivers/staging/unisys/visorchannel/globals.h
+++ b/drivers/staging/unisys/visorchannel/globals.h
@@ -18,7 +18,6 @@
 #ifndef __VISORCHANNEL_GLOBALS_H__
 #define __VISORCHANNEL_GLOBALS_H__
 
-#include "timskmod.h"
 #include "version.h"
 
 #define MYDRVNAME "visorchannel"
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c
index aa0c1f8..3562e8b 100644
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ b/drivers/staging/unisys/visorutil/periodic_work.c
@@ -20,7 +20,6 @@
  */
 #include <linux/sched.h>
 
-#include "timskmod.h"
 #include "periodic_work.h"
 
 #define MYDRVNAME "periodic_work"
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 090/141] staging: unisys: move periodic_work.c into the visorbus directory
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (88 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 089/141] staging: unisys: remove timskmod.h and procobjecttree.h Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 091/141] staging: unisys: fix visorbus Kconfig Benjamin Romer
                   ` (53 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Erik Arfvidson

From: Erik Arfvidson <erik.arfvidson@unisys.com>

This patch removes visorutil directory, move periodic_work.c into
the visorbus directory.

Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Kconfig                   |   1 -
 drivers/staging/unisys/visorbus/Makefile         |   1 +
 drivers/staging/unisys/visorbus/periodic_work.c  | 205 +++++++++++++++++++++++
 drivers/staging/unisys/visorutil/Kconfig         |   9 -
 drivers/staging/unisys/visorutil/Makefile        |   9 -
 drivers/staging/unisys/visorutil/periodic_work.c | 205 -----------------------
 6 files changed, 206 insertions(+), 224 deletions(-)
 create mode 100644 drivers/staging/unisys/visorbus/periodic_work.c
 delete mode 100644 drivers/staging/unisys/visorutil/Kconfig
 delete mode 100644 drivers/staging/unisys/visorutil/Makefile
 delete mode 100644 drivers/staging/unisys/visorutil/periodic_work.c

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index e0562f1..0c3e9a1 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -11,7 +11,6 @@ menuconfig UNISYSSPAR
 
 if UNISYSSPAR
 
-source "drivers/staging/unisys/visorutil/Kconfig"
 source "drivers/staging/unisys/visorbus/Kconfig"
 
 endif # UNISYSSPAR
diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 16d3ff5..72d4d44 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_UNISYS_VISORBUS)	+= visorbus.o
 visorbus-y := visorbus_main.o
 visorbus-y += visorchannel.o
 visorbus-y += visorchipset.o
+visorbus-y += periodic_work.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
diff --git a/drivers/staging/unisys/visorbus/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c
new file mode 100644
index 0000000..3562e8b
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/periodic_work.c
@@ -0,0 +1,205 @@
+/* periodic_work.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ *  Helper functions to schedule periodic work in Linux kernel mode.
+ */
+#include <linux/sched.h>
+
+#include "periodic_work.h"
+
+#define MYDRVNAME "periodic_work"
+
+struct periodic_work {
+	rwlock_t lock;
+	struct delayed_work work;
+	void (*workfunc)(void *);
+	void *workfuncarg;
+	bool is_scheduled;
+	bool want_to_stop;
+	ulong jiffy_interval;
+	struct workqueue_struct *workqueue;
+	const char *devnam;
+};
+
+static void periodic_work_func(struct work_struct *work)
+{
+	struct periodic_work *pw;
+
+	pw = container_of(work, struct periodic_work, work.work);
+	(*pw->workfunc)(pw->workfuncarg);
+}
+
+struct periodic_work *visor_periodic_work_create(ulong jiffy_interval,
+					struct workqueue_struct *workqueue,
+					void (*workfunc)(void *),
+					void *workfuncarg,
+					const char *devnam)
+{
+	struct periodic_work *pw;
+
+	pw = kzalloc(sizeof(*pw), GFP_KERNEL | __GFP_NORETRY);
+	if (!pw)
+		return NULL;
+
+	rwlock_init(&pw->lock);
+	pw->jiffy_interval = jiffy_interval;
+	pw->workqueue = workqueue;
+	pw->workfunc = workfunc;
+	pw->workfuncarg = workfuncarg;
+	pw->devnam = devnam;
+	return pw;
+}
+EXPORT_SYMBOL_GPL(visor_periodic_work_create);
+
+void visor_periodic_work_destroy(struct periodic_work *pw)
+{
+	kfree(pw);
+}
+EXPORT_SYMBOL_GPL(visor_periodic_work_destroy);
+
+/** Call this from your periodic work worker function to schedule the next
+ *  call.
+ *  If this function returns false, there was a failure and the
+ *  periodic work is no longer scheduled
+ */
+bool visor_periodic_work_nextperiod(struct periodic_work *pw)
+{
+	bool rc = false;
+
+	write_lock(&pw->lock);
+	if (pw->want_to_stop) {
+		pw->is_scheduled = false;
+		pw->want_to_stop = false;
+		rc = true;  /* yes, true; see visor_periodic_work_stop() */
+		goto unlock;
+	} else if (queue_delayed_work(pw->workqueue, &pw->work,
+				      pw->jiffy_interval) < 0) {
+		pw->is_scheduled = false;
+		rc = false;
+		goto unlock;
+	}
+	rc = true;
+unlock:
+	write_unlock(&pw->lock);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod);
+
+/** This function returns true iff new periodic work was actually started.
+ *  If this function returns false, then no work was started
+ *  (either because it was already started, or because of a failure).
+ */
+bool visor_periodic_work_start(struct periodic_work *pw)
+{
+	bool rc = false;
+
+	write_lock(&pw->lock);
+	if (pw->is_scheduled) {
+		rc = false;
+		goto unlock;
+	}
+	if (pw->want_to_stop) {
+		rc = false;
+		goto unlock;
+	}
+	INIT_DELAYED_WORK(&pw->work, &periodic_work_func);
+	if (queue_delayed_work(pw->workqueue, &pw->work,
+			       pw->jiffy_interval) < 0) {
+		rc = false;
+		goto unlock;
+	}
+	pw->is_scheduled = true;
+	rc = true;
+unlock:
+	write_unlock(&pw->lock);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(visor_periodic_work_start);
+
+/** This function returns true iff your call actually stopped the periodic
+ *  work.
+ *
+ *  -- PAY ATTENTION... this is important --
+ *
+ *  NO NO #1
+ *
+ *     Do NOT call this function from some function that is running on the
+ *     same workqueue as the work you are trying to stop might be running
+ *     on!  If you violate this rule, visor_periodic_work_stop() MIGHT work,
+ *     but it also MIGHT get hung up in an infinite loop saying
+ *     "waiting for delayed work...".  This will happen if the delayed work
+ *     you are trying to cancel has been put in the workqueue list, but can't
+ *     run yet because we are running that same workqueue thread right now.
+ *
+ *     Bottom line: If you need to call visor_periodic_work_stop() from a
+ *     workitem, be sure the workitem is on a DIFFERENT workqueue than the
+ *     workitem that you are trying to cancel.
+ *
+ *     If I could figure out some way to check for this "no no" condition in
+ *     the code, I would.  It would have saved me the trouble of writing this
+ *     long comment.  And also, don't think this is some "theoretical" race
+ *     condition.  It is REAL, as I have spent the day chasing it.
+ *
+ *  NO NO #2
+ *
+ *     Take close note of the locks that you own when you call this function.
+ *     You must NOT own any locks that are needed by the periodic work
+ *     function that is currently installed.  If you DO, a deadlock may result,
+ *     because stopping the periodic work often involves waiting for the last
+ *     iteration of the periodic work function to complete.  Again, if you hit
+ *     this deadlock, you will get hung up in an infinite loop saying
+ *     "waiting for delayed work...".
+ */
+bool visor_periodic_work_stop(struct periodic_work *pw)
+{
+	bool stopped_something = false;
+
+	write_lock(&pw->lock);
+	stopped_something = pw->is_scheduled && (!pw->want_to_stop);
+	while (pw->is_scheduled) {
+		pw->want_to_stop = true;
+		if (cancel_delayed_work(&pw->work)) {
+			/* We get here if the delayed work was pending as
+			 * delayed work, but was NOT run.
+			 */
+			WARN_ON(!pw->is_scheduled);
+			pw->is_scheduled = false;
+		} else {
+			/* If we get here, either the delayed work:
+			 * - was run, OR,
+			 * - is running RIGHT NOW on another processor, OR,
+			 * - wasn't even scheduled (there is a miniscule
+			 *   timing window where this could be the case)
+			 * flush_workqueue() would make sure it is finished
+			 * executing, but that still isn't very useful, which
+			 * explains the loop...
+			 */
+		}
+		if (pw->is_scheduled) {
+			write_unlock(&pw->lock);
+			__set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(10);
+			write_lock(&pw->lock);
+		} else {
+			pw->want_to_stop = false;
+		}
+	}
+	write_unlock(&pw->lock);
+	return stopped_something;
+}
+EXPORT_SYMBOL_GPL(visor_periodic_work_stop);
diff --git a/drivers/staging/unisys/visorutil/Kconfig b/drivers/staging/unisys/visorutil/Kconfig
deleted file mode 100644
index be9c2cf..0000000
--- a/drivers/staging/unisys/visorutil/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Unisys timskmod configuration
-#
-
-config UNISYS_VISORUTIL
-	tristate "Unisys visorutil driver"
-	---help---
-	If you say Y here, you will enable the Unisys visorutil driver.
-
diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile
deleted file mode 100644
index 8f6a3e3..0000000
--- a/drivers/staging/unisys/visorutil/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for Unisys timskmod
-#
-
-obj-$(CONFIG_UNISYS_VISORUTIL)	+= visorutil.o
-
-visorutil-y := periodic_work.o
-
-ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c
deleted file mode 100644
index 3562e8b..0000000
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* periodic_work.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- *  Helper functions to schedule periodic work in Linux kernel mode.
- */
-#include <linux/sched.h>
-
-#include "periodic_work.h"
-
-#define MYDRVNAME "periodic_work"
-
-struct periodic_work {
-	rwlock_t lock;
-	struct delayed_work work;
-	void (*workfunc)(void *);
-	void *workfuncarg;
-	bool is_scheduled;
-	bool want_to_stop;
-	ulong jiffy_interval;
-	struct workqueue_struct *workqueue;
-	const char *devnam;
-};
-
-static void periodic_work_func(struct work_struct *work)
-{
-	struct periodic_work *pw;
-
-	pw = container_of(work, struct periodic_work, work.work);
-	(*pw->workfunc)(pw->workfuncarg);
-}
-
-struct periodic_work *visor_periodic_work_create(ulong jiffy_interval,
-					struct workqueue_struct *workqueue,
-					void (*workfunc)(void *),
-					void *workfuncarg,
-					const char *devnam)
-{
-	struct periodic_work *pw;
-
-	pw = kzalloc(sizeof(*pw), GFP_KERNEL | __GFP_NORETRY);
-	if (!pw)
-		return NULL;
-
-	rwlock_init(&pw->lock);
-	pw->jiffy_interval = jiffy_interval;
-	pw->workqueue = workqueue;
-	pw->workfunc = workfunc;
-	pw->workfuncarg = workfuncarg;
-	pw->devnam = devnam;
-	return pw;
-}
-EXPORT_SYMBOL_GPL(visor_periodic_work_create);
-
-void visor_periodic_work_destroy(struct periodic_work *pw)
-{
-	kfree(pw);
-}
-EXPORT_SYMBOL_GPL(visor_periodic_work_destroy);
-
-/** Call this from your periodic work worker function to schedule the next
- *  call.
- *  If this function returns false, there was a failure and the
- *  periodic work is no longer scheduled
- */
-bool visor_periodic_work_nextperiod(struct periodic_work *pw)
-{
-	bool rc = false;
-
-	write_lock(&pw->lock);
-	if (pw->want_to_stop) {
-		pw->is_scheduled = false;
-		pw->want_to_stop = false;
-		rc = true;  /* yes, true; see visor_periodic_work_stop() */
-		goto unlock;
-	} else if (queue_delayed_work(pw->workqueue, &pw->work,
-				      pw->jiffy_interval) < 0) {
-		pw->is_scheduled = false;
-		rc = false;
-		goto unlock;
-	}
-	rc = true;
-unlock:
-	write_unlock(&pw->lock);
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod);
-
-/** This function returns true iff new periodic work was actually started.
- *  If this function returns false, then no work was started
- *  (either because it was already started, or because of a failure).
- */
-bool visor_periodic_work_start(struct periodic_work *pw)
-{
-	bool rc = false;
-
-	write_lock(&pw->lock);
-	if (pw->is_scheduled) {
-		rc = false;
-		goto unlock;
-	}
-	if (pw->want_to_stop) {
-		rc = false;
-		goto unlock;
-	}
-	INIT_DELAYED_WORK(&pw->work, &periodic_work_func);
-	if (queue_delayed_work(pw->workqueue, &pw->work,
-			       pw->jiffy_interval) < 0) {
-		rc = false;
-		goto unlock;
-	}
-	pw->is_scheduled = true;
-	rc = true;
-unlock:
-	write_unlock(&pw->lock);
-	return rc;
-}
-EXPORT_SYMBOL_GPL(visor_periodic_work_start);
-
-/** This function returns true iff your call actually stopped the periodic
- *  work.
- *
- *  -- PAY ATTENTION... this is important --
- *
- *  NO NO #1
- *
- *     Do NOT call this function from some function that is running on the
- *     same workqueue as the work you are trying to stop might be running
- *     on!  If you violate this rule, visor_periodic_work_stop() MIGHT work,
- *     but it also MIGHT get hung up in an infinite loop saying
- *     "waiting for delayed work...".  This will happen if the delayed work
- *     you are trying to cancel has been put in the workqueue list, but can't
- *     run yet because we are running that same workqueue thread right now.
- *
- *     Bottom line: If you need to call visor_periodic_work_stop() from a
- *     workitem, be sure the workitem is on a DIFFERENT workqueue than the
- *     workitem that you are trying to cancel.
- *
- *     If I could figure out some way to check for this "no no" condition in
- *     the code, I would.  It would have saved me the trouble of writing this
- *     long comment.  And also, don't think this is some "theoretical" race
- *     condition.  It is REAL, as I have spent the day chasing it.
- *
- *  NO NO #2
- *
- *     Take close note of the locks that you own when you call this function.
- *     You must NOT own any locks that are needed by the periodic work
- *     function that is currently installed.  If you DO, a deadlock may result,
- *     because stopping the periodic work often involves waiting for the last
- *     iteration of the periodic work function to complete.  Again, if you hit
- *     this deadlock, you will get hung up in an infinite loop saying
- *     "waiting for delayed work...".
- */
-bool visor_periodic_work_stop(struct periodic_work *pw)
-{
-	bool stopped_something = false;
-
-	write_lock(&pw->lock);
-	stopped_something = pw->is_scheduled && (!pw->want_to_stop);
-	while (pw->is_scheduled) {
-		pw->want_to_stop = true;
-		if (cancel_delayed_work(&pw->work)) {
-			/* We get here if the delayed work was pending as
-			 * delayed work, but was NOT run.
-			 */
-			WARN_ON(!pw->is_scheduled);
-			pw->is_scheduled = false;
-		} else {
-			/* If we get here, either the delayed work:
-			 * - was run, OR,
-			 * - is running RIGHT NOW on another processor, OR,
-			 * - wasn't even scheduled (there is a miniscule
-			 *   timing window where this could be the case)
-			 * flush_workqueue() would make sure it is finished
-			 * executing, but that still isn't very useful, which
-			 * explains the loop...
-			 */
-		}
-		if (pw->is_scheduled) {
-			write_unlock(&pw->lock);
-			__set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(10);
-			write_lock(&pw->lock);
-		} else {
-			pw->want_to_stop = false;
-		}
-	}
-	write_unlock(&pw->lock);
-	return stopped_something;
-}
-EXPORT_SYMBOL_GPL(visor_periodic_work_stop);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 091/141] staging: unisys: fix visorbus Kconfig
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (89 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 090/141] staging: unisys: move periodic_work.c into the visorbus directory Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 092/141] staging: unisys: remove visorutil from top level Makefile Benjamin Romer
                   ` (52 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

Removing visorutil made it impossible to build visorbus. Remove the config
setting from the Kconfig so the module can be enabled in the build.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig
index 420c9ee..9b299ac 100644
--- a/drivers/staging/unisys/visorbus/Kconfig
+++ b/drivers/staging/unisys/visorbus/Kconfig
@@ -4,6 +4,6 @@
 
 config UNISYS_VISORBUS
 	tristate "Unisys visorbus driver"
-	depends on UNISYSSPAR && UNISYS_VISORUTIL
+	depends on UNISYSSPAR
 	---help---
 	If you say Y here, you will enable the Unisys visorbus driver.
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 092/141] staging: unisys: remove visorutil from top level Makefile
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (90 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 091/141] staging: unisys: fix visorbus Kconfig Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 093/141] staging: unisys: visorchannel: Make visorchannel_create take a gfp_t Benjamin Romer
                   ` (51 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

The visorutil directory is still mentioned in the top level makefile for
the Unisys drivers, so remove it.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index e0c893a..566af8e 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -1,5 +1,4 @@
 #
 # Makefile for Unisys SPAR drivers
 #
-obj-$(CONFIG_UNISYS_VISORUTIL)		+= visorutil/
 obj-$(CONFIG_UNISYS_VISORBUS)		+= visorbus/
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 093/141] staging: unisys: visorchannel: Make visorchannel_create take a gfp_t
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (91 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 092/141] staging: unisys: remove visorutil from top level Makefile Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 094/141] staging: unisys: visorchipset: Declare parser_init_byte_stream() static Benjamin Romer
                   ` (50 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This allows the caller to specify an appropriate GFP flag instead of
hardcoding the lowest common denominator.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/controlvmchannel.h    |  5 +----
 drivers/staging/unisys/include/visorbus.h              |  7 ++++---
 drivers/staging/unisys/visorbus/visorbus_main.c        |  3 ++-
 drivers/staging/unisys/visorbus/visorchannel.c         | 18 ++++++++++--------
 drivers/staging/unisys/visorbus/visorchipset.c         |  8 ++++----
 5 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index d8ed52e..f1c86fb 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -25,9 +25,6 @@
 		UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
 			0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
 
-static const uuid_le spar_controlvm_channel_protocol_uuid =
-	SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
-
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
 	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
 #define CONTROLVM_MESSAGE_MAX 64
@@ -42,7 +39,7 @@ static const uuid_le spar_controlvm_channel_protocol_uuid =
 
 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
 	spar_check_channel_client(ch, \
-		spar_controlvm_channel_protocol_uuid, \
+		SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
 		"controlvm", \
 		sizeof(struct spar_controlvm_channel_protocol), \
 		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 0f1966c..d542822 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -168,10 +168,11 @@ void visorbus_disable_channel_interrupts(struct visor_device *dev);
  * In this case, the values can simply be read from the channel header.
  */
 struct visorchannel *visorchannel_create(u64 physaddr,
-					 ulong channel_bytes, uuid_le guid);
+					 unsigned long channel_bytes,
+					 gfp_t gfp, uuid_le guid);
 struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
-						   ulong channel_bytes,
-						   uuid_le guid);
+						   unsigned long channel_bytes,
+						   gfp_t gfp, uuid_le guid);
 void visorchannel_destroy(struct visorchannel *channel);
 int visorchannel_read(struct visorchannel *channel, ulong offset,
 		      void *local, ulong nbytes);
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 2e00e42..77afa9d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1308,8 +1308,8 @@ create_visor_device(struct visorbus_devdata *devdata,
 			 POSTCODE_SEVERITY_INFO);
 	/* prepare chan_hdr (abstraction to read/write channel memory) */
 	visorchannel = visorchannel_create(chan_info.channel_addr,
-					   (unsigned long)
 					   chan_info.n_channel_bytes,
+					   GFP_KERNEL,
 					   chan_info.channel_type_uuid);
 	if (!visorchannel) {
 		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
@@ -1676,6 +1676,7 @@ create_bus_instance(int id)
 
 		devdata->chan = visorchannel_create(channel_addr,
 						    n_channel_bytes,
+						    GFP_KERNEL,
 						    channel_type_guid);
 		if (!devdata->chan) {
 			POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr,
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 44ea434..2d3e4d6 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -50,14 +50,15 @@ struct visorchannel {
  * but does NOT modify this data area.
  */
 static struct visorchannel *
-visorchannel_create_guts(u64 physaddr, ulong channel_bytes,
-			 ulong off, uuid_le guid, bool needs_lock)
+visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes,
+			 gfp_t gfp, unsigned long off,
+			 uuid_le guid, bool needs_lock)
 {
 	struct visorchannel *channel;
 	int err;
 	size_t size = sizeof(struct channel_header);
 
-	channel = kzalloc(sizeof(*channel), GFP_KERNEL|__GFP_NORETRY);
+	channel = kzalloc(sizeof(*channel), gfp);
 	if (!channel)
 		goto cleanup;
 
@@ -112,18 +113,19 @@ cleanup:
 }
 
 struct visorchannel *
-visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid)
+visorchannel_create(u64 physaddr, unsigned long channel_bytes,
+		    gfp_t gfp, uuid_le guid)
 {
-	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
+	return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid,
 					false);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create);
 
 struct visorchannel *
-visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes,
-			      uuid_le guid)
+visorchannel_create_with_lock(u64 physaddr, unsigned long channel_bytes,
+			      gfp_t gfp, uuid_le guid)
 {
-	return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
+	return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid,
 					true);
 }
 EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 776bf2e..e61ec34 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2659,11 +2659,11 @@ visorchipset_init(struct acpi_device *acpi_device)
 
 	addr = controlvm_get_channel_address();
 	if (addr) {
+		int tmp_sz = sizeof(struct spar_controlvm_channel_protocol);
+		uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
 		controlvm_channel =
-		    visorchannel_create_with_lock
-		    (addr,
-		     sizeof(struct spar_controlvm_channel_protocol),
-		     spar_controlvm_channel_protocol_uuid);
+			visorchannel_create_with_lock(addr, tmp_sz,
+						      GFP_KERNEL, uuid);
 		if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
 				visorchannel_get_header(controlvm_channel))) {
 			initialize_controlvm_payload();
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 094/141] staging: unisys: visorchipset: Declare parser_init_byte_stream() static
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (92 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 093/141] staging: unisys: visorchannel: Make visorchannel_create take a gfp_t Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 095/141] staging: unisys: parser: Remove unused functions and mark others static Benjamin Romer
                   ` (49 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

In addition remove unused parser_init()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index e61ec34..a5e1bde 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -470,18 +470,12 @@ cleanup:
 	return rc;
 }
 
-struct parser_context *
-parser_init(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, true, retry);
-}
-
 /* Call this instead of parser_init() if the payload area consists of just
  * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
  * structures.  Afterwards, you can call parser_simpleString_get() or
  * parser_byteStream_get() to obtain the data.
  */
-struct parser_context *
+static struct parser_context *
 parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
 {
 	return parser_init_guts(addr, bytes, local, false, retry);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 095/141] staging: unisys: parser: Remove unused functions and mark others static
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (93 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 094/141] staging: unisys: visorchipset: Declare parser_init_byte_stream() static Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 096/141] staging: unisys: parser_init_guts(): standard_payload_header is always false Benjamin Romer
                   ` (48 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 201 +------------------------
 1 file changed, 4 insertions(+), 197 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index a5e1bde..b6b332c 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -481,30 +481,7 @@ parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
 	return parser_init_guts(addr, bytes, local, false, retry);
 }
 
-/* Obtain '\0'-terminated copy of string in payload area.
- */
-char *
-parser_simpleString_get(struct parser_context *ctx)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	return ctx->data;	/* note this IS '\0'-terminated, because of
-				 * the num of bytes we alloc+clear in
-				 * parser_init_byteStream() */
-}
-
-/* Obtain a copy of the buffer in the payload area.
- */
-void *parser_byte_stream_get(struct parser_context *ctx, unsigned long *nbytes)
-{
-	if (!ctx->byte_stream)
-		return NULL;
-	if (nbytes)
-		*nbytes = ctx->param_bytes;
-	return (void *)ctx->data;
-}
-
-uuid_le
+static uuid_le
 parser_id_get(struct parser_context *ctx)
 {
 	struct spar_controlvm_parameters_header *phdr = NULL;
@@ -526,7 +503,7 @@ enum PARSER_WHICH_STRING {
 	PARSERSTRING_NAME, /* TODO: only PARSERSTRING_NAME is used ? */
 };
 
-void
+static void
 parser_param_start(struct parser_context *ctx,
 		   enum PARSER_WHICH_STRING which_string)
 {
@@ -560,8 +537,7 @@ Away:
 	return;
 }
 
-void
-parser_done(struct parser_context *ctx)
+static void parser_done(struct parser_context *ctx)
 {
 	if (!ctx)
 		return;
@@ -569,176 +545,7 @@ parser_done(struct parser_context *ctx)
 	kfree(ctx);
 }
 
-/** Return length of string not counting trailing spaces. */
-static int
-string_length_no_trail(char *s, int len)
-{
-	int i = len - 1;
-
-	while (i >= 0) {
-		if (!isspace(s[i]))
-			return i + 1;
-		i--;
-	}
-	return 0;
-}
-
-/** Grab the next name and value out of the parameter buffer.
- *  The entire parameter buffer looks like this:
- *      <name>=<value>\0
- *      <name>=<value>\0
- *      ...
- *      \0
- *  If successful, the next <name> value is returned within the supplied
- *  <nam> buffer (the value is always upper-cased), and the corresponding
- *  <value> is returned within a kmalloc()ed buffer, whose pointer is
- *  provided as the return value of this function.
- *  (The total number of bytes allocated is strlen(<value>)+1.)
- *
- *  NULL is returned to indicate failure, which can occur for several reasons:
- *  - all <name>=<value> pairs have already been processed
- *  - bad parameter
- *  - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
- *    the confines of the parameter buffer)
- *  - the <nam> buffer is not large enough to hold the <name> of the next
- *    parameter
- */
-void *
-parser_param_get(struct parser_context *ctx, char *nam, int namesize)
-{
-	u8 *pscan, *pnam = nam;
-	unsigned long nscan;
-	int value_length = -1, orig_value_length = -1;
-	void *value = NULL;
-	int i;
-	int closing_quote = 0;
-
-	if (!ctx)
-		return NULL;
-	pscan = ctx->curr;
-	nscan = ctx->bytes_remaining;
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\0')
-		/*  This is the normal return point after you have processed
-		 *  all of the <name>=<value> pairs in a syntactically-valid
-		 *  parameter buffer.
-		 */
-		return NULL;
-
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	while (*pscan != ':') {
-		if (namesize <= 0)
-			return NULL;
-		*pnam = toupper(*pscan);
-		pnam++;
-		namesize--;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (namesize <= 0)
-		return NULL;
-	*pnam = '\0';
-	nam[string_length_no_trail(nam, strlen(nam))] = '\0';
-
-	/* point to char immediately after ":" in "<name>:<value>" */
-	pscan++;
-	nscan--;
-	/* skip whitespace */
-	while (isspace(*pscan)) {
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-	if (nscan == 0)
-		return NULL;
-	if (*pscan == '\'' || *pscan == '"') {
-		closing_quote = *pscan;
-		pscan++;
-		nscan--;
-		if (nscan == 0)
-			return NULL;
-	}
-
-	/* look for a separator character, terminator character, or
-	 * end of data
-	 */
-	for (i = 0, value_length = -1; i < nscan; i++) {
-		if (closing_quote) {
-			if (pscan[i] == '\0')
-				return NULL;
-			if (pscan[i] == closing_quote) {
-				value_length = i;
-				break;
-			}
-		} else
-		    if (pscan[i] == ',' || pscan[i] == ';'
-			|| pscan[i] == '\0') {
-			value_length = i;
-			break;
-		}
-	}
-	if (value_length < 0) {
-		if (closing_quote)
-			return NULL;
-		value_length = nscan;
-	}
-	orig_value_length = value_length;
-	if (closing_quote == 0)
-		value_length = string_length_no_trail(pscan, orig_value_length);
-	value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
-	if (value == NULL)
-		return NULL;
-	memcpy(value, pscan, value_length);
-	((u8 *) (value))[value_length] = '\0';
-
-	pscan += orig_value_length;
-	nscan -= orig_value_length;
-
-	/* skip past separator or closing quote */
-	if (nscan > 0) {
-		if (*pscan != '\0') {
-			pscan++;
-			nscan--;
-		}
-	}
-
-	if (closing_quote && (nscan > 0)) {
-		/* we still need to skip around the real separator if present */
-		/* first, skip whitespace */
-		while (isspace(*pscan)) {
-			pscan++;
-			nscan--;
-			if (nscan == 0)
-				break;
-		}
-		if (nscan > 0) {
-			if (*pscan == ',' || *pscan == ';') {
-				pscan++;
-				nscan--;
-			} else if (*pscan != '\0') {
-				kfree(value);
-				value = NULL;
-				return NULL;
-			}
-		}
-	}
-	ctx->curr = pscan;
-	ctx->bytes_remaining = nscan;
-	return value;
-}
-
-void *
+static void *
 parser_string_get(struct parser_context *ctx)
 {
 	u8 *pscan;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 096/141] staging: unisys: parser_init_guts(): standard_payload_header is always false
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (94 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 095/141] staging: unisys: parser: Remove unused functions and mark others static Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 097/141] staging: unisys: Remove wrapper around parser_init_guts() Benjamin Romer
                   ` (47 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 37 +++++++-------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index b6b332c..2cf59ca 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -376,21 +376,20 @@ static void controlvm_respond_physdev_changestate(
 static void parser_done(struct parser_context *ctx);
 
 static struct parser_context *
-parser_init_guts(u64 addr, u32 bytes, bool local,
-		 bool standard_payload_header, bool *retry)
+parser_init_guts(u64 addr, u32 bytes, bool local, bool *retry)
 {
 	int allocbytes = sizeof(struct parser_context) + bytes;
 	struct parser_context *rc = NULL;
 	struct parser_context *ctx = NULL;
-	struct spar_controlvm_parameters_header *phdr = NULL;
 
 	if (retry)
 		*retry = false;
-	if (!standard_payload_header)
-		/* alloc and 0 extra byte to ensure payload is
-		 * '\0'-terminated
-		 */
-		allocbytes++;
+
+	/*
+	 * alloc an 0 extra byte to ensure payload is
+	 * '\0'-terminated
+	 */
+	allocbytes++;
 	if ((controlvm_payload_bytes_buffered + bytes)
 	    > MAX_CONTROLVM_PAYLOAD_BYTES) {
 		if (retry)
@@ -437,26 +436,8 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 		memcpy_fromio(ctx->data, mapping, bytes);
 		release_mem_region(addr, bytes);
 	}
-	if (!standard_payload_header) {
-		ctx->byte_stream = true;
-		rc = ctx;
-		goto cleanup;
-	}
-	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
-	if (phdr->total_length != bytes) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->total_length < phdr->header_length) {
-		rc = NULL;
-		goto cleanup;
-	}
-	if (phdr->header_length <
-	    sizeof(struct spar_controlvm_parameters_header)) {
-		rc = NULL;
-		goto cleanup;
-	}
 
+	ctx->byte_stream = true;
 	rc = ctx;
 cleanup:
 	if (rc) {
@@ -478,7 +459,7 @@ cleanup:
 static struct parser_context *
 parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
 {
-	return parser_init_guts(addr, bytes, local, false, retry);
+	return parser_init_guts(addr, bytes, local, retry);
 }
 
 static uuid_le
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 097/141] staging: unisys: Remove wrapper around parser_init_guts()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (95 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 096/141] staging: unisys: parser_init_guts(): standard_payload_header is always false Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 098/141] staging: unisys: visorchipset: Remove unused cache allocator Benjamin Romer
                   ` (46 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 2cf59ca..ac75ddf 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -376,7 +376,7 @@ static void controlvm_respond_physdev_changestate(
 static void parser_done(struct parser_context *ctx);
 
 static struct parser_context *
-parser_init_guts(u64 addr, u32 bytes, bool local, bool *retry)
+parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
 {
 	int allocbytes = sizeof(struct parser_context) + bytes;
 	struct parser_context *rc = NULL;
@@ -451,17 +451,6 @@ cleanup:
 	return rc;
 }
 
-/* Call this instead of parser_init() if the payload area consists of just
- * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
- * structures.  Afterwards, you can call parser_simpleString_get() or
- * parser_byteStream_get() to obtain the data.
- */
-static struct parser_context *
-parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
-{
-	return parser_init_guts(addr, bytes, local, retry);
-}
-
 static uuid_le
 parser_id_get(struct parser_context *ctx)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 098/141] staging: unisys: visorchipset: Remove unused cache allocator
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (96 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 097/141] staging: unisys: Remove wrapper around parser_init_guts() Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 099/141] staging: unisys: uislib.h: Remove unused cache allocation prototypes Benjamin Romer
                   ` (45 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 39 --------------------------
 1 file changed, 39 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index ac75ddf..ca22f49 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2223,45 +2223,6 @@ visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
 }
 EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
 
-/* Generic wrapper function for allocating memory from a kmem_cache pool.
- */
-void *
-visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block,
-			 char *fn, int ln)
-{
-	gfp_t gfp;
-	void *p;
-
-	if (ok_to_block)
-		gfp = GFP_KERNEL;
-	else
-		gfp = GFP_ATOMIC;
-	/* __GFP_NORETRY means "ok to fail", meaning
-	 * kmem_cache_alloc() can return NULL, implying the caller CAN
-	 * cope with failure.  If you do NOT specify __GFP_NORETRY,
-	 * Linux will go to extreme measures to get memory for you
-	 * (like, invoke oom killer), which will probably cripple the
-	 * system.
-	 */
-	gfp |= __GFP_NORETRY;
-	p = kmem_cache_alloc(pool, gfp);
-	if (!p)
-		return NULL;
-
-	return p;
-}
-
-/* Generic wrapper function for freeing memory from a kmem_cache pool.
- */
-void
-visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
-{
-	if (!p)
-		return;
-
-	kmem_cache_free(pool, p);
-}
-
 static ssize_t chipsetready_store(struct device *dev,
 				  struct device_attribute *attr,
 				  const char *buf, size_t count)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 099/141] staging: unisys: uislib.h: Remove unused cache allocation prototypes
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (97 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 098/141] staging: unisys: visorchipset: Remove unused cache allocator Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 100/141] staging: unisys: visorchipset_file_{init, cleanup}(): mark static Benjamin Romer
                   ` (44 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/uisutils.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
index c7d0ba8..4514772 100644
--- a/drivers/staging/unisys/include/uisutils.h
+++ b/drivers/staging/unisys/include/uisutils.h
@@ -284,11 +284,6 @@ static inline unsigned int issue_vmcall_channel_mismatch(const char *chname,
 }
 
 #define UIS_DAEMONIZE(nam)
-void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln);
-#define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__)
-void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln);
-#define UISCACHEFREE(cur_pool, p) \
-	uislib_cache_free(cur_pool, p, __FILE__, __LINE__)
 
 void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no,
 				      int (*interrupt)(void *),
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 100/141] staging: unisys: visorchipset_file_{init, cleanup}(): mark static
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (98 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 099/141] staging: unisys: uislib.h: Remove unused cache allocation prototypes Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 101/141] staging: unisys: Remove unused visorchipset_save_message() Benjamin Romer
                   ` (43 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index ca22f49..66ae3d0 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -2351,7 +2351,7 @@ static const struct file_operations visorchipset_fops = {
 	.mmap = visorchipset_mmap,
 };
 
-int
+static int
 visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
 {
 	int rc = 0;
@@ -2460,7 +2460,7 @@ cleanup:
 	return rc;
 }
 
-void
+static void
 visorchipset_file_cleanup(dev_t major_dev)
 {
 	if (file_cdev.ops)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 101/141] staging: unisys: Remove unused visorchipset_save_message()
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (99 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 100/141] staging: unisys: visorchipset_file_{init, cleanup}(): mark static Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 102/141] staging: unisys: visorchipset_init(): Simplify initial checks Benjamin Romer
                   ` (42 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 56 --------------------------
 1 file changed, 56 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 66ae3d0..d88f11f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -933,62 +933,6 @@ enum crash_obj_type {
 	CRASH_BUS,
 };
 
-void
-visorchipset_save_message(struct controlvm_message *msg,
-			  enum crash_obj_type type)
-{
-	u32 crash_msg_offset;
-	u16 crash_msg_count;
-
-	/* get saved message count */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_count),
-			      &crash_msg_count, sizeof(u16)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
-		POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
-				 crash_msg_count,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	/* get saved crash message offset */
-	if (visorchannel_read(controlvm_channel,
-			      offsetof(struct spar_controlvm_channel_protocol,
-				       saved_crash_message_offset),
-			      &crash_msg_offset, sizeof(u32)) < 0) {
-		POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	if (type == CRASH_BUS) {
-		if (visorchannel_write(controlvm_channel,
-				       crash_msg_offset,
-				       msg,
-				       sizeof(struct controlvm_message)) < 0) {
-			POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
-					 POSTCODE_SEVERITY_ERR);
-			return;
-		}
-	} else { /* CRASH_DEV */
-		if (visorchannel_write(controlvm_channel,
-				       crash_msg_offset +
-				       sizeof(struct controlvm_message), msg,
-				       sizeof(struct controlvm_message)) < 0) {
-			POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
-					 POSTCODE_SEVERITY_ERR);
-			return;
-		}
-	}
-}
-EXPORT_SYMBOL_GPL(visorchipset_save_message);
-
 static void
 bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 102/141] staging: unisys: visorchipset_init(): Simplify initial checks
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (100 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 101/141] staging: unisys: Remove unused visorchipset_save_message() Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 103/141] staging: unisys: Remove unused livedump_info Benjamin Romer
                   ` (41 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer, Jes Sorensen

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 40 +++++++++++---------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index d88f11f..88a2b5e 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1474,15 +1474,14 @@ initialize_controlvm_payload(void)
 /*  Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
  *  Returns CONTROLVM_RESP_xxx code.
  */
-int
+static int
 visorchipset_chipset_ready(void)
 {
 	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
 	return CONTROLVM_RESP_SUCCESS;
 }
-EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
 
-int
+static int
 visorchipset_chipset_selftest(void)
 {
 	char env_selftest[20];
@@ -1493,18 +1492,16 @@ visorchipset_chipset_selftest(void)
 			   envp);
 	return CONTROLVM_RESP_SUCCESS;
 }
-EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
 
 /*  Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
  *  Returns CONTROLVM_RESP_xxx code.
  */
-int
+static int
 visorchipset_chipset_notready(void)
 {
 	kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
 	return CONTROLVM_RESP_SUCCESS;
 }
-EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
 
 static void
 chipset_ready(struct controlvm_message_header *msg_hdr)
@@ -2099,14 +2096,13 @@ device_destroy_response(u32 bus_no, u32 dev_no, int response)
 	device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
 }
 
-void
+static void
 visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
 				     bus_no, dev_no, response,
 				     segment_state_standby);
 }
-EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
 
 static void
 device_resume_response(u32 bus_no, u32 dev_no, int response)
@@ -2327,28 +2323,26 @@ visorchipset_init(struct acpi_device *acpi_device)
 {
 	int rc = 0;
 	u64 addr;
+	int tmp_sz = sizeof(struct spar_controlvm_channel_protocol);
+	uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
+
+	addr = controlvm_get_channel_address();
+	if (!addr)
+		return -ENODEV;
 
 	memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
 	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
 	memset(&livedump_info, 0, sizeof(livedump_info));
 	atomic_set(&livedump_info.buffers_in_use, 0);
 
-	addr = controlvm_get_channel_address();
-	if (addr) {
-		int tmp_sz = sizeof(struct spar_controlvm_channel_protocol);
-		uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
-		controlvm_channel =
-			visorchannel_create_with_lock(addr, tmp_sz,
-						      GFP_KERNEL, uuid);
-		if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
-				visorchannel_get_header(controlvm_channel))) {
-			initialize_controlvm_payload();
-		} else {
-			visorchannel_destroy(controlvm_channel);
-			controlvm_channel = NULL;
-			return -ENODEV;
-		}
+	controlvm_channel = visorchannel_create_with_lock(addr, tmp_sz,
+							  GFP_KERNEL, uuid);
+	if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
+		    visorchannel_get_header(controlvm_channel))) {
+		initialize_controlvm_payload();
 	} else {
+		visorchannel_destroy(controlvm_channel);
+		controlvm_channel = NULL;
 		return -ENODEV;
 	}
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 103/141] staging: unisys: Remove unused livedump_info
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (101 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 102/141] staging: unisys: visorchipset_init(): Simplify initial checks Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 104/141] staging: unisys: Remove appos_subsystems.h Benjamin Romer
                   ` (40 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 88a2b5e..e6d7075 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -135,22 +135,6 @@ struct visor_controlvm_payload_info {
 
 static struct visor_controlvm_payload_info controlvm_payload_info;
 
-/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
- * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
- */
-struct visor_livedump_info {
-	struct controlvm_message_header dumpcapture_header;
-	struct controlvm_message_header gettextdump_header;
-	struct controlvm_message_header dumpcomplete_header;
-	bool gettextdump_outstanding;
-	u32 crc32;
-	unsigned long length;
-	atomic_t buffers_in_use;
-	unsigned long destination;
-};
-
-static struct visor_livedump_info livedump_info;
-
 /* The following globals are used to handle the scenario where we are unable to
  * offload the payload from a controlvm message due to memory requirements.  In
  * this scenario, we simply stash the controlvm message, then attempt to
@@ -2332,8 +2316,6 @@ visorchipset_init(struct acpi_device *acpi_device)
 
 	memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
 	memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
-	memset(&livedump_info, 0, sizeof(livedump_info));
-	atomic_set(&livedump_info.buffers_in_use, 0);
 
 	controlvm_channel = visorchannel_create_with_lock(addr, tmp_sz,
 							  GFP_KERNEL, uuid);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 104/141] staging: unisys: Remove appos_subsystems.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (102 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 103/141] staging: unisys: Remove unused livedump_info Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 105/141] staging: unisys: move hypervisor calls into visorbus Benjamin Romer
                   ` (39 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Get rid of common-spar/include/diagnostics/appos_subsystems.h.

No one is using it.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../include/diagnostics/appos_subsystems.h         | 310 ---------------------
 drivers/staging/unisys/include/uisutils.h          |   1 -
 2 files changed, 311 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h

diff --git a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h b/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
deleted file mode 100644
index 18cc9ed..0000000
--- a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* Please note that this file is to be used ONLY for defining diagnostic
- * subsystem values for the appos (sPAR Linux service partitions) component.
- */
-#ifndef __APPOS_SUBSYSTEMS_H__
-#define __APPOS_SUBSYSTEMS_H__
-
-#ifdef __KERNEL__
-#include <linux/kernel.h>
-#include <linux/string.h>
-#else
-#include <stdio.h>
-#include <string.h>
-#endif
-
-static inline char *
-subsys_unknown_to_s(int subsys, char *s, int n)
-{
-	snprintf(s, n, "SUBSYS-%-2.2d", subsys);
-	s[n - 1] = '\0';
-	return s;
-}
-
-#define SUBSYS_TO_MASK(subsys)      (1ULL << (subsys))
-
-/* The first SUBSYS_APPOS_MAX subsystems are the same for each AppOS type
- * (IOVM, SMS, etc.) The rest have unique values for each AppOS type.
- */
-#define SUBSYS_APPOS_MAX 16
-
-#define	SUBSYS_APPOS_DEFAULT         1	/* or "other" */
-#define SUBSYS_APPOS_CHIPSET         2	/* controlvm and other */
-					/* low-level sPAR activity */
-#define SUBSYS_APPOS_BUS             3	/* sPAR bus */
-/* DAK #define SUBSYS_APPOS_DIAG            4  // diagnostics and dump */
-#define SUBSYS_APPOS_CHANNELACCESS   5	/* generic channel access */
-#define SUBSYS_APPOS_NICCLIENT       6	/* virtual NIC client */
-#define SUBSYS_APPOS_HBACLIENT       7	/* virtual HBA client */
-#define SUBSYS_APPOS_CONSOLESERIAL   8	/* sPAR virtual serial console */
-#define SUBSYS_APPOS_UISLIB          9	/*  */
-#define SUBSYS_APPOS_VRTCUPDD       10	/*  */
-#define SUBSYS_APPOS_WATCHDOG       11	/* watchdog timer and healthcheck */
-#define SUBSYS_APPOS_13             13	/* available */
-#define SUBSYS_APPOS_14             14	/* available */
-#define SUBSYS_APPOS_15             15	/* available */
-#define SUBSYS_APPOS_16             16	/* available */
-static inline char *
-subsys_generic_to_s(int subsys, char *s, int n)
-{
-	switch (subsys) {
-	case SUBSYS_APPOS_DEFAULT:
-		strncpy(s, "APPOS_DEFAULT", n);
-		break;
-	case SUBSYS_APPOS_CHIPSET:
-		strncpy(s, "APPOS_CHIPSET", n);
-		break;
-	case SUBSYS_APPOS_BUS:
-		strncpy(s, "APPOS_BUS", n);
-		break;
-	case SUBSYS_APPOS_CHANNELACCESS:
-		strncpy(s, "APPOS_CHANNELACCESS", n);
-		break;
-	case SUBSYS_APPOS_NICCLIENT:
-		strncpy(s, "APPOS_NICCLIENT", n);
-		break;
-	case SUBSYS_APPOS_HBACLIENT:
-		strncpy(s, "APPOS_HBACLIENT", n);
-		break;
-	case SUBSYS_APPOS_CONSOLESERIAL:
-		strncpy(s, "APPOS_CONSOLESERIAL", n);
-		break;
-	case SUBSYS_APPOS_UISLIB:
-		strncpy(s, "APPOS_UISLIB", n);
-		break;
-	case SUBSYS_APPOS_VRTCUPDD:
-		strncpy(s, "APPOS_VRTCUPDD", n);
-		break;
-	case SUBSYS_APPOS_WATCHDOG:
-		strncpy(s, "APPOS_WATCHDOG", n);
-		break;
-	case SUBSYS_APPOS_13:
-		strncpy(s, "APPOS_13", n);
-		break;
-	case SUBSYS_APPOS_14:
-		strncpy(s, "APPOS_14", n);
-		break;
-	case SUBSYS_APPOS_15:
-		strncpy(s, "APPOS_15", n);
-		break;
-	case SUBSYS_APPOS_16:
-		strncpy(s, "APPOS_16", n);
-		break;
-	default:
-		subsys_unknown_to_s(subsys, s, n);
-		break;
-	}
-	s[n - 1] = '\0';
-	return s;
-}
-
-/* CONSOLE */
-
-#define SUBSYS_CONSOLE_VIDEO        (SUBSYS_APPOS_MAX + 1)	/* 17 */
-#define SUBSYS_CONSOLE_KBDMOU       (SUBSYS_APPOS_MAX + 2)	/* 18 */
-#define SUBSYS_CONSOLE_04           (SUBSYS_APPOS_MAX + 4)
-#define SUBSYS_CONSOLE_05           (SUBSYS_APPOS_MAX + 5)
-#define SUBSYS_CONSOLE_06           (SUBSYS_APPOS_MAX + 6)
-#define SUBSYS_CONSOLE_07           (SUBSYS_APPOS_MAX + 7)
-#define SUBSYS_CONSOLE_08           (SUBSYS_APPOS_MAX + 8)
-#define SUBSYS_CONSOLE_09           (SUBSYS_APPOS_MAX + 9)
-#define SUBSYS_CONSOLE_10           (SUBSYS_APPOS_MAX + 10)
-#define SUBSYS_CONSOLE_11           (SUBSYS_APPOS_MAX + 11)
-#define SUBSYS_CONSOLE_12           (SUBSYS_APPOS_MAX + 12)
-#define SUBSYS_CONSOLE_13           (SUBSYS_APPOS_MAX + 13)
-#define SUBSYS_CONSOLE_14           (SUBSYS_APPOS_MAX + 14)
-#define SUBSYS_CONSOLE_15           (SUBSYS_APPOS_MAX + 15)
-#define SUBSYS_CONSOLE_16           (SUBSYS_APPOS_MAX + 16)
-#define SUBSYS_CONSOLE_17           (SUBSYS_APPOS_MAX + 17)
-#define SUBSYS_CONSOLE_18           (SUBSYS_APPOS_MAX + 18)
-#define SUBSYS_CONSOLE_19           (SUBSYS_APPOS_MAX + 19)
-#define SUBSYS_CONSOLE_20           (SUBSYS_APPOS_MAX + 20)
-#define SUBSYS_CONSOLE_21           (SUBSYS_APPOS_MAX + 21)
-#define SUBSYS_CONSOLE_22           (SUBSYS_APPOS_MAX + 22)
-#define SUBSYS_CONSOLE_23           (SUBSYS_APPOS_MAX + 23)
-#define SUBSYS_CONSOLE_24           (SUBSYS_APPOS_MAX + 24)
-#define SUBSYS_CONSOLE_25           (SUBSYS_APPOS_MAX + 25)
-#define SUBSYS_CONSOLE_26           (SUBSYS_APPOS_MAX + 26)
-#define SUBSYS_CONSOLE_27           (SUBSYS_APPOS_MAX + 27)
-#define SUBSYS_CONSOLE_28           (SUBSYS_APPOS_MAX + 28)
-#define SUBSYS_CONSOLE_29           (SUBSYS_APPOS_MAX + 29)
-#define SUBSYS_CONSOLE_30           (SUBSYS_APPOS_MAX + 30)
-#define SUBSYS_CONSOLE_31           (SUBSYS_APPOS_MAX + 31)
-#define SUBSYS_CONSOLE_32           (SUBSYS_APPOS_MAX + 32)
-#define SUBSYS_CONSOLE_33           (SUBSYS_APPOS_MAX + 33)
-#define SUBSYS_CONSOLE_34           (SUBSYS_APPOS_MAX + 34)
-#define SUBSYS_CONSOLE_35           (SUBSYS_APPOS_MAX + 35)
-#define SUBSYS_CONSOLE_36           (SUBSYS_APPOS_MAX + 36)
-#define SUBSYS_CONSOLE_37           (SUBSYS_APPOS_MAX + 37)
-#define SUBSYS_CONSOLE_38           (SUBSYS_APPOS_MAX + 38)
-#define SUBSYS_CONSOLE_39           (SUBSYS_APPOS_MAX + 39)
-#define SUBSYS_CONSOLE_40           (SUBSYS_APPOS_MAX + 40)
-#define SUBSYS_CONSOLE_41           (SUBSYS_APPOS_MAX + 41)
-#define SUBSYS_CONSOLE_42           (SUBSYS_APPOS_MAX + 42)
-#define SUBSYS_CONSOLE_43           (SUBSYS_APPOS_MAX + 43)
-#define SUBSYS_CONSOLE_44           (SUBSYS_APPOS_MAX + 44)
-#define SUBSYS_CONSOLE_45           (SUBSYS_APPOS_MAX + 45)
-#define SUBSYS_CONSOLE_46           (SUBSYS_APPOS_MAX + 46)
-
-static inline char *
-subsys_console_to_s(int subsys, char *s, int n)
-{
-	switch (subsys) {
-	case SUBSYS_CONSOLE_VIDEO:
-		strncpy(s, "CONSOLE_VIDEO", n);
-		break;
-	case SUBSYS_CONSOLE_KBDMOU:
-		strncpy(s, "CONSOLE_KBDMOU", n);
-		break;
-	case SUBSYS_CONSOLE_04:
-		strncpy(s, "CONSOLE_04", n);
-		break;
-	case SUBSYS_CONSOLE_05:
-		strncpy(s, "CONSOLE_05", n);
-		break;
-	case SUBSYS_CONSOLE_06:
-		strncpy(s, "CONSOLE_06", n);
-		break;
-	case SUBSYS_CONSOLE_07:
-		strncpy(s, "CONSOLE_07", n);
-		break;
-	case SUBSYS_CONSOLE_08:
-		strncpy(s, "CONSOLE_08", n);
-		break;
-	case SUBSYS_CONSOLE_09:
-		strncpy(s, "CONSOLE_09", n);
-		break;
-	case SUBSYS_CONSOLE_10:
-		strncpy(s, "CONSOLE_10", n);
-		break;
-	case SUBSYS_CONSOLE_11:
-		strncpy(s, "CONSOLE_11", n);
-		break;
-	case SUBSYS_CONSOLE_12:
-		strncpy(s, "CONSOLE_12", n);
-		break;
-	case SUBSYS_CONSOLE_13:
-		strncpy(s, "CONSOLE_13", n);
-		break;
-	case SUBSYS_CONSOLE_14:
-		strncpy(s, "CONSOLE_14", n);
-		break;
-	case SUBSYS_CONSOLE_15:
-		strncpy(s, "CONSOLE_15", n);
-		break;
-	case SUBSYS_CONSOLE_16:
-		strncpy(s, "CONSOLE_16", n);
-		break;
-	case SUBSYS_CONSOLE_17:
-		strncpy(s, "CONSOLE_17", n);
-		break;
-	case SUBSYS_CONSOLE_18:
-		strncpy(s, "CONSOLE_18", n);
-		break;
-	case SUBSYS_CONSOLE_19:
-		strncpy(s, "CONSOLE_19", n);
-		break;
-	case SUBSYS_CONSOLE_20:
-		strncpy(s, "CONSOLE_20", n);
-		break;
-	case SUBSYS_CONSOLE_21:
-		strncpy(s, "CONSOLE_21", n);
-		break;
-	case SUBSYS_CONSOLE_22:
-		strncpy(s, "CONSOLE_22", n);
-		break;
-	case SUBSYS_CONSOLE_23:
-		strncpy(s, "CONSOLE_23", n);
-		break;
-	case SUBSYS_CONSOLE_24:
-		strncpy(s, "CONSOLE_24", n);
-		break;
-	case SUBSYS_CONSOLE_25:
-		strncpy(s, "CONSOLE_25", n);
-		break;
-	case SUBSYS_CONSOLE_26:
-		strncpy(s, "CONSOLE_26", n);
-		break;
-	case SUBSYS_CONSOLE_27:
-		strncpy(s, "CONSOLE_27", n);
-		break;
-	case SUBSYS_CONSOLE_28:
-		strncpy(s, "CONSOLE_28", n);
-		break;
-	case SUBSYS_CONSOLE_29:
-		strncpy(s, "CONSOLE_29", n);
-		break;
-	case SUBSYS_CONSOLE_30:
-		strncpy(s, "CONSOLE_30", n);
-		break;
-	case SUBSYS_CONSOLE_31:
-		strncpy(s, "CONSOLE_31", n);
-		break;
-	case SUBSYS_CONSOLE_32:
-		strncpy(s, "CONSOLE_32", n);
-		break;
-	case SUBSYS_CONSOLE_33:
-		strncpy(s, "CONSOLE_33", n);
-		break;
-	case SUBSYS_CONSOLE_34:
-		strncpy(s, "CONSOLE_34", n);
-		break;
-	case SUBSYS_CONSOLE_35:
-		strncpy(s, "CONSOLE_35", n);
-		break;
-	case SUBSYS_CONSOLE_36:
-		strncpy(s, "CONSOLE_36", n);
-		break;
-	case SUBSYS_CONSOLE_37:
-		strncpy(s, "CONSOLE_37", n);
-		break;
-	case SUBSYS_CONSOLE_38:
-		strncpy(s, "CONSOLE_38", n);
-		break;
-	case SUBSYS_CONSOLE_39:
-		strncpy(s, "CONSOLE_39", n);
-		break;
-	case SUBSYS_CONSOLE_40:
-		strncpy(s, "CONSOLE_40", n);
-		break;
-	case SUBSYS_CONSOLE_41:
-		strncpy(s, "CONSOLE_41", n);
-		break;
-	case SUBSYS_CONSOLE_42:
-		strncpy(s, "CONSOLE_42", n);
-		break;
-	case SUBSYS_CONSOLE_43:
-		strncpy(s, "CONSOLE_43", n);
-		break;
-	case SUBSYS_CONSOLE_44:
-		strncpy(s, "CONSOLE_44", n);
-		break;
-	case SUBSYS_CONSOLE_45:
-		strncpy(s, "CONSOLE_45", n);
-		break;
-	case SUBSYS_CONSOLE_46:
-		strncpy(s, "CONSOLE_46", n);
-		break;
-	default:
-		subsys_unknown_to_s(subsys, s, n);
-		break;
-	}
-	s[n - 1] = '\0';
-	return s;
-}
-
-#endif
diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
index 4514772..d58858b 100644
--- a/drivers/staging/unisys/include/uisutils.h
+++ b/drivers/staging/unisys/include/uisutils.h
@@ -32,7 +32,6 @@
 #include "channel.h"
 #include "uisthread.h"
 #include "uisqueue.h"
-#include "diagnostics/appos_subsystems.h"
 #include "vbusdeviceinfo.h"
 #include <linux/atomic.h>
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 105/141] staging: unisys: move hypervisor calls into visorbus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (103 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 104/141] staging: unisys: Remove appos_subsystems.h Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 106/141] staging: unisys: Move controlframework into controlvmchannel.h Benjamin Romer
                   ` (38 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Move hypervisor calls into visorbus and move vbusdeviceinfo.h into
visorbus.
Drivers will call into that to update clientInfo field.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../unisys/common-spar/include/iovmcall_gnuc.h     |  49 -----
 .../unisys/common-spar/include/vbusdeviceinfo.h    | 213 ---------------------
 .../unisys/common-spar/include/vmcallinterface.h   | 163 ----------------
 drivers/staging/unisys/visorbus/iovmcall_gnuc.h    |  49 +++++
 drivers/staging/unisys/visorbus/vbusdeviceinfo.h   | 213 +++++++++++++++++++++
 drivers/staging/unisys/visorbus/vmcallinterface.h  | 161 ++++++++++++++++
 6 files changed, 423 insertions(+), 425 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/vmcallinterface.h
 create mode 100644 drivers/staging/unisys/visorbus/iovmcall_gnuc.h
 create mode 100644 drivers/staging/unisys/visorbus/vbusdeviceinfo.h
 create mode 100644 drivers/staging/unisys/visorbus/vmcallinterface.h

diff --git a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h b/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
deleted file mode 100644
index 57dd93e..0000000
--- a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* Linux GCC Version (32-bit and 64-bit) */
-static inline unsigned long
-__unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
-		     unsigned long reg_ecx)
-{
-	unsigned long result = 0;
-	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
-
-	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
-	if (!(cpuid_ecx & 0x80000000))
-		return -1;
-
-	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
-		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
-	return result;
-}
-
-static inline unsigned long
-__unisys_extended_vmcall_gnuc(unsigned long long tuple,
-			      unsigned long long reg_ebx,
-			      unsigned long long reg_ecx,
-			      unsigned long long reg_edx)
-{
-	unsigned long result = 0;
-	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
-
-	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
-	if (!(cpuid_ecx & 0x80000000))
-		return -1;
-
-	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
-		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx));
-	return result;
-}
diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
deleted file mode 100644
index 9b6d3e6..0000000
--- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VBUSDEVICEINFO_H__
-#define __VBUSDEVICEINFO_H__
-
-#include <linux/types.h>
-
-#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
-
-/* An array of this struct is present in the channel area for each vbus.
- * (See vbuschannel.h.)
- * It is filled in by the client side to provide info about the device
- * and driver from the client's perspective.
- */
-struct ultra_vbus_deviceinfo {
-	u8 devtype[16];		/* short string identifying the device type */
-	u8 drvname[16];		/* driver .sys file name */
-	u8 infostrs[96];	/* sequence of tab-delimited id strings: */
-	/* <DRIVER_REV> <DRIVER_VERTAG> <DRIVER_COMPILETIME> */
-	u8 reserved[128];	/* pad size to 256 bytes */
-};
-
-#pragma pack(pop)
-
-/* Reads chars from the buffer at <src> for <srcmax> bytes, and writes to
- * the buffer at <p>, which is <remain> bytes long, ensuring never to
- * overflow the buffer at <p>, using the following rules:
- * - printable characters are simply copied from the buffer at <src> to the
- *   buffer at <p>
- * - intervening streaks of non-printable characters in the buffer at <src>
- *   are replaced with a single space in the buffer at <p>
- * Note that we pay no attention to '\0'-termination.
- * Returns the number of bytes written to <p>.
- *
- * Pass <p> == NULL and <remain> == 0 for this special behavior.  In this
- * case, we simply return the number of bytes that WOULD HAVE been written
- * to a buffer at <p>, had it been infinitely big.
- */
-static inline int
-vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax)
-{
-	int chars = 0;
-	int nonprintable_streak = 0;
-
-	while (srcmax > 0) {
-		if ((*src >= ' ') && (*src < 0x7f)) {
-			if (nonprintable_streak) {
-				if (remain > 0) {
-					*p = ' ';
-					p++;
-					remain--;
-					chars++;
-				} else if (p == NULL) {
-					chars++;
-				}
-				nonprintable_streak = 0;
-			}
-			if (remain > 0) {
-				*p = *src;
-				p++;
-				remain--;
-				chars++;
-			} else if (p == NULL) {
-				chars++;
-			}
-		} else {
-			nonprintable_streak = 1;
-		}
-		src++;
-		srcmax--;
-	}
-	return chars;
-}
-
-#define VBUSCHANNEL_ADDACHAR(ch, p, remain, chars) \
-	do {					   \
-		if (remain <= 0)		   \
-			break;			   \
-		*p = ch;			   \
-		p++;  chars++;  remain--;	   \
-	} while (0)
-
-/* Converts the non-negative value at <num> to an ascii decimal string
- * at <p>, writing at most <remain> bytes.  Note there is NO '\0' termination
- * written to <p>.
- *
- * Returns the number of bytes written to <p>.
- *
- * Note that we create this function because we need to do this operation in
- * an environment-independent way (since we are in a common header file).
- */
-static inline int
-vbuschannel_itoa(char *p, int remain, int num)
-{
-	int digits = 0;
-	char s[32];
-	int i;
-
-	if (num == 0) {
-		/* '0' is a special case */
-		if (remain <= 0)
-			return 0;
-		*p = '0';
-		return 1;
-	}
-	/* form a backwards decimal ascii string in <s> */
-	while (num > 0) {
-		if (digits >= (int)sizeof(s))
-			return 0;
-		s[digits++] = (num % 10) + '0';
-		num = num / 10;
-	}
-	if (remain < digits) {
-		/* not enough room left at <p> to hold number, so fill with
-		 * '?' */
-		for (i = 0; i < remain; i++, p++)
-			*p = '?';
-		return remain;
-	}
-	/* plug in the decimal ascii string representing the number, by */
-	/* reversing the string we just built in <s> */
-	i = digits;
-	while (i > 0) {
-		i--;
-		*p = s[i];
-		p++;
-	}
-	return digits;
-}
-
-/* Reads <devInfo>, and converts its contents to a printable string at <p>,
- * writing at most <remain> bytes.  Note there is NO '\0' termination
- * written to <p>.
- *
- * Pass <devix> >= 0 if you want a device index presented.
- *
- * Returns the number of bytes written to <p>.
- */
-static inline int
-vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo,
-			      char *p, int remain, int devix)
-{
-	char *psrc;
-	int nsrc, x, i, pad;
-	int chars = 0;
-
-	psrc = &devinfo->devtype[0];
-	nsrc = sizeof(devinfo->devtype);
-	if (vbuschannel_sanitize_buffer(NULL, 0, psrc, nsrc) <= 0)
-		return 0;
-
-	/* emit device index */
-	if (devix >= 0) {
-		VBUSCHANNEL_ADDACHAR('[', p, remain, chars);
-		x = vbuschannel_itoa(p, remain, devix);
-		p += x;
-		remain -= x;
-		chars += x;
-		VBUSCHANNEL_ADDACHAR(']', p, remain, chars);
-	} else {
-		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-	}
-
-	/* emit device type */
-	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
-	p += x;
-	remain -= x;
-	chars += x;
-	pad = 15 - x;		/* pad device type to be exactly 15 chars */
-	for (i = 0; i < pad; i++)
-		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-	VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-
-	/* emit driver name */
-	psrc = &devinfo->drvname[0];
-	nsrc = sizeof(devinfo->drvname);
-	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
-	p += x;
-	remain -= x;
-	chars += x;
-	pad = 15 - x;		/* pad driver name to be exactly 15 chars */
-	for (i = 0; i < pad; i++)
-		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-	VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
-
-	/* emit strings */
-	psrc = &devinfo->infostrs[0];
-	nsrc = sizeof(devinfo->infostrs);
-	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
-	p += x;
-	remain -= x;
-	chars += x;
-	VBUSCHANNEL_ADDACHAR('\n', p, remain, chars);
-
-	return chars;
-}
-
-#endif
diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h
deleted file mode 100644
index 59a7459..0000000
--- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __IOMONINTF_H__
-#define __IOMONINTF_H__
-
-/*
-* This file contains all structures needed to support the VMCALLs for IO
-* Virtualization.  The VMCALLs are provided by Monitor and used by IO code
-* running on IO Partitions.
-*/
-
-#ifdef __GNUC__
-#include "iovmcall_gnuc.h"
-#endif	/*  */
-#include "diagchannel.h"
-
-#ifdef VMCALL_IO_CONTROLVM_ADDR
-#undef VMCALL_IO_CONTROLVM_ADDR
-#endif	/*  */
-
-/* define subsystem number for AppOS, used in uislib driver  */
-#define MDS_APPOS 0x4000000000000000L	/* subsystem = 62 - AppOS */
-enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
-	    /* Note: when a new VMCALL is added:
-	     * - the 1st 2 hex digits correspond to one of the
-	     *   VMCALL_MONITOR_INTERFACE types and
-	     * - the next 2 hex digits are the nth relative instance of within a
-	     *   type
-	     * E.G. for VMCALL_VIRTPART_RECYCLE_PART,
-	     * - the 0x02 identifies it as a VMCALL_VIRTPART type and
-	     * - the 0x01 identifies it as the 1st instance of a VMCALL_VIRTPART
-	     *   type of VMCALL
-	     */
-
-	VMCALL_IO_CONTROLVM_ADDR = 0x0501,	/* used by all Guests, not just
-						 * IO */
-	VMCALL_IO_DIAG_ADDR = 0x0508,
-	VMCALL_IO_VISORSERIAL_ADDR = 0x0509,
-	VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET = 0x0708, /* Allow caller to
-							  * query virtual time
-							  * offset */
-	VMCALL_CHANNEL_VERSION_MISMATCH = 0x0709,
-	VMCALL_POST_CODE_LOGEVENT = 0x070B,	/* LOGEVENT Post Code (RDX) with
-						 * specified subsystem mask (RCX
-						 * - monitor_subsystems.h) and
-						 * severity (RDX) */
-	VMCALL_GENERIC_SURRENDER_QUANTUM_FOREVER = 0x0802, /* Yield the
-							    * remainder & all
-							    * future quantums of
-							    * the caller */
-	VMCALL_MEASUREMENT_DO_NOTHING = 0x0901,
-	VMCALL_UPDATE_PHYSICAL_TIME = 0x0a02	/* Allow
-						 * ULTRA_SERVICE_CAPABILITY_TIME
-						 * capable guest to make
-						 * VMCALL */
-};
-
-#define VMCALL_SUCCESS 0
-#define VMCALL_SUCCESSFUL(result)	(result == 0)
-
-#ifdef __GNUC__
-#define unisys_vmcall(tuple, reg_ebx, reg_ecx) \
-	__unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
-#define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
-	__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
-#define ISSUE_IO_VMCALL(method, param, result) \
-	(result = unisys_vmcall(method, (param) & 0xFFFFFFFF,	\
-				(param) >> 32))
-#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2, param3) \
-	unisys_extended_vmcall(method, param1, param2, param3)
-
-    /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
-     * not used much */
-#define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity)		\
-do {									\
-	ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity,	\
-				 MDS_APPOS, postcode);			\
-} while (0)
-#endif
-
-/* Structures for IO VMCALLs */
-
-/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
-/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
-#pragma pack(push, 1)
-struct phys_info {
-	u64 pi_pfn;
-	u16 pi_off;
-	u16 pi_len;
-};
-
-#pragma pack(pop)
-/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-
-/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
-/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
-#pragma pack(push, 1)
-/* Parameters to VMCALL_IO_CONTROLVM_ADDR interface */
-struct vmcall_io_controlvm_addr_params {
-	    /* The Guest-relative physical address of the ControlVm channel.
-	    * This VMCall fills this in with the appropriate address. */
-	u64 address;	/* contents provided by this VMCALL (OUT) */
-	    /* the size of the ControlVm channel in bytes This VMCall fills this
-	    * in with the appropriate address. */
-	u32 channel_bytes;	/* contents provided by this VMCALL (OUT) */
-	u8 unused[4];		/* Unused Bytes in the 64-Bit Aligned Struct */
-};
-
-#pragma pack(pop)
-/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-
-/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
-/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
-#pragma pack(push, 1)
-/* Parameters to VMCALL_IO_DIAG_ADDR interface */
-struct vmcall_io_diag_addr_params {
-	    /* The Guest-relative physical address of the diagnostic channel.
-	    * This VMCall fills this in with the appropriate address. */
-	u64 address;	/* contents provided by this VMCALL (OUT) */
-};
-
-#pragma pack(pop)
-/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-
-/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
-/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
-#pragma pack(push, 1)
-/* Parameters to VMCALL_IO_VISORSERIAL_ADDR interface */
-struct vmcall_io_visorserial_addr_params {
-	    /* The Guest-relative physical address of the serial console
-	    * channel.  This VMCall fills this in with the appropriate
-	    * address. */
-	u64 address;	/* contents provided by this VMCALL (OUT) */
-};
-
-#pragma pack(pop)
-/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-
-/* Parameters to VMCALL_CHANNEL_MISMATCH interface */
-struct vmcall_channel_version_mismatch_params {
-	u8 chname[32];	/* Null terminated string giving name of channel
-				 * (IN) */
-	u8 item_name[32];	/* Null terminated string giving name of
-				 * mismatched item (IN) */
-	u32 line_no;		/* line# where invoked. (IN) */
-	u8 file_name[36];	/* source code where invoked - Null terminated
-				 * string (IN) */
-};
-
-#endif /* __IOMONINTF_H__ */
diff --git a/drivers/staging/unisys/visorbus/iovmcall_gnuc.h b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h
new file mode 100644
index 0000000..57dd93e
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h
@@ -0,0 +1,49 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/* Linux GCC Version (32-bit and 64-bit) */
+static inline unsigned long
+__unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
+		     unsigned long reg_ecx)
+{
+	unsigned long result = 0;
+	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
+
+	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
+	if (!(cpuid_ecx & 0x80000000))
+		return -1;
+
+	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
+		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
+	return result;
+}
+
+static inline unsigned long
+__unisys_extended_vmcall_gnuc(unsigned long long tuple,
+			      unsigned long long reg_ebx,
+			      unsigned long long reg_ecx,
+			      unsigned long long reg_edx)
+{
+	unsigned long result = 0;
+	unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
+
+	cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
+	if (!(cpuid_ecx & 0x80000000))
+		return -1;
+
+	__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
+		"a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx));
+	return result;
+}
diff --git a/drivers/staging/unisys/visorbus/vbusdeviceinfo.h b/drivers/staging/unisys/visorbus/vbusdeviceinfo.h
new file mode 100644
index 0000000..9b6d3e6
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/vbusdeviceinfo.h
@@ -0,0 +1,213 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VBUSDEVICEINFO_H__
+#define __VBUSDEVICEINFO_H__
+
+#include <linux/types.h>
+
+#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
+
+/* An array of this struct is present in the channel area for each vbus.
+ * (See vbuschannel.h.)
+ * It is filled in by the client side to provide info about the device
+ * and driver from the client's perspective.
+ */
+struct ultra_vbus_deviceinfo {
+	u8 devtype[16];		/* short string identifying the device type */
+	u8 drvname[16];		/* driver .sys file name */
+	u8 infostrs[96];	/* sequence of tab-delimited id strings: */
+	/* <DRIVER_REV> <DRIVER_VERTAG> <DRIVER_COMPILETIME> */
+	u8 reserved[128];	/* pad size to 256 bytes */
+};
+
+#pragma pack(pop)
+
+/* Reads chars from the buffer at <src> for <srcmax> bytes, and writes to
+ * the buffer at <p>, which is <remain> bytes long, ensuring never to
+ * overflow the buffer at <p>, using the following rules:
+ * - printable characters are simply copied from the buffer at <src> to the
+ *   buffer at <p>
+ * - intervening streaks of non-printable characters in the buffer at <src>
+ *   are replaced with a single space in the buffer at <p>
+ * Note that we pay no attention to '\0'-termination.
+ * Returns the number of bytes written to <p>.
+ *
+ * Pass <p> == NULL and <remain> == 0 for this special behavior.  In this
+ * case, we simply return the number of bytes that WOULD HAVE been written
+ * to a buffer at <p>, had it been infinitely big.
+ */
+static inline int
+vbuschannel_sanitize_buffer(char *p, int remain, char *src, int srcmax)
+{
+	int chars = 0;
+	int nonprintable_streak = 0;
+
+	while (srcmax > 0) {
+		if ((*src >= ' ') && (*src < 0x7f)) {
+			if (nonprintable_streak) {
+				if (remain > 0) {
+					*p = ' ';
+					p++;
+					remain--;
+					chars++;
+				} else if (p == NULL) {
+					chars++;
+				}
+				nonprintable_streak = 0;
+			}
+			if (remain > 0) {
+				*p = *src;
+				p++;
+				remain--;
+				chars++;
+			} else if (p == NULL) {
+				chars++;
+			}
+		} else {
+			nonprintable_streak = 1;
+		}
+		src++;
+		srcmax--;
+	}
+	return chars;
+}
+
+#define VBUSCHANNEL_ADDACHAR(ch, p, remain, chars) \
+	do {					   \
+		if (remain <= 0)		   \
+			break;			   \
+		*p = ch;			   \
+		p++;  chars++;  remain--;	   \
+	} while (0)
+
+/* Converts the non-negative value at <num> to an ascii decimal string
+ * at <p>, writing at most <remain> bytes.  Note there is NO '\0' termination
+ * written to <p>.
+ *
+ * Returns the number of bytes written to <p>.
+ *
+ * Note that we create this function because we need to do this operation in
+ * an environment-independent way (since we are in a common header file).
+ */
+static inline int
+vbuschannel_itoa(char *p, int remain, int num)
+{
+	int digits = 0;
+	char s[32];
+	int i;
+
+	if (num == 0) {
+		/* '0' is a special case */
+		if (remain <= 0)
+			return 0;
+		*p = '0';
+		return 1;
+	}
+	/* form a backwards decimal ascii string in <s> */
+	while (num > 0) {
+		if (digits >= (int)sizeof(s))
+			return 0;
+		s[digits++] = (num % 10) + '0';
+		num = num / 10;
+	}
+	if (remain < digits) {
+		/* not enough room left at <p> to hold number, so fill with
+		 * '?' */
+		for (i = 0; i < remain; i++, p++)
+			*p = '?';
+		return remain;
+	}
+	/* plug in the decimal ascii string representing the number, by */
+	/* reversing the string we just built in <s> */
+	i = digits;
+	while (i > 0) {
+		i--;
+		*p = s[i];
+		p++;
+	}
+	return digits;
+}
+
+/* Reads <devInfo>, and converts its contents to a printable string at <p>,
+ * writing at most <remain> bytes.  Note there is NO '\0' termination
+ * written to <p>.
+ *
+ * Pass <devix> >= 0 if you want a device index presented.
+ *
+ * Returns the number of bytes written to <p>.
+ */
+static inline int
+vbuschannel_devinfo_to_string(struct ultra_vbus_deviceinfo *devinfo,
+			      char *p, int remain, int devix)
+{
+	char *psrc;
+	int nsrc, x, i, pad;
+	int chars = 0;
+
+	psrc = &devinfo->devtype[0];
+	nsrc = sizeof(devinfo->devtype);
+	if (vbuschannel_sanitize_buffer(NULL, 0, psrc, nsrc) <= 0)
+		return 0;
+
+	/* emit device index */
+	if (devix >= 0) {
+		VBUSCHANNEL_ADDACHAR('[', p, remain, chars);
+		x = vbuschannel_itoa(p, remain, devix);
+		p += x;
+		remain -= x;
+		chars += x;
+		VBUSCHANNEL_ADDACHAR(']', p, remain, chars);
+	} else {
+		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+	}
+
+	/* emit device type */
+	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
+	p += x;
+	remain -= x;
+	chars += x;
+	pad = 15 - x;		/* pad device type to be exactly 15 chars */
+	for (i = 0; i < pad; i++)
+		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+	VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+
+	/* emit driver name */
+	psrc = &devinfo->drvname[0];
+	nsrc = sizeof(devinfo->drvname);
+	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
+	p += x;
+	remain -= x;
+	chars += x;
+	pad = 15 - x;		/* pad driver name to be exactly 15 chars */
+	for (i = 0; i < pad; i++)
+		VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+	VBUSCHANNEL_ADDACHAR(' ', p, remain, chars);
+
+	/* emit strings */
+	psrc = &devinfo->infostrs[0];
+	nsrc = sizeof(devinfo->infostrs);
+	x = vbuschannel_sanitize_buffer(p, remain, psrc, nsrc);
+	p += x;
+	remain -= x;
+	chars += x;
+	VBUSCHANNEL_ADDACHAR('\n', p, remain, chars);
+
+	return chars;
+}
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h b/drivers/staging/unisys/visorbus/vmcallinterface.h
new file mode 100644
index 0000000..dc09caf
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -0,0 +1,161 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __IOMONINTF_H__
+#define __IOMONINTF_H__
+
+/*
+* This file contains all structures needed to support the VMCALLs for IO
+* Virtualization.  The VMCALLs are provided by Monitor and used by IO code
+* running on IO Partitions.
+*/
+
+#ifdef __GNUC__
+#include "iovmcall_gnuc.h"
+#endif	/*  */
+#include "diagchannel.h"
+
+#ifdef VMCALL_IO_CONTROLVM_ADDR
+#undef VMCALL_IO_CONTROLVM_ADDR
+#endif	/*  */
+
+/* define subsystem number for AppOS, used in uislib driver  */
+#define MDS_APPOS 0x4000000000000000L	/* subsystem = 62 - AppOS */
+enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
+	    /* Note: when a new VMCALL is added:
+	     * - the 1st 2 hex digits correspond to one of the
+	     *   VMCALL_MONITOR_INTERFACE types and
+	     * - the next 2 hex digits are the nth relative instance of within a
+	     *   type
+	     * E.G. for VMCALL_VIRTPART_RECYCLE_PART,
+	     * - the 0x02 identifies it as a VMCALL_VIRTPART type and
+	     * - the 0x01 identifies it as the 1st instance of a VMCALL_VIRTPART
+	     *   type of VMCALL
+	     */
+
+	VMCALL_IO_CONTROLVM_ADDR = 0x0501,	/* used by all Guests, not just
+						 * IO */
+	VMCALL_IO_DIAG_ADDR = 0x0508,
+	VMCALL_IO_VISORSERIAL_ADDR = 0x0509,
+	VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET = 0x0708, /* Allow caller to
+							  * query virtual time
+							  * offset */
+	VMCALL_CHANNEL_VERSION_MISMATCH = 0x0709,
+	VMCALL_POST_CODE_LOGEVENT = 0x070B,	/* LOGEVENT Post Code (RDX) with
+						 * specified subsystem mask (RCX
+						 * - monitor_subsystems.h) and
+						 * severity (RDX) */
+	VMCALL_GENERIC_SURRENDER_QUANTUM_FOREVER = 0x0802, /* Yield the
+							    * remainder & all
+							    * future quantums of
+							    * the caller */
+	VMCALL_MEASUREMENT_DO_NOTHING = 0x0901,
+	VMCALL_UPDATE_PHYSICAL_TIME = 0x0a02	/* Allow
+						 * ULTRA_SERVICE_CAPABILITY_TIME
+						 * capable guest to make
+						 * VMCALL */
+};
+
+#define VMCALL_SUCCESS 0
+#define VMCALL_SUCCESSFUL(result)	(result == 0)
+
+#ifdef __GNUC__
+#define unisys_vmcall(tuple, reg_ebx, reg_ecx) \
+	__unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
+#define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
+	__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
+#define ISSUE_IO_VMCALL(method, param, result) \
+	(result = unisys_vmcall(method, (param) & 0xFFFFFFFF,	\
+				(param) >> 32))
+#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2, param3) \
+	unisys_extended_vmcall(method, param1, param2, param3)
+
+    /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
+     * not used much */
+#define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity)		\
+	ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity,	\
+				 MDS_APPOS, postcode)
+#endif
+
+/* Structures for IO VMCALLs */
+
+/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
+/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
+#pragma pack(push, 1)
+struct phys_info {
+	u64 pi_pfn;
+	u16 pi_off;
+	u16 pi_len;
+};
+
+#pragma pack(pop)
+/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
+
+/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
+/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
+#pragma pack(push, 1)
+/* Parameters to VMCALL_IO_CONTROLVM_ADDR interface */
+struct vmcall_io_controlvm_addr_params {
+	    /* The Guest-relative physical address of the ControlVm channel.
+	    * This VMCall fills this in with the appropriate address. */
+	u64 address;	/* contents provided by this VMCALL (OUT) */
+	    /* the size of the ControlVm channel in bytes This VMCall fills this
+	    * in with the appropriate address. */
+	u32 channel_bytes;	/* contents provided by this VMCALL (OUT) */
+	u8 unused[4];		/* Unused Bytes in the 64-Bit Aligned Struct */
+};
+
+#pragma pack(pop)
+/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
+
+/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
+/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
+#pragma pack(push, 1)
+/* Parameters to VMCALL_IO_DIAG_ADDR interface */
+struct vmcall_io_diag_addr_params {
+	    /* The Guest-relative physical address of the diagnostic channel.
+	    * This VMCall fills this in with the appropriate address. */
+	u64 address;	/* contents provided by this VMCALL (OUT) */
+};
+
+#pragma pack(pop)
+/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
+
+/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
+/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
+#pragma pack(push, 1)
+/* Parameters to VMCALL_IO_VISORSERIAL_ADDR interface */
+struct vmcall_io_visorserial_addr_params {
+	    /* The Guest-relative physical address of the serial console
+	    * channel.  This VMCall fills this in with the appropriate
+	    * address. */
+	u64 address;	/* contents provided by this VMCALL (OUT) */
+};
+
+#pragma pack(pop)
+/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
+
+/* Parameters to VMCALL_CHANNEL_MISMATCH interface */
+struct vmcall_channel_version_mismatch_params {
+	u8 chname[32];	/* Null terminated string giving name of channel
+				 * (IN) */
+	u8 item_name[32];	/* Null terminated string giving name of
+				 * mismatched item (IN) */
+	u32 line_no;		/* line# where invoked. (IN) */
+	u8 file_name[36];	/* source code where invoked - Null terminated
+				 * string (IN) */
+};
+
+#endif /* __IOMONINTF_H__ */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 106/141] staging: unisys: Move controlframework into controlvmchannel.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (104 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 105/141] staging: unisys: move hypervisor calls into visorbus Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 107/141] staging: unisys: Move channel.h to include. Controvlm to visorbus Benjamin Romer
                   ` (37 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Controlframework was only needed by controlvmchannel, move the
structures into that header file.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../include/channels/controlframework.h            | 62 ----------------------
 .../include/channels/controlvmchannel.h            | 32 ++++++++++-
 2 files changed, 31 insertions(+), 63 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/controlframework.h

diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h
deleted file mode 100644
index 33d9caf..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- * Module Name:
- *  controlframework.h
- *
- * Abstract: This file defines common structures in the unmanaged
- *	     Ultravisor (mostly EFI) space.
- *
- */
-
-#ifndef _CONTROL_FRAMEWORK_H_
-#define _CONTROL_FRAMEWORK_H_
-
-#include <linux/types.h>
-#include "channel.h"
-
-struct spar_segment_state  {
-	u16 enabled:1;		/* Bit 0: May enter other states */
-	u16 active:1;		/* Bit 1: Assigned to active partition */
-	u16 alive:1;		/* Bit 2: Configure message sent to
-				 * service/server */
-	u16 revoked:1;		/* Bit 3: similar to partition state
-				 * ShuttingDown */
-	u16 allocated:1;	/* Bit 4: memory (device/port number)
-				 * has been selected by Command */
-	u16 known:1;		/* Bit 5: has been introduced to the
-				 * service/guest partition */
-	u16 ready:1;		/* Bit 6: service/Guest partition has
-				 * responded to introduction */
-	u16 operating:1;	/* Bit 7: resource is configured and
-				 * operating */
-	/* Note: don't use high bit unless we need to switch to ushort
-	 * which is non-compliant */
-};
-
-static const struct spar_segment_state segment_state_running = {
-	1, 1, 1, 0, 1, 1, 1, 1
-};
-
-static const struct spar_segment_state segment_state_paused = {
-	1, 1, 1, 0, 1, 1, 1, 0
-};
-
-static const struct spar_segment_state segment_state_standby = {
-	1, 1, 0, 0, 1, 1, 1, 0
-};
-
-#endif				/* _CONTROL_FRAMEWORK_H_ not defined */
diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
index f1c86fb..a50d9cf 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
@@ -18,7 +18,6 @@
 
 #include <linux/uuid.h>
 #include "channel.h"
-#include "controlframework.h"
 
 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID	\
@@ -56,6 +55,37 @@
 /* Max num of messages stored during IOVM creation to be reused after crash */
 #define CONTROLVM_CRASHMSG_MAX		2
 
+struct spar_segment_state  {
+	u16 enabled:1;		/* Bit 0: May enter other states */
+	u16 active:1;		/* Bit 1: Assigned to active partition */
+	u16 alive:1;		/* Bit 2: Configure message sent to
+				 * service/server */
+	u16 revoked:1;		/* Bit 3: similar to partition state
+				 * ShuttingDown */
+	u16 allocated:1;	/* Bit 4: memory (device/port number)
+				 * has been selected by Command */
+	u16 known:1;		/* Bit 5: has been introduced to the
+				 * service/guest partition */
+	u16 ready:1;		/* Bit 6: service/Guest partition has
+				 * responded to introduction */
+	u16 operating:1;	/* Bit 7: resource is configured and
+				 * operating */
+	/* Note: don't use high bit unless we need to switch to ushort
+	 * which is non-compliant */
+};
+
+static const struct spar_segment_state segment_state_running = {
+	1, 1, 1, 0, 1, 1, 1, 1
+};
+
+static const struct spar_segment_state segment_state_paused = {
+	1, 1, 1, 0, 1, 1, 1, 0
+};
+
+static const struct spar_segment_state segment_state_standby = {
+	1, 1, 0, 0, 1, 1, 1, 0
+};
+
 /* Ids for commands that may appear in either queue of a ControlVm channel.
  *
  *  Commands that are initiated by the command partition (CP), by an IO or
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 107/141] staging: unisys: Move channel.h to include. Controvlm to visorbus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (105 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 106/141] staging: unisys: Move controlframework into controlvmchannel.h Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 108/141] staging: unisys: vbuschannel belonsg " Benjamin Romer
                   ` (36 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Channel.h is used by all channels, it needs to be in include.
Controlvm Channel is only used by visorbus, it needs to just be there.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../unisys/common-spar/include/channels/channel.h  | 590 ---------------------
 .../common-spar/include/channels/channel_guid.h    |  61 ---
 .../include/channels/controlvmchannel.h            | 485 -----------------
 drivers/staging/unisys/include/channel.h           | 555 +++++++++++++++++++
 drivers/staging/unisys/include/channel_guid.h      |  61 +++
 drivers/staging/unisys/visorbus/controlvmchannel.h | 485 +++++++++++++++++
 6 files changed, 1101 insertions(+), 1136 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/channel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/channel_guid.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
 create mode 100644 drivers/staging/unisys/include/channel.h
 create mode 100644 drivers/staging/unisys/include/channel_guid.h
 create mode 100644 drivers/staging/unisys/visorbus/controlvmchannel.h

diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h
deleted file mode 100644
index 6fb6e5b..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/channel.h
+++ /dev/null
@@ -1,590 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CHANNEL_H__
-#define __CHANNEL_H__
-
-#include <linux/types.h>
-#include <linux/io.h>
-#include <linux/uuid.h>
-
-/*
-* Whenever this file is changed a corresponding change must be made in
-* the Console/ServicePart/visordiag_early/supervisor_channel.h file
-* which is needed for Linux kernel compiles. These two files must be
-* in sync.
-*/
-
-/* define the following to prevent include nesting in kernel header
- * files of similar abbreviated content
- */
-#define __SUPERVISOR_CHANNEL_H__
-
-#define SIGNATURE_16(A, B) ((A) | (B<<8))
-#define SIGNATURE_32(A, B, C, D) \
-	(SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
-#define SIGNATURE_64(A, B, C, D, E, F, G, H) \
-	(SIGNATURE_32(A, B, C, D) | ((u64)(SIGNATURE_32(E, F, G, H)) << 32))
-
-#ifndef lengthof
-#define lengthof(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
-#endif
-#ifndef COVERQ
-#define COVERQ(v, d)  (((v)+(d)-1) / (d))
-#endif
-#ifndef COVER
-#define COVER(v, d)   ((d)*COVERQ(v, d))
-#endif
-
-#define ULTRA_CHANNEL_PROTOCOL_SIGNATURE  SIGNATURE_32('E', 'C', 'N', 'L')
-
-enum channel_serverstate {
-	CHANNELSRV_UNINITIALIZED = 0,	/* channel is in an undefined state */
-	CHANNELSRV_READY = 1	/* channel has been initialized by server */
-};
-
-enum channel_clientstate {
-	CHANNELCLI_DETACHED = 0,
-	CHANNELCLI_DISABLED = 1,	/* client can see channel but is NOT
-					 * allowed to use it unless given TBD
-					 * explicit request (should actually be
-					 * < DETACHED) */
-	CHANNELCLI_ATTACHING = 2,	/* legacy EFI client request
-					 * for EFI server to attach */
-	CHANNELCLI_ATTACHED = 3,	/* idle, but client may want
-					 * to use channel any time */
-	CHANNELCLI_BUSY = 4,	/* client either wants to use or is
-				 * using channel */
-	CHANNELCLI_OWNED = 5	/* "no worries" state - client can
-				 * access channel anytime */
-};
-
-static inline const u8 *
-ULTRA_CHANNELCLI_STRING(u32 v)
-{
-	switch (v) {
-	case CHANNELCLI_DETACHED:
-		return (const u8 *)("DETACHED");
-	case CHANNELCLI_DISABLED:
-		return (const u8 *)("DISABLED");
-	case CHANNELCLI_ATTACHING:
-		return (const u8 *)("ATTACHING");
-	case CHANNELCLI_ATTACHED:
-		return (const u8 *)("ATTACHED");
-	case CHANNELCLI_BUSY:
-		return (const u8 *)("BUSY");
-	case CHANNELCLI_OWNED:
-		return (const u8 *)("OWNED");
-	default:
-		break;
-	}
-	return (const u8 *)("?");
-}
-
-#define SPAR_CHANNEL_SERVER_READY(ch) \
-	(readl(&(ch)->srv_state) == CHANNELSRV_READY)
-
-#define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n)				\
-	(((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \
-	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DISABLED)) || \
-	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DISABLED)) || \
-	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DETACHED)) || \
-	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DETACHED)) || \
-	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHING)) || \
-	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_ATTACHED)) || \
-	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHED)) || \
-	  (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_ATTACHED)) ||	\
-	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_BUSY)) ||	\
-	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_OWNED)) || \
-	  (((o) == CHANNELCLI_DISABLED) && ((n) == CHANNELCLI_OWNED)) || \
-	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_OWNED)) || \
-	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_OWNED)) || \
-	  (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \
-	 ? (1) : (0))
-
-#define SPAR_CHANNEL_CLIENT_CHK_TRANSITION(old, new, id, log,	\
-					    file, line)			\
-	do {								\
-		if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new))	\
-			pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \
-				id, "CliState<x>",		\
-				ULTRA_CHANNELCLI_STRING(old),	\
-				old,				\
-				ULTRA_CHANNELCLI_STRING(new),	\
-				new,				\
-				pathname_last_n_nodes((u8 *)file, 4), \
-				line);				\
-	} while (0)
-
-#define SPAR_CHANNEL_CLIENT_TRANSITION(ch, id, newstate, log)		\
-	do {								\
-		SPAR_CHANNEL_CLIENT_CHK_TRANSITION(			\
-			readl(&(((struct channel_header __iomem *)\
-				 (ch))->cli_state_os)),		\
-			newstate, id, log, __FILE__, __LINE__);		\
-			pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \
-				id, "CliStateOS",			\
-				ULTRA_CHANNELCLI_STRING( \
-				      readl(&((struct channel_header __iomem *)\
-					      (ch))->cli_state_os)),	\
-				readl(&((struct channel_header __iomem *)\
-				      (ch))->cli_state_os),		\
-				ULTRA_CHANNELCLI_STRING(newstate),	\
-				newstate,				\
-				pathname_last_n_nodes(__FILE__, 4), __LINE__); \
-		writel(newstate, &((struct channel_header __iomem *)\
-				   (ch))->cli_state_os);		\
-		mb(); /* required for channel synch */			\
-	} while (0)
-
-/* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */
-/* throttling invalid boot channel statetransition error due to client
- * disabled */
-#define ULTRA_CLIERRORBOOT_THROTTLEMSG_DISABLED    0x01
-
-/* throttling invalid boot channel statetransition error due to client
- * not attached */
-#define ULTRA_CLIERRORBOOT_THROTTLEMSG_NOTATTACHED 0x02
-
-/* throttling invalid boot channel statetransition error due to busy channel */
-#define ULTRA_CLIERRORBOOT_THROTTLEMSG_BUSY        0x04
-
-/* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorOS: */
-/* throttling invalid guest OS channel statetransition error due to
- * client disabled */
-#define ULTRA_CLIERROROS_THROTTLEMSG_DISABLED      0x01
-
-/* throttling invalid guest OS channel statetransition error due to
- * client not attached */
-#define ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED   0x02
-
-/* throttling invalid guest OS channel statetransition error due to
- * busy channel */
-#define ULTRA_CLIERROROS_THROTTLEMSG_BUSY          0x04
-
-/* Values for ULTRA_CHANNEL_PROTOCOL.Features: This define exists so
-* that windows guest can look at the FeatureFlags in the io channel,
-* and configure the windows driver to use interrupts or not based on
-* this setting.  This flag is set in uislib after the
-* ULTRA_VHBA_init_channel is called.  All feature bits for all
-* channels should be defined here.  The io channel feature bits are
-* defined right here */
-#define ULTRA_IO_DRIVER_ENABLES_INTS (0x1ULL << 1)
-#define ULTRA_IO_CHANNEL_IS_POLLING (0x1ULL << 3)
-#define ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS (0x1ULL << 4)
-#define ULTRA_IO_DRIVER_DISABLES_INTS (0x1ULL << 5)
-#define ULTRA_IO_DRIVER_SUPPORTS_ENHANCED_RCVBUF_CHECKING (0x1ULL << 6)
-
-#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
-/* Common Channel Header */
-struct channel_header {
-	u64 signature;		/* Signature */
-	u32 legacy_state;	/* DEPRECATED - being replaced by */
-	/* /              SrvState, CliStateBoot, and CliStateOS below */
-	u32 header_size;	/* sizeof(struct channel_header) */
-	u64 size;		/* Total size of this channel in bytes */
-	u64 features;		/* Flags to modify behavior */
-	uuid_le chtype;		/* Channel type: data, bus, control, etc. */
-	u64 partition_handle;	/* ID of guest partition */
-	u64 handle;		/* Device number of this channel in client */
-	u64 ch_space_offset;	/* Offset in bytes to channel specific area */
-	u32 version_id;		/* struct channel_header Version ID */
-	u32 partition_index;	/* Index of guest partition */
-	uuid_le zone_uuid;	/* Guid of Channel's zone */
-	u32 cli_str_offset;	/* offset from channel header to
-				 * nul-terminated ClientString (0 if
-				 * ClientString not present) */
-	u32 cli_state_boot;	/* CHANNEL_CLIENTSTATE of pre-boot
-				 * EFI client of this channel */
-	u32 cmd_state_cli;	/* CHANNEL_COMMANDSTATE (overloaded in
-				 * Windows drivers, see ServerStateUp,
-				 * ServerStateDown, etc) */
-	u32 cli_state_os;	/* CHANNEL_CLIENTSTATE of Guest OS
-				 * client of this channel */
-	u32 ch_characteristic;	/* CHANNEL_CHARACTERISTIC_<xxx> */
-	u32 cmd_state_srv;	/* CHANNEL_COMMANDSTATE (overloaded in
-				 * Windows drivers, see ServerStateUp,
-				 * ServerStateDown, etc) */
-	u32 srv_state;		/* CHANNEL_SERVERSTATE */
-	u8 cli_error_boot;	/* bits to indicate err states for
-				 * boot clients, so err messages can
-				 * be throttled */
-	u8 cli_error_os;	/* bits to indicate err states for OS
-				 * clients, so err messages can be
-				 * throttled */
-	u8 filler[1];		/* Pad out to 128 byte cacheline */
-	/* Please add all new single-byte values below here */
-	u8 recover_channel;
-};
-
-#define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0)
-
-/* Subheader for the Signal Type variation of the Common Channel */
-struct signal_queue_header {
-	/* 1st cache line */
-	u32 version;		/* SIGNAL_QUEUE_HEADER Version ID */
-	u32 chtype;		/* Queue type: storage, network */
-	u64 size;		/* Total size of this queue in bytes */
-	u64 sig_base_offset;	/* Offset to signal queue area */
-	u64 features;		/* Flags to modify behavior */
-	u64 num_sent;		/* Total # of signals placed in this queue */
-	u64 num_overflows;	/* Total # of inserts failed due to
-				 * full queue */
-	u32 signal_size;	/* Total size of a signal for this queue */
-	u32 max_slots;		/* Max # of slots in queue, 1 slot is
-				 * always empty */
-	u32 max_signals;	/* Max # of signals in queue
-				 * (MaxSignalSlots-1) */
-	u32 head;		/* Queue head signal # */
-	/* 2nd cache line */
-	u64 num_received;	/* Total # of signals removed from this queue */
-	u32 tail;		/* Queue tail signal # (on separate
-				 * cache line) */
-	u32 reserved1;		/* Reserved field */
-	u64 reserved2;		/* Reserved field */
-	u64 client_queue;
-	u64 num_irq_received;	/* Total # of Interrupts received.  This
-					 * is incremented by the ISR in the
-					 * guest windows driver */
-	u64 num_empty;		/* Number of times that visor_signal_remove
-				 * is called and returned Empty
-				 * Status. */
-	u32 errorflags;		/* Error bits set during SignalReinit
-				 * to denote trouble with client's
-				 * fields */
-	u8 filler[12];		/* Pad out to 64 byte cacheline */
-};
-
-#pragma pack(pop)
-
-#define spar_signal_init(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ)	\
-	do {								\
-		memset(&chan->QHDRFLD, 0, sizeof(chan->QHDRFLD));	\
-		chan->QHDRFLD.version = ver;				\
-		chan->QHDRFLD.chtype = typ;				\
-		chan->QHDRFLD.size = sizeof(chan->QDATAFLD);		\
-		chan->QHDRFLD.signal_size = sizeof(QDATATYPE);		\
-		chan->QHDRFLD.sig_base_offset = (u64)(chan->QDATAFLD)-	\
-			(u64)(&chan->QHDRFLD);				\
-		chan->QHDRFLD.max_slots =				\
-			sizeof(chan->QDATAFLD)/sizeof(QDATATYPE);	\
-		chan->QHDRFLD.max_signals = chan->QHDRFLD.max_slots-1;	\
-	} while (0)
-
-/* Generic function useful for validating any type of channel when it is
- * received by the client that will be accessing the channel.
- * Note that <logCtx> is only needed for callers in the EFI environment, and
- * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
- */
-static inline int
-spar_check_channel_client(void __iomem *ch,
-			  uuid_le expected_uuid,
-			  char *chname,
-			  u64 expected_min_bytes,
-			  u32 expected_version,
-			  u64 expected_signature)
-{
-	if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
-		uuid_le guid;
-
-		memcpy_fromio(&guid,
-			      &((struct channel_header __iomem *)(ch))->chtype,
-			      sizeof(guid));
-		/* caller wants us to verify type GUID */
-		if (uuid_le_cmp(guid, expected_uuid) != 0) {
-			pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
-			       chname, &expected_uuid,
-			       &expected_uuid, &guid);
-			return 0;
-		}
-	}
-	if (expected_min_bytes > 0) {	/* caller wants us to verify
-					 * channel size */
-		unsigned long long bytes =
-				readq(&((struct channel_header __iomem *)
-					(ch))->size);
-		if (bytes < expected_min_bytes) {
-			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
-			       chname, &expected_uuid,
-			       (unsigned long long)expected_min_bytes, bytes);
-			return 0;
-		}
-	}
-	if (expected_version > 0) {	/* caller wants us to verify
-					 * channel version */
-		unsigned long ver = readl(&((struct channel_header __iomem *)
-				    (ch))->version_id);
-		if (ver != expected_version) {
-			pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
-			       chname, &expected_uuid,
-			       (unsigned long)expected_version, ver);
-			return 0;
-		}
-	}
-	if (expected_signature > 0) {	/* caller wants us to verify
-					 * channel signature */
-		unsigned long long sig =
-				readq(&((struct channel_header __iomem *)
-					(ch))->signature);
-		if (sig != expected_signature) {
-			pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
-			       chname, &expected_uuid,
-			       expected_signature, sig);
-			return 0;
-		}
-	}
-	return 1;
-}
-
-/* Generic function useful for validating any type of channel when it is about
- * to be initialized by the server of the channel.
- * Note that <logCtx> is only needed for callers in the EFI environment, and
- * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
- */
-static inline int spar_check_channel_server(uuid_le typeuuid, char *name,
-					    u64 expected_min_bytes,
-					    u64 actual_bytes)
-{
-	if (expected_min_bytes > 0)	/* caller wants us to verify
-					 * channel size */
-		if (actual_bytes < expected_min_bytes) {
-			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
-			       name, &typeuuid, expected_min_bytes,
-			       actual_bytes);
-			return 0;
-		}
-	return 1;
-}
-
-/* Given a file pathname <s> (with '/' or '\' separating directory nodes),
- * returns a pointer to the beginning of a node within that pathname such
- * that the number of nodes from that pointer to the end of the string is
- * NOT more than <n>.  Note that if the pathname has less than <n> nodes
- * in it, the return pointer will be to the beginning of the string.
- */
-static inline u8 *
-pathname_last_n_nodes(u8 *s, unsigned int n)
-{
-	u8 *p = s;
-	unsigned int node_count = 0;
-
-	while (*p != '\0') {
-		if ((*p == '/') || (*p == '\\'))
-			node_count++;
-		p++;
-	}
-	if (node_count <= n)
-		return s;
-	while (n > 0) {
-		p--;
-		if (p == s)
-			break;	/* should never happen, unless someone
-				 * is changing the string while we are
-				 * looking at it!! */
-		if ((*p == '/') || (*p == '\\'))
-			n--;
-	}
-	return p + 1;
-}
-
-static inline int
-spar_channel_client_acquire_os(void __iomem *ch, u8 *id)
-{
-	struct channel_header __iomem *hdr = ch;
-
-	if (readl(&hdr->cli_state_os) == CHANNELCLI_DISABLED) {
-		if ((readb(&hdr->cli_error_os)
-		     & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED) == 0) {
-			/* we are NOT throttling this message */
-			writeb(readb(&hdr->cli_error_os) |
-			       ULTRA_CLIERROROS_THROTTLEMSG_DISABLED,
-			       &hdr->cli_error_os);
-			/* throttle until acquire successful */
-
-			pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED\n",
-				id);
-		}
-		return 0;
-	}
-	if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) &&
-	    (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) {
-		/* Our competitor is DISABLED, so we can transition to OWNED */
-		pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d)\n",
-			id, "cli_state_os",
-			ULTRA_CHANNELCLI_STRING(readl(&hdr->cli_state_os)),
-			readl(&hdr->cli_state_os),
-			ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED),
-			CHANNELCLI_OWNED);
-		writel(CHANNELCLI_OWNED, &hdr->cli_state_os);
-		mb(); /* required for channel synch */
-	}
-	if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED) {
-		if (readb(&hdr->cli_error_os) != 0) {
-			/* we are in an error msg throttling state;
-			 * come out of it */
-			pr_info("%s Channel OS client acquire now successful\n",
-				id);
-			writeb(0, &hdr->cli_error_os);
-		}
-		return 1;
-	}
-
-	/* We have to do it the "hard way".  We transition to BUSY,
-	* and can use the channel iff our competitor has not also
-	* transitioned to BUSY. */
-	if (readl(&hdr->cli_state_os) != CHANNELCLI_ATTACHED) {
-		if ((readb(&hdr->cli_error_os)
-		     & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED) == 0) {
-			/* we are NOT throttling this message */
-			writeb(readb(&hdr->cli_error_os) |
-			       ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED,
-			       &hdr->cli_error_os);
-			/* throttle until acquire successful */
-			pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d))\n",
-				id, ULTRA_CHANNELCLI_STRING(
-						readl(&hdr->cli_state_os)),
-				readl(&hdr->cli_state_os));
-		}
-		return 0;
-	}
-	writel(CHANNELCLI_BUSY, &hdr->cli_state_os);
-	mb(); /* required for channel synch */
-	if (readl(&hdr->cli_state_boot) == CHANNELCLI_BUSY) {
-		if ((readb(&hdr->cli_error_os)
-		     & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) {
-			/* we are NOT throttling this message */
-			writeb(readb(&hdr->cli_error_os) |
-			       ULTRA_CLIERROROS_THROTTLEMSG_BUSY,
-			       &hdr->cli_error_os);
-			/* throttle until acquire successful */
-			pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY\n",
-				id);
-		}
-		/* reset busy */
-		writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os);
-		mb(); /* required for channel synch */
-		return 0;
-	}
-	if (readb(&hdr->cli_error_os) != 0) {
-		/* we are in an error msg throttling state; come out of it */
-		pr_info("%s Channel OS client acquire now successful\n", id);
-		writeb(0, &hdr->cli_error_os);
-	}
-	return 1;
-}
-
-static inline void
-spar_channel_client_release_os(void __iomem *ch, u8 *id)
-{
-	struct channel_header __iomem *hdr = ch;
-
-	if (readb(&hdr->cli_error_os) != 0) {
-		/* we are in an error msg throttling state; come out of it */
-		pr_info("%s Channel OS client error state cleared\n", id);
-		writeb(0, &hdr->cli_error_os);
-	}
-	if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED)
-		return;
-	if (readl(&hdr->cli_state_os) != CHANNELCLI_BUSY) {
-		pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d))\n",
-			id, ULTRA_CHANNELCLI_STRING(
-					readl(&hdr->cli_state_os)),
-			readl(&hdr->cli_state_os));
-		/* return; */
-	}
-	writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os); /* release busy */
-}
-
-/*
-* Routine Description:
-* Tries to insert the prebuilt signal pointed to by pSignal into the nth
-* Queue of the Channel pointed to by pChannel
-*
-* Parameters:
-* pChannel: (IN) points to the IO Channel
-* Queue: (IN) nth Queue of the IO Channel
-* pSignal: (IN) pointer to the signal
-*
-* Assumptions:
-* - pChannel, Queue and pSignal are valid.
-* - If insertion fails due to a full queue, the caller will determine the
-* retry policy (e.g. wait & try again, report an error, etc.).
-*
-* Return value: 1 if the insertion succeeds, 0 if the queue was
-* full.
-*/
-
-unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
-				 void *sig);
-
-/*
-* Routine Description:
-* Removes one signal from Channel pChannel's nth Queue at the
-* time of the call and copies it into the memory pointed to by
-* pSignal.
-*
-* Parameters:
-* pChannel: (IN) points to the IO Channel
-* Queue: (IN) nth Queue of the IO Channel
-* pSignal: (IN) pointer to where the signals are to be copied
-*
-* Assumptions:
-* - pChannel and Queue are valid.
-* - pSignal points to a memory area large enough to hold queue's SignalSize
-*
-* Return value: 1 if the removal succeeds, 0 if the queue was
-* empty.
-*/
-
-unsigned char spar_signal_remove(struct channel_header __iomem *ch, u32 queue,
-				 void *sig);
-
-/*
-* Routine Description:
-* Removes all signals present in Channel pChannel's nth Queue at the
-* time of the call and copies them into the memory pointed to by
-* pSignal.  Returns the # of signals copied as the value of the routine.
-*
-* Parameters:
-* pChannel: (IN) points to the IO Channel
-* Queue: (IN) nth Queue of the IO Channel
-* pSignal: (IN) pointer to where the signals are to be copied
-*
-* Assumptions:
-* - pChannel and Queue are valid.
-* - pSignal points to a memory area large enough to hold Queue's MaxSignals
-* # of signals, each of which is Queue's SignalSize.
-*
-* Return value:
-* # of signals copied.
-*/
-unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue,
-				    void *sig);
-
-/*
-* Routine Description:
-* Determine whether a signal queue is empty.
-*
-* Parameters:
-* pChannel: (IN) points to the IO Channel
-* Queue: (IN) nth Queue of the IO Channel
-*
-* Return value:
-* 1 if the signal queue is empty, 0 otherwise.
-*/
-unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch,
-				     u32 queue);
-
-#endif
diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h
deleted file mode 100644
index 706363fc..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- * CHANNEL Guids
- */
-
-/* Used in IOChannel
- * {414815ed-c58c-11da-95a9-00e08161165f}
- */
-#define SPAR_VHBA_CHANNEL_PROTOCOL_UUID \
-		UUID_LE(0x414815ed, 0xc58c, 0x11da, \
-				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le spar_vhba_channel_protocol_uuid =
-	SPAR_VHBA_CHANNEL_PROTOCOL_UUID;
-
-/* Used in IOChannel
- * {8cd5994d-c58e-11da-95a9-00e08161165f}
- */
-#define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \
-		UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \
-				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le spar_vnic_channel_protocol_uuid =
-	SPAR_VNIC_CHANNEL_PROTOCOL_UUID;
-
-/* Used in IOChannel
- * {72120008-4AAB-11DC-8530-444553544200}
- */
-#define SPAR_SIOVM_UUID \
-		UUID_LE(0x72120008, 0x4AAB, 0x11DC, \
-				0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00)
-static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID;
-
-/* Used in visornoop/visornoop_main.c
- * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f}
- */
-#define SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID  \
-		UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \
-				0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f)
-
-static const uuid_le spar_controldirector_channel_protocol_uuid =
-	SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID;
-
-/* Used in visorchipset/visorchipset_main.c
- * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C}
- */
-#define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID				\
-		UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \
-				0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c)
diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
deleted file mode 100644
index a50d9cf..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ /dev/null
@@ -1,485 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CONTROLVMCHANNEL_H__
-#define __CONTROLVMCHANNEL_H__
-
-#include <linux/uuid.h>
-#include "channel.h"
-
-/* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
-#define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID	\
-		UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
-			0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
-
-#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
-	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-#define CONTROLVM_MESSAGE_MAX 64
-
-/* Must increment this whenever you insert or delete fields within
- * this channel struct.  Also increment whenever you change the meaning
- * of fields within this channel struct so as to break pre-existing
- * software.  Note that you can usually add fields to the END of the
- * channel struct withOUT needing to increment this.
- */
-#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
-
-#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
-	spar_check_channel_client(ch, \
-		SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
-		"controlvm", \
-		sizeof(struct spar_controlvm_channel_protocol), \
-		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
-		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
-
-#define MAX_SERIAL_NUM	32
-
-/* Defines for various channel queues */
-#define CONTROLVM_QUEUE_REQUEST		0
-#define CONTROLVM_QUEUE_RESPONSE	1
-#define CONTROLVM_QUEUE_EVENT		2
-#define CONTROLVM_QUEUE_ACK		3
-
-/* Max num of messages stored during IOVM creation to be reused after crash */
-#define CONTROLVM_CRASHMSG_MAX		2
-
-struct spar_segment_state  {
-	u16 enabled:1;		/* Bit 0: May enter other states */
-	u16 active:1;		/* Bit 1: Assigned to active partition */
-	u16 alive:1;		/* Bit 2: Configure message sent to
-				 * service/server */
-	u16 revoked:1;		/* Bit 3: similar to partition state
-				 * ShuttingDown */
-	u16 allocated:1;	/* Bit 4: memory (device/port number)
-				 * has been selected by Command */
-	u16 known:1;		/* Bit 5: has been introduced to the
-				 * service/guest partition */
-	u16 ready:1;		/* Bit 6: service/Guest partition has
-				 * responded to introduction */
-	u16 operating:1;	/* Bit 7: resource is configured and
-				 * operating */
-	/* Note: don't use high bit unless we need to switch to ushort
-	 * which is non-compliant */
-};
-
-static const struct spar_segment_state segment_state_running = {
-	1, 1, 1, 0, 1, 1, 1, 1
-};
-
-static const struct spar_segment_state segment_state_paused = {
-	1, 1, 1, 0, 1, 1, 1, 0
-};
-
-static const struct spar_segment_state segment_state_standby = {
-	1, 1, 0, 0, 1, 1, 1, 0
-};
-
-/* Ids for commands that may appear in either queue of a ControlVm channel.
- *
- *  Commands that are initiated by the command partition (CP), by an IO or
- *  console service partition (SP), or by a guest partition (GP)are:
- *  - issued on the RequestQueue queue (q #0) in the ControlVm channel
- *  - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
- *
- *  Events that are initiated by an IO or console service partition (SP) or
- *  by a guest partition (GP) are:
- *  - issued on the EventQueue queue (q #2) in the ControlVm channel
- *  - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
- */
-enum controlvm_id {
-	CONTROLVM_INVALID = 0,
-	/* SWITCH commands required Parameter: SwitchNumber */
-	/* BUS commands required Parameter: BusNumber */
-	CONTROLVM_BUS_CREATE = 0x101,			/* CP --> SP, GP */
-	CONTROLVM_BUS_DESTROY = 0x102,			/* CP --> SP, GP */
-	CONTROLVM_BUS_CONFIGURE = 0x104,		/* CP --> SP */
-	CONTROLVM_BUS_CHANGESTATE = 0x105,		/* CP --> SP, GP */
-	CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106,	/* SP, GP --> CP */
-/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
-
-	CONTROLVM_DEVICE_CREATE = 0x201,		/* CP --> SP, GP */
-	CONTROLVM_DEVICE_DESTROY = 0x202,		/* CP --> SP, GP */
-	CONTROLVM_DEVICE_CONFIGURE = 0x203,		/* CP --> SP */
-	CONTROLVM_DEVICE_CHANGESTATE = 0x204,		/* CP --> SP, GP */
-	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205,	/* SP, GP --> CP */
-	CONTROLVM_DEVICE_RECONFIGURE = 0x206,		/* CP --> Boot */
-/* CHIPSET commands */
-	CONTROLVM_CHIPSET_INIT = 0x301,			/* CP --> SP, GP */
-	CONTROLVM_CHIPSET_STOP = 0x302,			/* CP --> SP, GP */
-	CONTROLVM_CHIPSET_READY = 0x304,		/* CP --> SP */
-	CONTROLVM_CHIPSET_SELFTEST = 0x305,		/* CP --> SP */
-
-};
-
-struct irq_info {
-	u64 reserved1;
-
-	 /* specifies interrupt handle. It is used to retrieve the
-	  *   corresponding interrupt pin from Monitor; and the
-	  *   interrupt pin is used to connect to the corresponding
-	  *   interrupt.  Used by IOPart-GP only.
-	  */
-	u64 recv_irq_handle;
-
-	 /* specifies interrupt vector. It, interrupt pin, and shared are
-	  *   used to connect to the corresponding interrupt.  Used by
-	  *   IOPart-GP only.
-	  */
-	u32 recv_irq_vector;
-
-    /* specifies if the recvInterrupt is shared.  It, interrupt pin
-     * and vector are used to connect to 0 = not shared; 1 = shared.
-     * the corresponding interrupt.  Used by IOPart-GP only.
-     */
-	u8 recv_irq_shared;
-	u8 reserved[3];	/* Natural alignment purposes */
-};
-
-struct pci_id {
-	u16 domain;
-	u8 bus;
-	u8 slot;
-	u8 func;
-	u8 reserved[3];	/* Natural alignment purposes */
-};
-
-struct efi_spar_indication  {
-	u64 boot_to_fw_ui:1;		/* Bit 0: Stop in uefi ui */
-	u64 clear_nvram:1;		/* Bit 1: Clear NVRAM */
-	u64 clear_cmos:1;		/* Bit 2: Clear CMOS */
-	u64 boot_to_tool:1;		/* Bit 3: Run install tool */
-	/* remaining bits are available */
-};
-
-enum ultra_chipset_feature {
-	ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
-	ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
-};
-
-/* This is the common structure that is at the beginning of every
- *  ControlVm message (both commands and responses) in any ControlVm
- *  queue.  Commands are easily distinguished from responses by
- *  looking at the flags.response field.
- */
-struct controlvm_message_header  {
-	u32 id;		/* See CONTROLVM_ID. */
-	/* For requests, indicates the message type. */
-	/* For responses, indicates the type of message we are responding to. */
-
-	u32 message_size;	/* Includes size of this struct + size
-				 * of message */
-	u32 segment_index;	/* Index of segment containing Vm
-				 * message/information */
-	u32 completion_status;	/* Error status code or result of
-				 * message completion */
-	struct  {
-		u32 failed:1;		   /* =1 in a response to * signify
-					    * failure */
-		u32 response_expected:1;   /* =1 in all messages that expect a
-					    * response (Control ignores this
-					    * bit) */
-		u32 server:1;		   /* =1 in all bus & device-related
-					    * messages where the message
-					    * receiver is to act as the bus or
-					    * device server */
-		u32 test_message:1;	   /* =1 for testing use only
-					    * (Control and Command ignore this
-					    * bit) */
-		u32 partial_completion:1;  /* =1 if there are forthcoming
-					    * responses/acks associated
-					    * with this message */
-		u32 preserve:1;		   /* =1 this is to let us know to
-					    * preserve channel contents
-					    * (for running guests)*/
-		u32 writer_in_diag:1;	   /* =1 the DiagWriter is active in the
-					    * Diagnostic Partition*/
-	} flags;
-	u32 reserved;		/* Natural alignment */
-	u64 message_handle;	/* Identifies the particular message instance,
-				 * and is used to match particular */
-	/* request instances with the corresponding response instance. */
-	u64 payload_vm_offset;	/* Offset of payload area from start of this
-				 * instance of ControlVm segment */
-	u32 payload_max_bytes;	/* Maximum bytes allocated in payload
-				 * area of ControlVm segment */
-	u32 payload_bytes;	/* Actual number of bytes of payload
-				 * area to copy between IO/Command; */
-	/* if non-zero, there is a payload to copy. */
-};
-
-struct controlvm_packet_device_create  {
-	u32 bus_no;		/* bus # (0..n-1) from the msg receiver's end */
-	u32 dev_no;		/* bus-relative (0..n-1) device number */
-	u64 channel_addr;	/* Guest physical address of the channel, which
-				 * can be dereferenced by the receiver of this
-				 * ControlVm command */
-	u64 channel_bytes;	/* specifies size of the channel in bytes */
-	uuid_le data_type_uuid;	/* specifies format of data in channel */
-	uuid_le dev_inst_uuid;	/* instance guid for the device */
-	struct irq_info intr;	/* specifies interrupt information */
-};	/* for CONTROLVM_DEVICE_CREATE */
-
-struct controlvm_packet_device_configure  {
-	u32 bus_no;	      /* bus # (0..n-1) from the msg
-			       * receiver's perspective */
-	/* Control uses header SegmentIndex field to access bus number... */
-	u32 dev_no;	      /* bus-relative (0..n-1) device number */
-} ;	/* for CONTROLVM_DEVICE_CONFIGURE */
-
-struct controlvm_message_device_create {
-	struct controlvm_message_header header;
-	struct controlvm_packet_device_create packet;
-};	/* total 128 bytes */
-
-struct controlvm_message_device_configure  {
-	struct controlvm_message_header header;
-	struct controlvm_packet_device_configure packet;
-};	/* total 56 bytes */
-
-/* This is the format for a message in any ControlVm queue. */
-struct controlvm_message_packet  {
-	union  {
-		struct  {
-			u32 bus_no;	/* bus # (0..n-1) from the msg
-					 * receiver's perspective */
-			u32 dev_count;	/* indicates the max number of
-					 * devices on this bus */
-			u64 channel_addr;	/* Guest physical address of
-						 * the channel, which can be
-						 * dereferenced by the receiver
-						 * of this ControlVm command */
-			u64 channel_bytes;	/* size of the channel */
-			uuid_le bus_data_type_uuid;	/* indicates format of
-							 * data in bus channel*/
-			uuid_le bus_inst_uuid;	/* instance uuid for the bus */
-		} create_bus;	/* for CONTROLVM_BUS_CREATE */
-		struct  {
-			u32 bus_no;	/* bus # (0..n-1) from the msg
-					 * receiver's perspective */
-			u32 reserved;	/* Natural alignment purposes */
-		} destroy_bus;	/* for CONTROLVM_BUS_DESTROY */
-		struct  {
-			u32 bus_no;	/* bus # (0..n-1) from the receiver's
-					 * perspective */
-			u32 reserved1;	/* for alignment purposes */
-			u64 guest_handle;	/* This is used to convert
-						 * guest physical address to
-						 * physical address */
-			u64 recv_bus_irq_handle;
-				/* specifies interrupt info. It is used by SP
-				 * to register to receive interrupts from the
-				 * CP. This interrupt is used for bus level
-				 * notifications.  The corresponding
-				 * sendBusInterruptHandle is kept in CP. */
-		} configure_bus;	/* for CONTROLVM_BUS_CONFIGURE */
-		/* for CONTROLVM_DEVICE_CREATE */
-		struct controlvm_packet_device_create create_device;
-		struct  {
-			u32 bus_no;	/* bus # (0..n-1) from the msg
-					 * receiver's perspective */
-			u32 dev_no;	/* bus-relative (0..n-1) device # */
-		} destroy_device;	/* for CONTROLVM_DEVICE_DESTROY */
-		/* for CONTROLVM_DEVICE_CONFIGURE */
-		struct controlvm_packet_device_configure configure_device;
-		struct  {
-			u32 bus_no;	/* bus # (0..n-1) from the msg
-					 * receiver's perspective */
-			u32 dev_no;	/* bus-relative (0..n-1) device # */
-		} reconfigure_device;	/* for CONTROLVM_DEVICE_RECONFIGURE */
-		struct  {
-			u32 bus_no;
-			struct spar_segment_state state;
-			u8 reserved[2];	/* Natural alignment purposes */
-		} bus_change_state;	/* for CONTROLVM_BUS_CHANGESTATE */
-		struct  {
-			u32 bus_no;
-			u32 dev_no;
-			struct spar_segment_state state;
-			struct  {
-				u32 phys_device:1;	/* =1 if message is for
-							 * a physical device */
-			} flags;
-			u8 reserved[2];	/* Natural alignment purposes */
-		} device_change_state;	/* for CONTROLVM_DEVICE_CHANGESTATE */
-		struct  {
-			u32 bus_no;
-			u32 dev_no;
-			struct spar_segment_state state;
-			u8 reserved[6];	/* Natural alignment purposes */
-		} device_change_state_event;
-			/* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
-		struct  {
-			u32 bus_count;	/* indicates the max number of busses */
-			u32 switch_count; /* indicates the max number of
-					   * switches if a service partition */
-			enum ultra_chipset_feature features;
-			u32 platform_number;	/* Platform Number */
-		} init_chipset;	/* for CONTROLVM_CHIPSET_INIT */
-		struct  {
-			u32 options;	/* reserved */
-			u32 test;	/* bit 0 set to run embedded selftest */
-		} chipset_selftest;	/* for CONTROLVM_CHIPSET_SELFTEST */
-		u64 addr;	/* a physical address of something, that can be
-				 * dereferenced by the receiver of this
-				 * ControlVm command (depends on command id) */
-		u64 handle;	/* a handle of something (depends on command
-				 * id) */
-	};
-};
-
-/* All messages in any ControlVm queue have this layout. */
-struct controlvm_message {
-	struct controlvm_message_header hdr;
-	struct controlvm_message_packet cmd;
-};
-
-struct spar_controlvm_channel_protocol {
-	struct channel_header header;
-	u64 gp_controlvm;	/* guest phys addr of this channel */
-	u64 gp_partition_tables;/* guest phys addr of partition tables */
-	u64 gp_diag_guest;	/* guest phys addr of diagnostic channel */
-	u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */
-	u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */
-	u64 gp_acpi_table;	/* guest phys addr of acpi table */
-	u64 gp_control_channel;/* guest phys addr of control channel */
-	u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */
-	u64 gp_nvram;	/* guest phys addr of NVRAM channel */
-	u64 request_payload_offset;	/* Offset to request payload area */
-	u64 event_payload_offset;	/* Offset to event payload area */
-	u32 request_payload_bytes;	/* Bytes available in request payload
-					 * area */
-	u32 event_payload_bytes;/* Bytes available in event payload area */
-	u32 control_channel_bytes;
-	u32 nvram_channel_bytes;	/* Bytes in PartitionNvram segment */
-	u32 message_bytes;		/* sizeof(CONTROLVM_MESSAGE) */
-	u32 message_count;		/* CONTROLVM_MESSAGE_MAX */
-	u64 gp_smbios_table;		/* guest phys addr of SMBIOS tables */
-	u64 gp_physical_smbios_table;	/* guest phys addr of SMBIOS table  */
-	/* ULTRA_MAX_GUESTS_PER_SERVICE */
-	char gp_reserved[2688];
-
-	/* guest physical address of EFI firmware image base  */
-	u64 virtual_guest_firmware_image_base;
-
-	/* guest physical address of EFI firmware entry point  */
-	u64 virtual_guest_firmware_entry_point;
-
-	/* guest EFI firmware image size  */
-	u64 virtual_guest_firmware_image_size;
-
-	/* GPA = 1MB where EFI firmware image is copied to  */
-	u64 virtual_guest_firmware_boot_base;
-	u64 virtual_guest_image_base;
-	u64 virtual_guest_image_size;
-	u64 prototype_control_channel_offset;
-	u64 virtual_guest_partition_handle;
-
-	u16 restore_action;	/* Restore Action field to restore the guest
-				 * partition */
-	u16 dump_action;	/* For Windows guests it shows if the visordisk
-				 * is running in dump mode */
-	u16 nvram_fail_count;
-	u16 saved_crash_message_count;	/* = CONTROLVM_CRASHMSG_MAX */
-	u32 saved_crash_message_offset;	/* Offset to request payload area needed
-					 * for crash dump */
-	u32 installation_error;	/* Type of error encountered during
-				 * installation */
-	u32 installation_text_id;	/* Id of string to display */
-	u16 installation_remaining_steps;/* Number of remaining installation
-					  * steps (for progress bars) */
-	u8 tool_action;		/* ULTRA_TOOL_ACTIONS Installation Action
-				 * field */
-	u8 reserved;		/* alignment */
-	struct efi_spar_indication efi_spar_ind;
-	struct efi_spar_indication efi_spar_ind_supported;
-	u32 sp_reserved;
-	u8 reserved2[28];	/* Force signals to begin on 128-byte cache
-				 * line */
-	struct signal_queue_header request_queue;/* Service or guest partition
-						  * uses this queue to send
-						  * requests to Control */
-	struct signal_queue_header response_queue;/* Control uses this queue to
-						   * respond to service or guest
-						   * partition requests */
-	struct signal_queue_header event_queue;	/* Control uses this queue to
-						 * send events to service or
-						 * guest partition */
-	struct signal_queue_header event_ack_queue;/* Service or guest partition
-						    * uses this queue to ack
-						    * Control events */
-
-	 /* Request fixed-size message pool - does not include payload */
-	 struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
-
-	 /* Response fixed-size message pool - does not include payload */
-	 struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
-
-	 /* Event fixed-size message pool - does not include payload */
-	 struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
-
-	 /* Ack fixed-size message pool - does not include payload */
-	 struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
-
-	 /* Message stored during IOVM creation to be reused after crash */
-	 struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
-};
-
-/* Offsets for VM channel attributes */
-#define VM_CH_REQ_QUEUE_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, request_queue)
-#define VM_CH_RESP_QUEUE_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, response_queue)
-#define VM_CH_EVENT_QUEUE_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, event_queue)
-#define VM_CH_ACK_QUEUE_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
-#define VM_CH_REQ_MSG_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, request_msg)
-#define VM_CH_RESP_MSG_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, response_msg)
-#define VM_CH_EVENT_MSG_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, event_msg)
-#define VM_CH_ACK_MSG_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
-#define VM_CH_CRASH_MSG_OFFSET \
-	offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
-
-/* The following header will be located at the beginning of PayloadVmOffset for
- * various ControlVm commands. The receiver of a ControlVm command with a
- * PayloadVmOffset will dereference this address and then use connection_offset,
- * initiator_offset, and target_offset to get the location of UTF-8 formatted
- * strings that can be parsed to obtain command-specific information. The value
- * of total_length should equal PayloadBytes. The format of the strings at
- * PayloadVmOffset will take different forms depending on the message.
- */
-struct spar_controlvm_parameters_header {
-	u32 total_length;
-	u32 header_length;
-	u32 connection_offset;
-	u32 connection_length;
-	u32 initiator_offset;
-	u32 initiator_length;
-	u32 target_offset;
-	u32 target_length;
-	u32 client_offset;
-	u32 client_length;
-	u32 name_offset;
-	u32 name_length;
-	uuid_le id;
-	u32 revision;
-	u32 reserved;		/* Natural alignment */
-};
-
-#endif				/* __CONTROLVMCHANNEL_H__ */
diff --git a/drivers/staging/unisys/include/channel.h b/drivers/staging/unisys/include/channel.h
new file mode 100644
index 0000000..da0b538
--- /dev/null
+++ b/drivers/staging/unisys/include/channel.h
@@ -0,0 +1,555 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __CHANNEL_H__
+#define __CHANNEL_H__
+
+#include <linux/types.h>
+#include <linux/io.h>
+#include <linux/uuid.h>
+
+/*
+* Whenever this file is changed a corresponding change must be made in
+* the Console/ServicePart/visordiag_early/supervisor_channel.h file
+* which is needed for Linux kernel compiles. These two files must be
+* in sync.
+*/
+
+/* define the following to prevent include nesting in kernel header
+ * files of similar abbreviated content
+ */
+#define __SUPERVISOR_CHANNEL_H__
+
+#define SIGNATURE_16(A, B) ((A) | (B<<8))
+#define SIGNATURE_32(A, B, C, D) \
+	(SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
+#define SIGNATURE_64(A, B, C, D, E, F, G, H) \
+	(SIGNATURE_32(A, B, C, D) | ((u64)(SIGNATURE_32(E, F, G, H)) << 32))
+
+#ifndef lengthof
+#define lengthof(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
+#endif
+#ifndef COVERQ
+#define COVERQ(v, d)  (((v)+(d)-1) / (d))
+#endif
+#ifndef COVER
+#define COVER(v, d)   ((d)*COVERQ(v, d))
+#endif
+
+#define ULTRA_CHANNEL_PROTOCOL_SIGNATURE  SIGNATURE_32('E', 'C', 'N', 'L')
+
+enum channel_serverstate {
+	CHANNELSRV_UNINITIALIZED = 0,	/* channel is in an undefined state */
+	CHANNELSRV_READY = 1	/* channel has been initialized by server */
+};
+
+enum channel_clientstate {
+	CHANNELCLI_DETACHED = 0,
+	CHANNELCLI_DISABLED = 1,	/* client can see channel but is NOT
+					 * allowed to use it unless given TBD
+					 * explicit request (should actually be
+					 * < DETACHED) */
+	CHANNELCLI_ATTACHING = 2,	/* legacy EFI client request
+					 * for EFI server to attach */
+	CHANNELCLI_ATTACHED = 3,	/* idle, but client may want
+					 * to use channel any time */
+	CHANNELCLI_BUSY = 4,	/* client either wants to use or is
+				 * using channel */
+	CHANNELCLI_OWNED = 5	/* "no worries" state - client can
+				 * access channel anytime */
+};
+
+static inline const u8 *
+ULTRA_CHANNELCLI_STRING(u32 v)
+{
+	switch (v) {
+	case CHANNELCLI_DETACHED:
+		return (const u8 *)("DETACHED");
+	case CHANNELCLI_DISABLED:
+		return (const u8 *)("DISABLED");
+	case CHANNELCLI_ATTACHING:
+		return (const u8 *)("ATTACHING");
+	case CHANNELCLI_ATTACHED:
+		return (const u8 *)("ATTACHED");
+	case CHANNELCLI_BUSY:
+		return (const u8 *)("BUSY");
+	case CHANNELCLI_OWNED:
+		return (const u8 *)("OWNED");
+	default:
+		break;
+	}
+	return (const u8 *)("?");
+}
+
+#define SPAR_CHANNEL_SERVER_READY(ch) \
+	(readl(&(ch)->srv_state) == CHANNELSRV_READY)
+
+#define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n)				\
+	(((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \
+	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DISABLED)) || \
+	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DISABLED)) || \
+	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DETACHED)) || \
+	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DETACHED)) || \
+	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHING)) || \
+	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_ATTACHED)) || \
+	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHED)) || \
+	  (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_ATTACHED)) ||	\
+	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_BUSY)) ||	\
+	  (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_OWNED)) || \
+	  (((o) == CHANNELCLI_DISABLED) && ((n) == CHANNELCLI_OWNED)) || \
+	  (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_OWNED)) || \
+	  (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_OWNED)) || \
+	  (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \
+	 ? (1) : (0))
+
+/* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */
+/* throttling invalid boot channel statetransition error due to client
+ * disabled */
+#define ULTRA_CLIERRORBOOT_THROTTLEMSG_DISABLED    0x01
+
+/* throttling invalid boot channel statetransition error due to client
+ * not attached */
+#define ULTRA_CLIERRORBOOT_THROTTLEMSG_NOTATTACHED 0x02
+
+/* throttling invalid boot channel statetransition error due to busy channel */
+#define ULTRA_CLIERRORBOOT_THROTTLEMSG_BUSY        0x04
+
+/* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorOS: */
+/* throttling invalid guest OS channel statetransition error due to
+ * client disabled */
+#define ULTRA_CLIERROROS_THROTTLEMSG_DISABLED      0x01
+
+/* throttling invalid guest OS channel statetransition error due to
+ * client not attached */
+#define ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED   0x02
+
+/* throttling invalid guest OS channel statetransition error due to
+ * busy channel */
+#define ULTRA_CLIERROROS_THROTTLEMSG_BUSY          0x04
+
+/* Values for ULTRA_CHANNEL_PROTOCOL.Features: This define exists so
+* that windows guest can look at the FeatureFlags in the io channel,
+* and configure the windows driver to use interrupts or not based on
+* this setting.  This flag is set in uislib after the
+* ULTRA_VHBA_init_channel is called.  All feature bits for all
+* channels should be defined here.  The io channel feature bits are
+* defined right here */
+#define ULTRA_IO_DRIVER_ENABLES_INTS (0x1ULL << 1)
+#define ULTRA_IO_CHANNEL_IS_POLLING (0x1ULL << 3)
+#define ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS (0x1ULL << 4)
+#define ULTRA_IO_DRIVER_DISABLES_INTS (0x1ULL << 5)
+#define ULTRA_IO_DRIVER_SUPPORTS_ENHANCED_RCVBUF_CHECKING (0x1ULL << 6)
+
+#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
+/* Common Channel Header */
+struct channel_header {
+	u64 signature;		/* Signature */
+	u32 legacy_state;	/* DEPRECATED - being replaced by */
+	/* /              SrvState, CliStateBoot, and CliStateOS below */
+	u32 header_size;	/* sizeof(struct channel_header) */
+	u64 size;		/* Total size of this channel in bytes */
+	u64 features;		/* Flags to modify behavior */
+	uuid_le chtype;		/* Channel type: data, bus, control, etc. */
+	u64 partition_handle;	/* ID of guest partition */
+	u64 handle;		/* Device number of this channel in client */
+	u64 ch_space_offset;	/* Offset in bytes to channel specific area */
+	u32 version_id;		/* struct channel_header Version ID */
+	u32 partition_index;	/* Index of guest partition */
+	uuid_le zone_uuid;	/* Guid of Channel's zone */
+	u32 cli_str_offset;	/* offset from channel header to
+				 * nul-terminated ClientString (0 if
+				 * ClientString not present) */
+	u32 cli_state_boot;	/* CHANNEL_CLIENTSTATE of pre-boot
+				 * EFI client of this channel */
+	u32 cmd_state_cli;	/* CHANNEL_COMMANDSTATE (overloaded in
+				 * Windows drivers, see ServerStateUp,
+				 * ServerStateDown, etc) */
+	u32 cli_state_os;	/* CHANNEL_CLIENTSTATE of Guest OS
+				 * client of this channel */
+	u32 ch_characteristic;	/* CHANNEL_CHARACTERISTIC_<xxx> */
+	u32 cmd_state_srv;	/* CHANNEL_COMMANDSTATE (overloaded in
+				 * Windows drivers, see ServerStateUp,
+				 * ServerStateDown, etc) */
+	u32 srv_state;		/* CHANNEL_SERVERSTATE */
+	u8 cli_error_boot;	/* bits to indicate err states for
+				 * boot clients, so err messages can
+				 * be throttled */
+	u8 cli_error_os;	/* bits to indicate err states for OS
+				 * clients, so err messages can be
+				 * throttled */
+	u8 filler[1];		/* Pad out to 128 byte cacheline */
+	/* Please add all new single-byte values below here */
+	u8 recover_channel;
+};
+
+#define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0)
+
+/* Subheader for the Signal Type variation of the Common Channel */
+struct signal_queue_header {
+	/* 1st cache line */
+	u32 version;		/* SIGNAL_QUEUE_HEADER Version ID */
+	u32 chtype;		/* Queue type: storage, network */
+	u64 size;		/* Total size of this queue in bytes */
+	u64 sig_base_offset;	/* Offset to signal queue area */
+	u64 features;		/* Flags to modify behavior */
+	u64 num_sent;		/* Total # of signals placed in this queue */
+	u64 num_overflows;	/* Total # of inserts failed due to
+				 * full queue */
+	u32 signal_size;	/* Total size of a signal for this queue */
+	u32 max_slots;		/* Max # of slots in queue, 1 slot is
+				 * always empty */
+	u32 max_signals;	/* Max # of signals in queue
+				 * (MaxSignalSlots-1) */
+	u32 head;		/* Queue head signal # */
+	/* 2nd cache line */
+	u64 num_received;	/* Total # of signals removed from this queue */
+	u32 tail;		/* Queue tail signal # (on separate
+				 * cache line) */
+	u32 reserved1;		/* Reserved field */
+	u64 reserved2;		/* Reserved field */
+	u64 client_queue;
+	u64 num_irq_received;	/* Total # of Interrupts received.  This
+					 * is incremented by the ISR in the
+					 * guest windows driver */
+	u64 num_empty;		/* Number of times that visor_signal_remove
+				 * is called and returned Empty
+				 * Status. */
+	u32 errorflags;		/* Error bits set during SignalReinit
+				 * to denote trouble with client's
+				 * fields */
+	u8 filler[12];		/* Pad out to 64 byte cacheline */
+};
+
+#pragma pack(pop)
+
+#define spar_signal_init(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ)	\
+	do {								\
+		memset(&chan->QHDRFLD, 0, sizeof(chan->QHDRFLD));	\
+		chan->QHDRFLD.version = ver;				\
+		chan->QHDRFLD.chtype = typ;				\
+		chan->QHDRFLD.size = sizeof(chan->QDATAFLD);		\
+		chan->QHDRFLD.signal_size = sizeof(QDATATYPE);		\
+		chan->QHDRFLD.sig_base_offset = (u64)(chan->QDATAFLD)-	\
+			(u64)(&chan->QHDRFLD);				\
+		chan->QHDRFLD.max_slots =				\
+			sizeof(chan->QDATAFLD)/sizeof(QDATATYPE);	\
+		chan->QHDRFLD.max_signals = chan->QHDRFLD.max_slots-1;	\
+	} while (0)
+
+/* Generic function useful for validating any type of channel when it is
+ * received by the client that will be accessing the channel.
+ * Note that <logCtx> is only needed for callers in the EFI environment, and
+ * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
+ */
+static inline int
+spar_check_channel_client(void __iomem *ch,
+			  uuid_le expected_uuid,
+			  char *chname,
+			  u64 expected_min_bytes,
+			  u32 expected_version,
+			  u64 expected_signature)
+{
+	if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
+		uuid_le guid;
+
+		memcpy_fromio(&guid,
+			      &((struct channel_header __iomem *)(ch))->chtype,
+			      sizeof(guid));
+		/* caller wants us to verify type GUID */
+		if (uuid_le_cmp(guid, expected_uuid) != 0) {
+			pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
+			       chname, &expected_uuid,
+			       &expected_uuid, &guid);
+			return 0;
+		}
+	}
+	if (expected_min_bytes > 0) {	/* caller wants us to verify
+					 * channel size */
+		unsigned long long bytes =
+				readq(&((struct channel_header __iomem *)
+					(ch))->size);
+		if (bytes < expected_min_bytes) {
+			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
+			       chname, &expected_uuid,
+			       (unsigned long long)expected_min_bytes, bytes);
+			return 0;
+		}
+	}
+	if (expected_version > 0) {	/* caller wants us to verify
+					 * channel version */
+		unsigned long ver = readl(&((struct channel_header __iomem *)
+				    (ch))->version_id);
+		if (ver != expected_version) {
+			pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
+			       chname, &expected_uuid,
+			       (unsigned long)expected_version, ver);
+			return 0;
+		}
+	}
+	if (expected_signature > 0) {	/* caller wants us to verify
+					 * channel signature */
+		unsigned long long sig =
+				readq(&((struct channel_header __iomem *)
+					(ch))->signature);
+		if (sig != expected_signature) {
+			pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
+			       chname, &expected_uuid,
+			       expected_signature, sig);
+			return 0;
+		}
+	}
+	return 1;
+}
+
+/* Generic function useful for validating any type of channel when it is about
+ * to be initialized by the server of the channel.
+ * Note that <logCtx> is only needed for callers in the EFI environment, and
+ * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
+ */
+static inline int spar_check_channel_server(uuid_le typeuuid, char *name,
+					    u64 expected_min_bytes,
+					    u64 actual_bytes)
+{
+	if (expected_min_bytes > 0)	/* caller wants us to verify
+					 * channel size */
+		if (actual_bytes < expected_min_bytes) {
+			pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
+			       name, &typeuuid, expected_min_bytes,
+			       actual_bytes);
+			return 0;
+		}
+	return 1;
+}
+
+/* Given a file pathname <s> (with '/' or '\' separating directory nodes),
+ * returns a pointer to the beginning of a node within that pathname such
+ * that the number of nodes from that pointer to the end of the string is
+ * NOT more than <n>.  Note that if the pathname has less than <n> nodes
+ * in it, the return pointer will be to the beginning of the string.
+ */
+static inline u8 *
+pathname_last_n_nodes(u8 *s, unsigned int n)
+{
+	u8 *p = s;
+	unsigned int node_count = 0;
+
+	while (*p != '\0') {
+		if ((*p == '/') || (*p == '\\'))
+			node_count++;
+		p++;
+	}
+	if (node_count <= n)
+		return s;
+	while (n > 0) {
+		p--;
+		if (p == s)
+			break;	/* should never happen, unless someone
+				 * is changing the string while we are
+				 * looking at it!! */
+		if ((*p == '/') || (*p == '\\'))
+			n--;
+	}
+	return p + 1;
+}
+
+static inline int
+spar_channel_client_acquire_os(void __iomem *ch, u8 *id)
+{
+	struct channel_header __iomem *hdr = ch;
+
+	if (readl(&hdr->cli_state_os) == CHANNELCLI_DISABLED) {
+		if ((readb(&hdr->cli_error_os)
+		     & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED) == 0) {
+			/* we are NOT throttling this message */
+			writeb(readb(&hdr->cli_error_os) |
+			       ULTRA_CLIERROROS_THROTTLEMSG_DISABLED,
+			       &hdr->cli_error_os);
+			/* throttle until acquire successful */
+
+			pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED\n",
+				id);
+		}
+		return 0;
+	}
+	if ((readl(&hdr->cli_state_os) != CHANNELCLI_OWNED) &&
+	    (readl(&hdr->cli_state_boot) == CHANNELCLI_DISABLED)) {
+		/* Our competitor is DISABLED, so we can transition to OWNED */
+		pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d)\n",
+			id, "cli_state_os",
+			ULTRA_CHANNELCLI_STRING(readl(&hdr->cli_state_os)),
+			readl(&hdr->cli_state_os),
+			ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED),
+			CHANNELCLI_OWNED);
+		writel(CHANNELCLI_OWNED, &hdr->cli_state_os);
+		mb(); /* required for channel synch */
+	}
+	if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED) {
+		if (readb(&hdr->cli_error_os) != 0) {
+			/* we are in an error msg throttling state;
+			 * come out of it */
+			pr_info("%s Channel OS client acquire now successful\n",
+				id);
+			writeb(0, &hdr->cli_error_os);
+		}
+		return 1;
+	}
+
+	/* We have to do it the "hard way".  We transition to BUSY,
+	* and can use the channel iff our competitor has not also
+	* transitioned to BUSY. */
+	if (readl(&hdr->cli_state_os) != CHANNELCLI_ATTACHED) {
+		if ((readb(&hdr->cli_error_os)
+		     & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED) == 0) {
+			/* we are NOT throttling this message */
+			writeb(readb(&hdr->cli_error_os) |
+			       ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED,
+			       &hdr->cli_error_os);
+			/* throttle until acquire successful */
+			pr_info("%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d))\n",
+				id, ULTRA_CHANNELCLI_STRING(
+						readl(&hdr->cli_state_os)),
+				readl(&hdr->cli_state_os));
+		}
+		return 0;
+	}
+	writel(CHANNELCLI_BUSY, &hdr->cli_state_os);
+	mb(); /* required for channel synch */
+	if (readl(&hdr->cli_state_boot) == CHANNELCLI_BUSY) {
+		if ((readb(&hdr->cli_error_os)
+		     & ULTRA_CLIERROROS_THROTTLEMSG_BUSY) == 0) {
+			/* we are NOT throttling this message */
+			writeb(readb(&hdr->cli_error_os) |
+			       ULTRA_CLIERROROS_THROTTLEMSG_BUSY,
+			       &hdr->cli_error_os);
+			/* throttle until acquire successful */
+			pr_info("%s Channel StateTransition failed - host OS acquire failed because boot BUSY\n",
+				id);
+		}
+		/* reset busy */
+		writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os);
+		mb(); /* required for channel synch */
+		return 0;
+	}
+	if (readb(&hdr->cli_error_os) != 0) {
+		/* we are in an error msg throttling state; come out of it */
+		pr_info("%s Channel OS client acquire now successful\n", id);
+		writeb(0, &hdr->cli_error_os);
+	}
+	return 1;
+}
+
+static inline void
+spar_channel_client_release_os(void __iomem *ch, u8 *id)
+{
+	struct channel_header __iomem *hdr = ch;
+
+	if (readb(&hdr->cli_error_os) != 0) {
+		/* we are in an error msg throttling state; come out of it */
+		pr_info("%s Channel OS client error state cleared\n", id);
+		writeb(0, &hdr->cli_error_os);
+	}
+	if (readl(&hdr->cli_state_os) == CHANNELCLI_OWNED)
+		return;
+	if (readl(&hdr->cli_state_os) != CHANNELCLI_BUSY) {
+		pr_info("%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d))\n",
+			id, ULTRA_CHANNELCLI_STRING(
+					readl(&hdr->cli_state_os)),
+			readl(&hdr->cli_state_os));
+		/* return; */
+	}
+	writel(CHANNELCLI_ATTACHED, &hdr->cli_state_os); /* release busy */
+}
+
+/*
+* Routine Description:
+* Tries to insert the prebuilt signal pointed to by pSignal into the nth
+* Queue of the Channel pointed to by pChannel
+*
+* Parameters:
+* pChannel: (IN) points to the IO Channel
+* Queue: (IN) nth Queue of the IO Channel
+* pSignal: (IN) pointer to the signal
+*
+* Assumptions:
+* - pChannel, Queue and pSignal are valid.
+* - If insertion fails due to a full queue, the caller will determine the
+* retry policy (e.g. wait & try again, report an error, etc.).
+*
+* Return value: 1 if the insertion succeeds, 0 if the queue was
+* full.
+*/
+
+unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
+				 void *sig);
+
+/*
+* Routine Description:
+* Removes one signal from Channel pChannel's nth Queue at the
+* time of the call and copies it into the memory pointed to by
+* pSignal.
+*
+* Parameters:
+* pChannel: (IN) points to the IO Channel
+* Queue: (IN) nth Queue of the IO Channel
+* pSignal: (IN) pointer to where the signals are to be copied
+*
+* Assumptions:
+* - pChannel and Queue are valid.
+* - pSignal points to a memory area large enough to hold queue's SignalSize
+*
+* Return value: 1 if the removal succeeds, 0 if the queue was
+* empty.
+*/
+
+unsigned char spar_signal_remove(struct channel_header __iomem *ch, u32 queue,
+				 void *sig);
+
+/*
+* Routine Description:
+* Removes all signals present in Channel pChannel's nth Queue at the
+* time of the call and copies them into the memory pointed to by
+* pSignal.  Returns the # of signals copied as the value of the routine.
+*
+* Parameters:
+* pChannel: (IN) points to the IO Channel
+* Queue: (IN) nth Queue of the IO Channel
+* pSignal: (IN) pointer to where the signals are to be copied
+*
+* Assumptions:
+* - pChannel and Queue are valid.
+* - pSignal points to a memory area large enough to hold Queue's MaxSignals
+* # of signals, each of which is Queue's SignalSize.
+*
+* Return value:
+* # of signals copied.
+*/
+unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue,
+				    void *sig);
+
+/*
+* Routine Description:
+* Determine whether a signal queue is empty.
+*
+* Parameters:
+* pChannel: (IN) points to the IO Channel
+* Queue: (IN) nth Queue of the IO Channel
+*
+* Return value:
+* 1 if the signal queue is empty, 0 otherwise.
+*/
+unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch,
+				     u32 queue);
+
+#endif
diff --git a/drivers/staging/unisys/include/channel_guid.h b/drivers/staging/unisys/include/channel_guid.h
new file mode 100644
index 0000000..706363fc
--- /dev/null
+++ b/drivers/staging/unisys/include/channel_guid.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * CHANNEL Guids
+ */
+
+/* Used in IOChannel
+ * {414815ed-c58c-11da-95a9-00e08161165f}
+ */
+#define SPAR_VHBA_CHANNEL_PROTOCOL_UUID \
+		UUID_LE(0x414815ed, 0xc58c, 0x11da, \
+				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
+static const uuid_le spar_vhba_channel_protocol_uuid =
+	SPAR_VHBA_CHANNEL_PROTOCOL_UUID;
+
+/* Used in IOChannel
+ * {8cd5994d-c58e-11da-95a9-00e08161165f}
+ */
+#define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \
+		UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \
+				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
+static const uuid_le spar_vnic_channel_protocol_uuid =
+	SPAR_VNIC_CHANNEL_PROTOCOL_UUID;
+
+/* Used in IOChannel
+ * {72120008-4AAB-11DC-8530-444553544200}
+ */
+#define SPAR_SIOVM_UUID \
+		UUID_LE(0x72120008, 0x4AAB, 0x11DC, \
+				0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00)
+static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID;
+
+/* Used in visornoop/visornoop_main.c
+ * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f}
+ */
+#define SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID  \
+		UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \
+				0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f)
+
+static const uuid_le spar_controldirector_channel_protocol_uuid =
+	SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID;
+
+/* Used in visorchipset/visorchipset_main.c
+ * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C}
+ */
+#define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID				\
+		UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \
+				0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c)
diff --git a/drivers/staging/unisys/visorbus/controlvmchannel.h b/drivers/staging/unisys/visorbus/controlvmchannel.h
new file mode 100644
index 0000000..a50d9cf
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/controlvmchannel.h
@@ -0,0 +1,485 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __CONTROLVMCHANNEL_H__
+#define __CONTROLVMCHANNEL_H__
+
+#include <linux/uuid.h>
+#include "channel.h"
+
+/* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
+#define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID	\
+		UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
+			0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
+
+#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
+	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+#define CONTROLVM_MESSAGE_MAX 64
+
+/* Must increment this whenever you insert or delete fields within
+ * this channel struct.  Also increment whenever you change the meaning
+ * of fields within this channel struct so as to break pre-existing
+ * software.  Note that you can usually add fields to the END of the
+ * channel struct withOUT needing to increment this.
+ */
+#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
+
+#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
+	spar_check_channel_client(ch, \
+		SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
+		"controlvm", \
+		sizeof(struct spar_controlvm_channel_protocol), \
+		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
+		ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
+
+#define MAX_SERIAL_NUM	32
+
+/* Defines for various channel queues */
+#define CONTROLVM_QUEUE_REQUEST		0
+#define CONTROLVM_QUEUE_RESPONSE	1
+#define CONTROLVM_QUEUE_EVENT		2
+#define CONTROLVM_QUEUE_ACK		3
+
+/* Max num of messages stored during IOVM creation to be reused after crash */
+#define CONTROLVM_CRASHMSG_MAX		2
+
+struct spar_segment_state  {
+	u16 enabled:1;		/* Bit 0: May enter other states */
+	u16 active:1;		/* Bit 1: Assigned to active partition */
+	u16 alive:1;		/* Bit 2: Configure message sent to
+				 * service/server */
+	u16 revoked:1;		/* Bit 3: similar to partition state
+				 * ShuttingDown */
+	u16 allocated:1;	/* Bit 4: memory (device/port number)
+				 * has been selected by Command */
+	u16 known:1;		/* Bit 5: has been introduced to the
+				 * service/guest partition */
+	u16 ready:1;		/* Bit 6: service/Guest partition has
+				 * responded to introduction */
+	u16 operating:1;	/* Bit 7: resource is configured and
+				 * operating */
+	/* Note: don't use high bit unless we need to switch to ushort
+	 * which is non-compliant */
+};
+
+static const struct spar_segment_state segment_state_running = {
+	1, 1, 1, 0, 1, 1, 1, 1
+};
+
+static const struct spar_segment_state segment_state_paused = {
+	1, 1, 1, 0, 1, 1, 1, 0
+};
+
+static const struct spar_segment_state segment_state_standby = {
+	1, 1, 0, 0, 1, 1, 1, 0
+};
+
+/* Ids for commands that may appear in either queue of a ControlVm channel.
+ *
+ *  Commands that are initiated by the command partition (CP), by an IO or
+ *  console service partition (SP), or by a guest partition (GP)are:
+ *  - issued on the RequestQueue queue (q #0) in the ControlVm channel
+ *  - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
+ *
+ *  Events that are initiated by an IO or console service partition (SP) or
+ *  by a guest partition (GP) are:
+ *  - issued on the EventQueue queue (q #2) in the ControlVm channel
+ *  - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
+ */
+enum controlvm_id {
+	CONTROLVM_INVALID = 0,
+	/* SWITCH commands required Parameter: SwitchNumber */
+	/* BUS commands required Parameter: BusNumber */
+	CONTROLVM_BUS_CREATE = 0x101,			/* CP --> SP, GP */
+	CONTROLVM_BUS_DESTROY = 0x102,			/* CP --> SP, GP */
+	CONTROLVM_BUS_CONFIGURE = 0x104,		/* CP --> SP */
+	CONTROLVM_BUS_CHANGESTATE = 0x105,		/* CP --> SP, GP */
+	CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106,	/* SP, GP --> CP */
+/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
+
+	CONTROLVM_DEVICE_CREATE = 0x201,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_DESTROY = 0x202,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_CONFIGURE = 0x203,		/* CP --> SP */
+	CONTROLVM_DEVICE_CHANGESTATE = 0x204,		/* CP --> SP, GP */
+	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205,	/* SP, GP --> CP */
+	CONTROLVM_DEVICE_RECONFIGURE = 0x206,		/* CP --> Boot */
+/* CHIPSET commands */
+	CONTROLVM_CHIPSET_INIT = 0x301,			/* CP --> SP, GP */
+	CONTROLVM_CHIPSET_STOP = 0x302,			/* CP --> SP, GP */
+	CONTROLVM_CHIPSET_READY = 0x304,		/* CP --> SP */
+	CONTROLVM_CHIPSET_SELFTEST = 0x305,		/* CP --> SP */
+
+};
+
+struct irq_info {
+	u64 reserved1;
+
+	 /* specifies interrupt handle. It is used to retrieve the
+	  *   corresponding interrupt pin from Monitor; and the
+	  *   interrupt pin is used to connect to the corresponding
+	  *   interrupt.  Used by IOPart-GP only.
+	  */
+	u64 recv_irq_handle;
+
+	 /* specifies interrupt vector. It, interrupt pin, and shared are
+	  *   used to connect to the corresponding interrupt.  Used by
+	  *   IOPart-GP only.
+	  */
+	u32 recv_irq_vector;
+
+    /* specifies if the recvInterrupt is shared.  It, interrupt pin
+     * and vector are used to connect to 0 = not shared; 1 = shared.
+     * the corresponding interrupt.  Used by IOPart-GP only.
+     */
+	u8 recv_irq_shared;
+	u8 reserved[3];	/* Natural alignment purposes */
+};
+
+struct pci_id {
+	u16 domain;
+	u8 bus;
+	u8 slot;
+	u8 func;
+	u8 reserved[3];	/* Natural alignment purposes */
+};
+
+struct efi_spar_indication  {
+	u64 boot_to_fw_ui:1;		/* Bit 0: Stop in uefi ui */
+	u64 clear_nvram:1;		/* Bit 1: Clear NVRAM */
+	u64 clear_cmos:1;		/* Bit 2: Clear CMOS */
+	u64 boot_to_tool:1;		/* Bit 3: Run install tool */
+	/* remaining bits are available */
+};
+
+enum ultra_chipset_feature {
+	ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
+	ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
+};
+
+/* This is the common structure that is at the beginning of every
+ *  ControlVm message (both commands and responses) in any ControlVm
+ *  queue.  Commands are easily distinguished from responses by
+ *  looking at the flags.response field.
+ */
+struct controlvm_message_header  {
+	u32 id;		/* See CONTROLVM_ID. */
+	/* For requests, indicates the message type. */
+	/* For responses, indicates the type of message we are responding to. */
+
+	u32 message_size;	/* Includes size of this struct + size
+				 * of message */
+	u32 segment_index;	/* Index of segment containing Vm
+				 * message/information */
+	u32 completion_status;	/* Error status code or result of
+				 * message completion */
+	struct  {
+		u32 failed:1;		   /* =1 in a response to * signify
+					    * failure */
+		u32 response_expected:1;   /* =1 in all messages that expect a
+					    * response (Control ignores this
+					    * bit) */
+		u32 server:1;		   /* =1 in all bus & device-related
+					    * messages where the message
+					    * receiver is to act as the bus or
+					    * device server */
+		u32 test_message:1;	   /* =1 for testing use only
+					    * (Control and Command ignore this
+					    * bit) */
+		u32 partial_completion:1;  /* =1 if there are forthcoming
+					    * responses/acks associated
+					    * with this message */
+		u32 preserve:1;		   /* =1 this is to let us know to
+					    * preserve channel contents
+					    * (for running guests)*/
+		u32 writer_in_diag:1;	   /* =1 the DiagWriter is active in the
+					    * Diagnostic Partition*/
+	} flags;
+	u32 reserved;		/* Natural alignment */
+	u64 message_handle;	/* Identifies the particular message instance,
+				 * and is used to match particular */
+	/* request instances with the corresponding response instance. */
+	u64 payload_vm_offset;	/* Offset of payload area from start of this
+				 * instance of ControlVm segment */
+	u32 payload_max_bytes;	/* Maximum bytes allocated in payload
+				 * area of ControlVm segment */
+	u32 payload_bytes;	/* Actual number of bytes of payload
+				 * area to copy between IO/Command; */
+	/* if non-zero, there is a payload to copy. */
+};
+
+struct controlvm_packet_device_create  {
+	u32 bus_no;		/* bus # (0..n-1) from the msg receiver's end */
+	u32 dev_no;		/* bus-relative (0..n-1) device number */
+	u64 channel_addr;	/* Guest physical address of the channel, which
+				 * can be dereferenced by the receiver of this
+				 * ControlVm command */
+	u64 channel_bytes;	/* specifies size of the channel in bytes */
+	uuid_le data_type_uuid;	/* specifies format of data in channel */
+	uuid_le dev_inst_uuid;	/* instance guid for the device */
+	struct irq_info intr;	/* specifies interrupt information */
+};	/* for CONTROLVM_DEVICE_CREATE */
+
+struct controlvm_packet_device_configure  {
+	u32 bus_no;	      /* bus # (0..n-1) from the msg
+			       * receiver's perspective */
+	/* Control uses header SegmentIndex field to access bus number... */
+	u32 dev_no;	      /* bus-relative (0..n-1) device number */
+} ;	/* for CONTROLVM_DEVICE_CONFIGURE */
+
+struct controlvm_message_device_create {
+	struct controlvm_message_header header;
+	struct controlvm_packet_device_create packet;
+};	/* total 128 bytes */
+
+struct controlvm_message_device_configure  {
+	struct controlvm_message_header header;
+	struct controlvm_packet_device_configure packet;
+};	/* total 56 bytes */
+
+/* This is the format for a message in any ControlVm queue. */
+struct controlvm_message_packet  {
+	union  {
+		struct  {
+			u32 bus_no;	/* bus # (0..n-1) from the msg
+					 * receiver's perspective */
+			u32 dev_count;	/* indicates the max number of
+					 * devices on this bus */
+			u64 channel_addr;	/* Guest physical address of
+						 * the channel, which can be
+						 * dereferenced by the receiver
+						 * of this ControlVm command */
+			u64 channel_bytes;	/* size of the channel */
+			uuid_le bus_data_type_uuid;	/* indicates format of
+							 * data in bus channel*/
+			uuid_le bus_inst_uuid;	/* instance uuid for the bus */
+		} create_bus;	/* for CONTROLVM_BUS_CREATE */
+		struct  {
+			u32 bus_no;	/* bus # (0..n-1) from the msg
+					 * receiver's perspective */
+			u32 reserved;	/* Natural alignment purposes */
+		} destroy_bus;	/* for CONTROLVM_BUS_DESTROY */
+		struct  {
+			u32 bus_no;	/* bus # (0..n-1) from the receiver's
+					 * perspective */
+			u32 reserved1;	/* for alignment purposes */
+			u64 guest_handle;	/* This is used to convert
+						 * guest physical address to
+						 * physical address */
+			u64 recv_bus_irq_handle;
+				/* specifies interrupt info. It is used by SP
+				 * to register to receive interrupts from the
+				 * CP. This interrupt is used for bus level
+				 * notifications.  The corresponding
+				 * sendBusInterruptHandle is kept in CP. */
+		} configure_bus;	/* for CONTROLVM_BUS_CONFIGURE */
+		/* for CONTROLVM_DEVICE_CREATE */
+		struct controlvm_packet_device_create create_device;
+		struct  {
+			u32 bus_no;	/* bus # (0..n-1) from the msg
+					 * receiver's perspective */
+			u32 dev_no;	/* bus-relative (0..n-1) device # */
+		} destroy_device;	/* for CONTROLVM_DEVICE_DESTROY */
+		/* for CONTROLVM_DEVICE_CONFIGURE */
+		struct controlvm_packet_device_configure configure_device;
+		struct  {
+			u32 bus_no;	/* bus # (0..n-1) from the msg
+					 * receiver's perspective */
+			u32 dev_no;	/* bus-relative (0..n-1) device # */
+		} reconfigure_device;	/* for CONTROLVM_DEVICE_RECONFIGURE */
+		struct  {
+			u32 bus_no;
+			struct spar_segment_state state;
+			u8 reserved[2];	/* Natural alignment purposes */
+		} bus_change_state;	/* for CONTROLVM_BUS_CHANGESTATE */
+		struct  {
+			u32 bus_no;
+			u32 dev_no;
+			struct spar_segment_state state;
+			struct  {
+				u32 phys_device:1;	/* =1 if message is for
+							 * a physical device */
+			} flags;
+			u8 reserved[2];	/* Natural alignment purposes */
+		} device_change_state;	/* for CONTROLVM_DEVICE_CHANGESTATE */
+		struct  {
+			u32 bus_no;
+			u32 dev_no;
+			struct spar_segment_state state;
+			u8 reserved[6];	/* Natural alignment purposes */
+		} device_change_state_event;
+			/* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
+		struct  {
+			u32 bus_count;	/* indicates the max number of busses */
+			u32 switch_count; /* indicates the max number of
+					   * switches if a service partition */
+			enum ultra_chipset_feature features;
+			u32 platform_number;	/* Platform Number */
+		} init_chipset;	/* for CONTROLVM_CHIPSET_INIT */
+		struct  {
+			u32 options;	/* reserved */
+			u32 test;	/* bit 0 set to run embedded selftest */
+		} chipset_selftest;	/* for CONTROLVM_CHIPSET_SELFTEST */
+		u64 addr;	/* a physical address of something, that can be
+				 * dereferenced by the receiver of this
+				 * ControlVm command (depends on command id) */
+		u64 handle;	/* a handle of something (depends on command
+				 * id) */
+	};
+};
+
+/* All messages in any ControlVm queue have this layout. */
+struct controlvm_message {
+	struct controlvm_message_header hdr;
+	struct controlvm_message_packet cmd;
+};
+
+struct spar_controlvm_channel_protocol {
+	struct channel_header header;
+	u64 gp_controlvm;	/* guest phys addr of this channel */
+	u64 gp_partition_tables;/* guest phys addr of partition tables */
+	u64 gp_diag_guest;	/* guest phys addr of diagnostic channel */
+	u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */
+	u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */
+	u64 gp_acpi_table;	/* guest phys addr of acpi table */
+	u64 gp_control_channel;/* guest phys addr of control channel */
+	u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */
+	u64 gp_nvram;	/* guest phys addr of NVRAM channel */
+	u64 request_payload_offset;	/* Offset to request payload area */
+	u64 event_payload_offset;	/* Offset to event payload area */
+	u32 request_payload_bytes;	/* Bytes available in request payload
+					 * area */
+	u32 event_payload_bytes;/* Bytes available in event payload area */
+	u32 control_channel_bytes;
+	u32 nvram_channel_bytes;	/* Bytes in PartitionNvram segment */
+	u32 message_bytes;		/* sizeof(CONTROLVM_MESSAGE) */
+	u32 message_count;		/* CONTROLVM_MESSAGE_MAX */
+	u64 gp_smbios_table;		/* guest phys addr of SMBIOS tables */
+	u64 gp_physical_smbios_table;	/* guest phys addr of SMBIOS table  */
+	/* ULTRA_MAX_GUESTS_PER_SERVICE */
+	char gp_reserved[2688];
+
+	/* guest physical address of EFI firmware image base  */
+	u64 virtual_guest_firmware_image_base;
+
+	/* guest physical address of EFI firmware entry point  */
+	u64 virtual_guest_firmware_entry_point;
+
+	/* guest EFI firmware image size  */
+	u64 virtual_guest_firmware_image_size;
+
+	/* GPA = 1MB where EFI firmware image is copied to  */
+	u64 virtual_guest_firmware_boot_base;
+	u64 virtual_guest_image_base;
+	u64 virtual_guest_image_size;
+	u64 prototype_control_channel_offset;
+	u64 virtual_guest_partition_handle;
+
+	u16 restore_action;	/* Restore Action field to restore the guest
+				 * partition */
+	u16 dump_action;	/* For Windows guests it shows if the visordisk
+				 * is running in dump mode */
+	u16 nvram_fail_count;
+	u16 saved_crash_message_count;	/* = CONTROLVM_CRASHMSG_MAX */
+	u32 saved_crash_message_offset;	/* Offset to request payload area needed
+					 * for crash dump */
+	u32 installation_error;	/* Type of error encountered during
+				 * installation */
+	u32 installation_text_id;	/* Id of string to display */
+	u16 installation_remaining_steps;/* Number of remaining installation
+					  * steps (for progress bars) */
+	u8 tool_action;		/* ULTRA_TOOL_ACTIONS Installation Action
+				 * field */
+	u8 reserved;		/* alignment */
+	struct efi_spar_indication efi_spar_ind;
+	struct efi_spar_indication efi_spar_ind_supported;
+	u32 sp_reserved;
+	u8 reserved2[28];	/* Force signals to begin on 128-byte cache
+				 * line */
+	struct signal_queue_header request_queue;/* Service or guest partition
+						  * uses this queue to send
+						  * requests to Control */
+	struct signal_queue_header response_queue;/* Control uses this queue to
+						   * respond to service or guest
+						   * partition requests */
+	struct signal_queue_header event_queue;	/* Control uses this queue to
+						 * send events to service or
+						 * guest partition */
+	struct signal_queue_header event_ack_queue;/* Service or guest partition
+						    * uses this queue to ack
+						    * Control events */
+
+	 /* Request fixed-size message pool - does not include payload */
+	 struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
+
+	 /* Response fixed-size message pool - does not include payload */
+	 struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
+
+	 /* Event fixed-size message pool - does not include payload */
+	 struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
+
+	 /* Ack fixed-size message pool - does not include payload */
+	 struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
+
+	 /* Message stored during IOVM creation to be reused after crash */
+	 struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
+};
+
+/* Offsets for VM channel attributes */
+#define VM_CH_REQ_QUEUE_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, request_queue)
+#define VM_CH_RESP_QUEUE_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, response_queue)
+#define VM_CH_EVENT_QUEUE_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, event_queue)
+#define VM_CH_ACK_QUEUE_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
+#define VM_CH_REQ_MSG_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, request_msg)
+#define VM_CH_RESP_MSG_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, response_msg)
+#define VM_CH_EVENT_MSG_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, event_msg)
+#define VM_CH_ACK_MSG_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
+#define VM_CH_CRASH_MSG_OFFSET \
+	offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
+
+/* The following header will be located at the beginning of PayloadVmOffset for
+ * various ControlVm commands. The receiver of a ControlVm command with a
+ * PayloadVmOffset will dereference this address and then use connection_offset,
+ * initiator_offset, and target_offset to get the location of UTF-8 formatted
+ * strings that can be parsed to obtain command-specific information. The value
+ * of total_length should equal PayloadBytes. The format of the strings at
+ * PayloadVmOffset will take different forms depending on the message.
+ */
+struct spar_controlvm_parameters_header {
+	u32 total_length;
+	u32 header_length;
+	u32 connection_offset;
+	u32 connection_length;
+	u32 initiator_offset;
+	u32 initiator_length;
+	u32 target_offset;
+	u32 target_length;
+	u32 client_offset;
+	u32 client_length;
+	u32 name_offset;
+	u32 name_length;
+	uuid_le id;
+	u32 revision;
+	u32 reserved;		/* Natural alignment */
+};
+
+#endif				/* __CONTROLVMCHANNEL_H__ */
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 108/141] staging: unisys: vbuschannel belonsg to visorbus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (106 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 107/141] staging: unisys: Move channel.h to include. Controvlm to visorbus Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 109/141] staging: unisys: Move diagchannel to include Benjamin Romer
                   ` (35 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Move vbuschannel.h into visorbus.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/vbuschannel.h     | 94 ----------------------
 drivers/staging/unisys/visorbus/vbuschannel.h      | 94 ++++++++++++++++++++++
 2 files changed, 94 insertions(+), 94 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
 create mode 100644 drivers/staging/unisys/visorbus/vbuschannel.h

diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
deleted file mode 100644
index 5ed83a3..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VBUSCHANNEL_H__
-#define __VBUSCHANNEL_H__
-
-/*  The vbus channel is the channel area provided via the BUS_CREATE controlvm
- *  message for each virtual bus.  This channel area is provided to both server
- *  and client ends of the bus.  The channel header area is initialized by
- *  the server, and the remaining information is filled in by the client.
- *  We currently use this for the client to provide various information about
- *  the client devices and client drivers for the server end to see.
- */
-#include <linux/uuid.h>
-#include "vbusdeviceinfo.h"
-#include "channel.h"
-
-/* {193b331b-c58f-11da-95a9-00e08161165f} */
-#define SPAR_VBUS_CHANNEL_PROTOCOL_UUID \
-		UUID_LE(0x193b331b, 0xc58f, 0x11da, \
-				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
-static const uuid_le spar_vbus_channel_protocol_uuid =
-	SPAR_VBUS_CHANNEL_PROTOCOL_UUID;
-
-#define SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-
-/* Must increment this whenever you insert or delete fields within this channel
-* struct.  Also increment whenever you change the meaning of fields within this
-* channel struct so as to break pre-existing software.  Note that you can
-* usually add fields to the END of the channel struct withOUT needing to
-* increment this. */
-#define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
-
-#define SPAR_VBUS_CHANNEL_OK_CLIENT(ch)       \
-	spar_check_channel_client(ch,				\
-				   spar_vbus_channel_protocol_uuid,	\
-				   "vbus",				\
-				   sizeof(struct spar_vbus_channel_protocol),\
-				   SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
-				   SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)
-
-#define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes)    \
-	(spar_check_channel_server(spar_vbus_channel_protocol_uuid,	\
-				   "vbus",				\
-				   sizeof(struct spar_vbus_channel_protocol),\
-				   actual_bytes))
-
-#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
-struct spar_vbus_headerinfo {
-	u32 struct_bytes;	/* size of this struct in bytes */
-	u32 device_info_struct_bytes;	/* sizeof(ULTRA_VBUS_DEVICEINFO) */
-	u32 dev_info_count;	/* num of items in DevInfo member */
-	/* (this is the allocated size) */
-	u32 chp_info_offset;	/* byte offset from beginning of this struct */
-	/* to the ChpInfo struct (below) */
-	u32 bus_info_offset;	/* byte offset from beginning of this struct */
-	/* to the BusInfo struct (below) */
-	u32 dev_info_offset;	/* byte offset from beginning of this struct */
-	/* to the DevInfo array (below) */
-	u8 reserved[104];
-};
-
-struct spar_vbus_channel_protocol {
-	struct channel_header channel_header;	/* initialized by server */
-	struct spar_vbus_headerinfo hdr_info;	/* initialized by server */
-	/* the remainder of this channel is filled in by the client */
-	struct ultra_vbus_deviceinfo chp_info;
-	/* describes client chipset device and driver */
-	struct ultra_vbus_deviceinfo bus_info;
-	/* describes client bus device and driver */
-	struct ultra_vbus_deviceinfo dev_info[0];
-	/* describes client device and driver for each device on the bus */
-};
-
-#define VBUS_CH_SIZE_EXACT(MAXDEVICES) \
-	(sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL) + ((MAXDEVICES) * \
-						sizeof(ULTRA_VBUS_DEVICEINFO)))
-#define VBUS_CH_SIZE(MAXDEVICES) COVER(VBUS_CH_SIZE_EXACT(MAXDEVICES), 4096)
-
-#pragma pack(pop)
-
-#endif
diff --git a/drivers/staging/unisys/visorbus/vbuschannel.h b/drivers/staging/unisys/visorbus/vbuschannel.h
new file mode 100644
index 0000000..5ed83a3
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/vbuschannel.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VBUSCHANNEL_H__
+#define __VBUSCHANNEL_H__
+
+/*  The vbus channel is the channel area provided via the BUS_CREATE controlvm
+ *  message for each virtual bus.  This channel area is provided to both server
+ *  and client ends of the bus.  The channel header area is initialized by
+ *  the server, and the remaining information is filled in by the client.
+ *  We currently use this for the client to provide various information about
+ *  the client devices and client drivers for the server end to see.
+ */
+#include <linux/uuid.h>
+#include "vbusdeviceinfo.h"
+#include "channel.h"
+
+/* {193b331b-c58f-11da-95a9-00e08161165f} */
+#define SPAR_VBUS_CHANNEL_PROTOCOL_UUID \
+		UUID_LE(0x193b331b, 0xc58f, 0x11da, \
+				0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
+static const uuid_le spar_vbus_channel_protocol_uuid =
+	SPAR_VBUS_CHANNEL_PROTOCOL_UUID;
+
+#define SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+
+/* Must increment this whenever you insert or delete fields within this channel
+* struct.  Also increment whenever you change the meaning of fields within this
+* channel struct so as to break pre-existing software.  Note that you can
+* usually add fields to the END of the channel struct withOUT needing to
+* increment this. */
+#define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
+
+#define SPAR_VBUS_CHANNEL_OK_CLIENT(ch)       \
+	spar_check_channel_client(ch,				\
+				   spar_vbus_channel_protocol_uuid,	\
+				   "vbus",				\
+				   sizeof(struct spar_vbus_channel_protocol),\
+				   SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
+				   SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)
+
+#define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes)    \
+	(spar_check_channel_server(spar_vbus_channel_protocol_uuid,	\
+				   "vbus",				\
+				   sizeof(struct spar_vbus_channel_protocol),\
+				   actual_bytes))
+
+#pragma pack(push, 1)		/* both GCC and VC now allow this pragma */
+struct spar_vbus_headerinfo {
+	u32 struct_bytes;	/* size of this struct in bytes */
+	u32 device_info_struct_bytes;	/* sizeof(ULTRA_VBUS_DEVICEINFO) */
+	u32 dev_info_count;	/* num of items in DevInfo member */
+	/* (this is the allocated size) */
+	u32 chp_info_offset;	/* byte offset from beginning of this struct */
+	/* to the ChpInfo struct (below) */
+	u32 bus_info_offset;	/* byte offset from beginning of this struct */
+	/* to the BusInfo struct (below) */
+	u32 dev_info_offset;	/* byte offset from beginning of this struct */
+	/* to the DevInfo array (below) */
+	u8 reserved[104];
+};
+
+struct spar_vbus_channel_protocol {
+	struct channel_header channel_header;	/* initialized by server */
+	struct spar_vbus_headerinfo hdr_info;	/* initialized by server */
+	/* the remainder of this channel is filled in by the client */
+	struct ultra_vbus_deviceinfo chp_info;
+	/* describes client chipset device and driver */
+	struct ultra_vbus_deviceinfo bus_info;
+	/* describes client bus device and driver */
+	struct ultra_vbus_deviceinfo dev_info[0];
+	/* describes client device and driver for each device on the bus */
+};
+
+#define VBUS_CH_SIZE_EXACT(MAXDEVICES) \
+	(sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL) + ((MAXDEVICES) * \
+						sizeof(ULTRA_VBUS_DEVICEINFO)))
+#define VBUS_CH_SIZE(MAXDEVICES) COVER(VBUS_CH_SIZE_EXACT(MAXDEVICES), 4096)
+
+#pragma pack(pop)
+
+#endif
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 109/141] staging: unisys: Move diagchannel to include
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (107 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 108/141] staging: unisys: vbuschannel belonsg " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 110/141] staging: unisys: Move files out of common-spar Benjamin Romer
                   ` (34 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Diagchannel needs to go to standard include.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/diagchannel.h     | 427 ---------------------
 drivers/staging/unisys/include/diagchannel.h       | 427 +++++++++++++++++++++
 2 files changed, 427 insertions(+), 427 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/diagchannel.h
 create mode 100644 drivers/staging/unisys/include/diagchannel.h

diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h
deleted file mode 100644
index e8fb867..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h
+++ /dev/null
@@ -1,427 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*++
- *
- * Module Name:
- *
- * diagchannel.h
- *
- * Abstract:
- *
- * This file defines the DiagChannel protocol.  This protocol is used to aid in
- * preserving event data sent by external applications.  This protocol provides
- * a region for event data to reside in.  This data will eventually be sent to
- * the Boot Partition where it will be committed to memory and/or disk.  This
- * file contains platform-independent data that can be built using any
- * Supervisor build environment (Windows, Linux, EFI).
- *
-*/
-
-#ifndef _DIAG_CHANNEL_H_
-#define _DIAG_CHANNEL_H_
-
-#include <linux/uuid.h>
-#include "channel.h"
-
-/* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */
-#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \
-		UUID_LE(0xeea7a573, 0xdb82, 0x447c, \
-				0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58)
-
-static const uuid_le spar_diag_channel_protocol_uuid =
-	SPAR_DIAG_CHANNEL_PROTOCOL_UUID;
-
-/* {E850F968-3263-4484-8CA5-2A35D087A5A8} */
-#define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \
-		UUID_LE(0xe850f968, 0x3263, 0x4484, \
-				0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8)
-
-#define ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE  ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-
-/* Must increment this whenever you insert or delete fields within this channel
-* struct.  Also increment whenever you change the meaning of fields within this
-* channel struct so as to break pre-existing software.  Note that you can
-* usually add fields to the END of the channel struct withOUT needing to
-* increment this. */
-#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
-
-#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\
-	(spar_check_channel_client(ch,\
-				   spar_diag_channel_protocol_uuid,\
-				   "diag",\
-				   sizeof(struct spar_diag_channel_protocol),\
-				   ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\
-				   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
-
-#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\
-	(spar_check_channel_server(spar_diag_channel_protocol_uuid,\
-				   "diag",\
-				   sizeof(struct spar_diag_channel_protocol),\
-				   bytes))
-
-#define MAX_MODULE_NAME_SIZE 128	/* Maximum length of module name... */
-#define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional info
-					 * accompanying event... */
-#define MAX_SUBSYSTEMS 64	/* Maximum number of subsystems allowed in
-				 * DiagChannel... */
-#define LOW_SUBSYSTEMS 32	/* Half of MAX_SUBSYSTEMS to allow 64-bit
-				 * math */
-#define SUBSYSTEM_DEBUG 0	/* Standard subsystem for debug events */
-#define SUBSYSTEM_DEFAULT 1	/* Default subsystem for legacy calls to
-				 * ReportEvent */
-
-/* few useful subsystem mask values */
-#define SUBSYSTEM_MASK_DEBUG	0x01	/* Standard subsystem for debug
-					 * events */
-#define SUBSYSTEM_MASK_DEFAULT  0x02	/* Default subsystem for legacy calls to
-					 * ReportEvents */
-
-/* Event parameter "Severity" is overloaded with Cause in byte 2 and Severity in
- * byte 0, bytes 1 and 3 are reserved */
-#define SEVERITY_MASK 0x0FF	/* mask out all but the Severity in byte 0 */
-#define CAUSE_MASK 0x0FF0000	/* mask out all but the cause in byte 2 */
-#define CAUSE_SHIFT_AMT 16	/* shift 2 bytes to place it in byte 2 */
-
-/* SubsystemSeverityFilter */
-#define SEVERITY_FILTER_MASK 0x0F /* mask out the Cause half, SeverityFilter is
-				   * in the lower nibble */
-#define CAUSE_FILTER_MASK 0xF0	/* mask out the Severity half, CauseFilter is in
-				 * the upper nibble */
-#define CAUSE_FILTER_SHIFT_AMT	4 /* shift amount to place it in lower or upper
-				   * nibble */
-
-/* Copied from EFI's EFI_TIME struct in efidef.h.  EFI headers are not allowed
-* in some of the Supervisor areas, such as Monitor, so it has been "ported" here
-* for use in diagnostic event timestamps... */
-struct diag_efi_time  {
-	u16 year;		/* 1998 - 20XX */
-	u8 month;		/* 1 - 12 */
-	u8 day;			/* 1 - 31 */
-	u8 hour;		/* 0 - 23 */
-	u8 minute;		/* 0 - 59 */
-	u8 second;		/* 0 - 59 */
-	u8 pad1;
-	u32 nanosecond;	/* 0 - 999, 999, 999 */
-	s16 timezone;		/* -1440 to 1440 or 2047 */
-	u8 daylight;
-	u8 pad2;
-};
-
-enum spar_component_types  {
-	 ULTRA_COMPONENT_GUEST = 0,
-	 ULTRA_COMPONENT_MONITOR = 0x01,
-	 ULTRA_COMPONENT_CCM = 0x02,	/* Common Control module */
-	 /* RESERVED 0x03 - 0x7 */
-
-	 /* Ultravisor Components */
-	 ULTRA_COMPONENT_BOOT = 0x08,
-	 ULTRA_COMPONENT_IDLE = 0x09,
-	 ULTRA_COMPONENT_CONTROL = 0x0A,
-	 ULTRA_COMPONENT_LOGGER = 0x0B,
-	 ULTRA_COMPONENT_ACPI = 0X0C,
-	 /* RESERVED 0x0D - 0x0F */
-
-	 /* sPAR Components */
-	 ULTRA_COMPONENT_COMMAND = 0x10,
-	 ULTRA_COMPONENT_IODRIVER = 0x11,
-	 ULTRA_COMPONENT_CONSOLE = 0x12,
-	 ULTRA_COMPONENT_OPERATIONS = 0x13,
-	 ULTRA_COMPONENT_MANAGEMENT = 0x14,
-	 ULTRA_COMPONENT_DIAG = 0x15,
-	 ULTRA_COMPONENT_HWDIAG = 0x16,
-	 ULTRA_COMPONENT_PSERVICES = 0x17,
-	 ULTRA_COMPONENT_PDIAG = 0x18
-	 /* RESERVED 0x18 - 0x1F */
-};
-
-/* Structure: diag_channel_event Purpose: Contains attributes that make up an
- * event to be written to the DIAG_CHANNEL memory.  Attributes: EventId: Id of
- * the diagnostic event to write to memory.  Severity: Severity of the event
- * (Error, Info, etc).  ModuleName: Module/file name where event originated.
- * LineNumber: Line number in module name where event originated.  Timestamp:
- * Date/time when event was received by ReportEvent, and written to DiagChannel.
- * Reserved: Padding to align structure on a 64-byte cache line boundary.
- * AdditionalInfo: Array of characters for additional event info (may be
- * empty).  */
-struct diag_channel_event {
-	u32 event_id;
-	u32 severity;
-	u8 module_name[MAX_MODULE_NAME_SIZE];
-	u32 line_number;
-	struct diag_efi_time timestamp;	/* Size = 16 bytes */
-	u32 partition_number;	/* Filled in by Diag Switch as pool blocks are
-				 * filled */
-	u16 vcpu_number;
-	u16 lcpu_number;
-	u8 component_type;	/* ULTRA_COMPONENT_TYPES */
-	u8 subsystem;
-	u16 reserved0;		/* pad to u64 alignment */
-	u32 block_no;		/* filled in by DiagSwitch as pool blocks are
-				 * filled */
-	u32 block_no_high;
-	u32 event_no;		/* filled in by DiagSwitch as pool blocks are
-				 * filled */
-	u32 event_no_high;
-
-	/* The block_no and event_no fields are set only by DiagSwitch
-	 * and referenced only by WinDiagDisplay formatting tool as
-	 * additional diagnostic information.  Other tools including
-	 * WinDiagDisplay currently ignore these 'Reserved' bytes. */
-	u8 reserved[8];
-	u8 additional_info[MAX_ADDITIONAL_INFO_SIZE];
-
-	/* NOTE: Changes to diag_channel_event generally need to be reflected in
-	 * existing copies *
-	 * - for AppOS at
-	 * GuestLinux/visordiag_early/supervisor_diagchannel.h *
-	 * - for WinDiagDisplay at
-	 * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */
-};
-
-/* Levels of severity for diagnostic events, in order from lowest severity to
-* highest (i.e. fatal errors are the most severe, and should always be logged,
-* but info events rarely need to be logged except during debugging).  The values
-* DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid severity
-* values.  They exist merely to dilineate the list, so that future additions
-* won't require changes to the driver (i.e. when checking for out-of-range
-* severities in SetSeverity).  The values DIAG_SEVERITY_OVERRIDE and
-* DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events but
-* they are valid for controlling the amount of event data.  This enum is also
-* defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs.  If a
-* change is made to this enum, they should also be reflected in that file.  */
-enum diag_severity {
-		DIAG_SEVERITY_ENUM_BEGIN = 0,
-		DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN,
-		DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE,	/* 0 */
-		DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1,	/* 1 */
-		DIAG_SEVERITY_WARNING = DIAG_SEVERITY_INFO + 1,	/* 2 */
-		DIAG_SEVERITY_ERR = DIAG_SEVERITY_WARNING + 1,	/* 3 */
-		DIAG_SEVERITY_PRINT = DIAG_SEVERITY_ERR + 1,	/* 4 */
-		DIAG_SEVERITY_SHUTOFF = DIAG_SEVERITY_PRINT + 1, /* 5 */
-		DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF,	/* 5 */
-		DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR,
-		DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT
-};
-
-/* Event Cause enums
-*
-* Levels of cause for diagnostic events, in order from least to greatest cause
-* Internal errors are most urgent since ideally they should never exist
-* Invalid requests are preventable by avoiding invalid inputs
-* Operations errors depend on environmental factors which may impact which
-* requests are possible
-* Manifest provides intermediate value to capture firmware and configuration
-* version information
-* Trace provides suplimental debug information in release firmware
-* Unknown Log captures unclasified LogEvent calls.
-* Debug is the least urgent since it provides suplimental debug information only
-* in debug firmware
-* Unknown Debug captures unclassified DebugEvent calls.
-* This enum is also defined in
-* DotNet\sParFramework\ControlFramework\ControlFramework.cs.
-* If a change is made to this enum, they should also be reflected in that
-* file.  */
-
-/* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of
-* "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to
-* the Diag partition. This cause-severity combination will be used by Logger
-* DiagSwitch to segregate events into block types. The files are transferred in
-* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event
-* structure. In the file transfer mode, some event fields will have different
-* meaning: EventId specifies the file offset, severity specifies the block type,
-* ModuleName specifies the filename, LineNumber specifies the number of valid
-* data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */
-
-/* The Diag DiagWriter appends event blocks to events.raw as today, and for data
- * blocks uses diag_channel_event
- * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified
- * by ModuleName). */
-
-/* The Dell PDiag uses this new mechanism to stash DSET .zip onto the
- * 'diagnostic' virtual disk.  */
-enum diag_cause {
-	DIAG_CAUSE_UNKNOWN = 0,
-	DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1,	/* 1 */
-	DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1,	/* 2 */
-	DIAG_CAUSE_UNKNOWN_LOG = DIAG_CAUSE_DEBUG + 1,	/* 3 */
-	DIAG_CAUSE_TRACE = DIAG_CAUSE_UNKNOWN_LOG + 1,	/* 4 */
-	DIAG_CAUSE_MANIFEST = DIAG_CAUSE_TRACE + 1,	/* 5 */
-	DIAG_CAUSE_OPERATIONS_ERROR = DIAG_CAUSE_MANIFEST + 1,	/* 6 */
-	DIAG_CAUSE_INVALID_REQUEST = DIAG_CAUSE_OPERATIONS_ERROR + 1,	/* 7 */
-	DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */
-	DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1,	/* 9 */
-	DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER	/* 9 */
-};
-
-/* Event Cause category defined into the byte 2 of Severity */
-#define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT)
-#define CAUSE_TRACE (DIAG_CAUSE_TRACE << CAUSE_SHIFT_AMT)
-#define CAUSE_MANIFEST (DIAG_CAUSE_MANIFEST << CAUSE_SHIFT_AMT)
-#define CAUSE_OPERATIONS_ERROR (DIAG_CAUSE_OPERATIONS_ERROR << CAUSE_SHIFT_AMT)
-#define CAUSE_INVALID_REQUEST (DIAG_CAUSE_INVALID_REQUEST << CAUSE_SHIFT_AMT)
-#define CAUSE_INTERNAL_ERROR (DIAG_CAUSE_INTERNAL_ERROR << CAUSE_SHIFT_AMT)
-#define CAUSE_FILE_XFER (DIAG_CAUSE_FILE_XFER << CAUSE_SHIFT_AMT)
-#define CAUSE_ENUM_END CAUSE_FILE_XFER
-
-/* Combine Cause and Severity categories into one */
-#define CAUSE_DEBUG_SEVERITY_VERBOSE \
-	(CAUSE_DEBUG | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_TRACE_SEVERITY_VERBOSE \
-	(CAUSE_TRACE | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_MANIFEST_SEVERITY_VERBOSE\
-	(CAUSE_MANIFEST | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_OPERATIONS_SEVERITY_VERBOSE \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_INVALID_SEVERITY_VERBOSE \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_INTERNAL_SEVERITY_VERBOSE \
-	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_VERBOSE)
-
-#define CAUSE_DEBUG_SEVERITY_INFO \
-	(CAUSE_DEBUG | DIAG_SEVERITY_INFO)
-#define CAUSE_TRACE_SEVERITY_INFO \
-	(CAUSE_TRACE | DIAG_SEVERITY_INFO)
-#define CAUSE_MANIFEST_SEVERITY_INFO \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_INFO)
-#define CAUSE_OPERATIONS_SEVERITY_INFO \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_INFO)
-#define CAUSE_INVALID_SEVERITY_INFO \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_INFO)
-#define CAUSE_INTERNAL_SEVERITY_INFO \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_INFO)
-
-#define CAUSE_DEBUG_SEVERITY_WARN \
-	(CAUSE_DEBUG | DIAG_SEVERITY_WARNING)
-#define CAUSE_TRACE_SEVERITY_WARN \
-	(CAUSE_TRACE | DIAG_SEVERITY_WARNING)
-#define CAUSE_MANIFEST_SEVERITY_WARN \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_WARNING)
-#define CAUSE_OPERATIONS_SEVERITY_WARN \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_WARNING)
-#define CAUSE_INVALID_SEVERITY_WARN \
-	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_WARNING)
-#define CAUSE_INTERNAL_SEVERITY_WARN \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_WARNING)
-
-#define CAUSE_DEBUG_SEVERITY_ERR \
-	(CAUSE_DEBUG | DIAG_SEVERITY_ERR)
-#define CAUSE_TRACE_SEVERITY_ERR \
-	(CAUSE_TRACE | DIAG_SEVERITY_ERR)
-#define CAUSE_MANIFEST_SEVERITY_ERR \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_ERR)
-#define CAUSE_OPERATIONS_SEVERITY_ERR \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_ERR)
-#define CAUSE_INVALID_SEVERITY_ERR \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_ERR)
-#define CAUSE_INTERNAL_SEVERITY_ERR \
-	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_ERR)
-
-#define CAUSE_DEBUG_SEVERITY_PRINT \
-	(CAUSE_DEBUG | DIAG_SEVERITY_PRINT)
-#define CAUSE_TRACE_SEVERITY_PRINT \
-	(CAUSE_TRACE | DIAG_SEVERITY_PRINT)
-#define CAUSE_MANIFEST_SEVERITY_PRINT \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_PRINT)
-#define CAUSE_OPERATIONS_SEVERITY_PRINT \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_PRINT)
-#define CAUSE_INVALID_SEVERITY_PRINT \
-	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_PRINT)
-#define CAUSE_INTERNAL_SEVERITY_PRINT \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_PRINT)
-#define CAUSE_FILE_XFER_SEVERITY_PRINT \
-	(CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT)
-
-/* Structure: diag_channel_protocol_header
- *
- * Purpose: Contains attributes that make up the header specific to the
- * DIAG_CHANNEL area.
- *
- * Attributes:
- *
- * DiagLock: Diag Channel spinlock.
- *
- *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise
- *			0, and assume the channel is not ready for use yet.
- *
- * Reserved: Padding to align the fields in this structure.
- *
- *SubsystemSeverityFilter: Level of severity on a subsystem basis that controls
- *			whether events are logged.  Any event's severity for a
- *			particular subsystem below this level will be discarded.
- */
-struct diag_channel_protocol_header {
-	u32 diag_lock;
-	u8 channel_initialized;
-	u8 reserved[3];
-	u8 subsystem_severity_filter[64];
-};
-
-/* The Diagram for the Diagnostic Channel: */
-/* ----------------------- */
-/* | Channel Header        |	Defined by ULTRA_CHANNEL_PROTOCOL */
-/* ----------------------- */
-/* | Signal Queue Header   |	Defined by SIGNAL_QUEUE_HEADER */
-/* ----------------------- */
-/* | DiagChannel Header    |	Defined by diag_channel_protocol_header */
-/* ----------------------- */
-/* | Channel Event Info    |	Defined by diag_channel_event*MAX_EVENTS */
-/* ----------------------- */
-/* | Reserved              |	Reserved (pad out to 4MB) */
-/* ----------------------- */
-
-/* Offsets/sizes for diagnostic channel attributes... */
-#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header))
-#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header))
-#define DIAG_CH_PROTOCOL_HEADER_OFFSET \
-	(DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE)
-#define DIAG_CH_PROTOCOL_HEADER_SIZE \
-	(sizeof(struct diag_channel_protocol_header))
-#define DIAG_CH_EVENT_OFFSET \
-	(DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE)
-#define DIAG_CH_SIZE (4096 * 1024)
-
-/* For Control and Idle Partitions with larger (8 MB) diagnostic(root)
- * channels */
-#define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE)	/* 8 MB */
-
-/*
- * Structure: spar_diag_channel_protocol
- *
- * Purpose: Contains attributes that make up the DIAG_CHANNEL memory.
- *
- * Attributes:
- *
- * CommonChannelHeader:	Header info common to all channels.
- *
- * QueueHeader: Queue header common to all channels - used to determine where to
- * store event.
- *
- * DiagChannelHeader: Diagnostic channel header info (see
- * diag_channel_protocol_header comments).
- *
- * Events: Area where diagnostic events (up to MAX_EVENTS) are written.
- *
- *Reserved: Reserved area to allow for correct channel size padding.
-*/
-struct spar_diag_channel_protocol  {
-	struct channel_header common_channel_header;
-	struct signal_queue_header queue_header;
-	struct diag_channel_protocol_header diag_channel_header;
-	struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) /
-				   sizeof(struct diag_channel_event)];
-};
-
-#endif
diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h
new file mode 100644
index 0000000..e8fb867
--- /dev/null
+++ b/drivers/staging/unisys/include/diagchannel.h
@@ -0,0 +1,427 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*++
+ *
+ * Module Name:
+ *
+ * diagchannel.h
+ *
+ * Abstract:
+ *
+ * This file defines the DiagChannel protocol.  This protocol is used to aid in
+ * preserving event data sent by external applications.  This protocol provides
+ * a region for event data to reside in.  This data will eventually be sent to
+ * the Boot Partition where it will be committed to memory and/or disk.  This
+ * file contains platform-independent data that can be built using any
+ * Supervisor build environment (Windows, Linux, EFI).
+ *
+*/
+
+#ifndef _DIAG_CHANNEL_H_
+#define _DIAG_CHANNEL_H_
+
+#include <linux/uuid.h>
+#include "channel.h"
+
+/* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */
+#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \
+		UUID_LE(0xeea7a573, 0xdb82, 0x447c, \
+				0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58)
+
+static const uuid_le spar_diag_channel_protocol_uuid =
+	SPAR_DIAG_CHANNEL_PROTOCOL_UUID;
+
+/* {E850F968-3263-4484-8CA5-2A35D087A5A8} */
+#define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \
+		UUID_LE(0xe850f968, 0x3263, 0x4484, \
+				0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8)
+
+#define ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE  ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+
+/* Must increment this whenever you insert or delete fields within this channel
+* struct.  Also increment whenever you change the meaning of fields within this
+* channel struct so as to break pre-existing software.  Note that you can
+* usually add fields to the END of the channel struct withOUT needing to
+* increment this. */
+#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
+
+#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\
+	(spar_check_channel_client(ch,\
+				   spar_diag_channel_protocol_uuid,\
+				   "diag",\
+				   sizeof(struct spar_diag_channel_protocol),\
+				   ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\
+				   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
+
+#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\
+	(spar_check_channel_server(spar_diag_channel_protocol_uuid,\
+				   "diag",\
+				   sizeof(struct spar_diag_channel_protocol),\
+				   bytes))
+
+#define MAX_MODULE_NAME_SIZE 128	/* Maximum length of module name... */
+#define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional info
+					 * accompanying event... */
+#define MAX_SUBSYSTEMS 64	/* Maximum number of subsystems allowed in
+				 * DiagChannel... */
+#define LOW_SUBSYSTEMS 32	/* Half of MAX_SUBSYSTEMS to allow 64-bit
+				 * math */
+#define SUBSYSTEM_DEBUG 0	/* Standard subsystem for debug events */
+#define SUBSYSTEM_DEFAULT 1	/* Default subsystem for legacy calls to
+				 * ReportEvent */
+
+/* few useful subsystem mask values */
+#define SUBSYSTEM_MASK_DEBUG	0x01	/* Standard subsystem for debug
+					 * events */
+#define SUBSYSTEM_MASK_DEFAULT  0x02	/* Default subsystem for legacy calls to
+					 * ReportEvents */
+
+/* Event parameter "Severity" is overloaded with Cause in byte 2 and Severity in
+ * byte 0, bytes 1 and 3 are reserved */
+#define SEVERITY_MASK 0x0FF	/* mask out all but the Severity in byte 0 */
+#define CAUSE_MASK 0x0FF0000	/* mask out all but the cause in byte 2 */
+#define CAUSE_SHIFT_AMT 16	/* shift 2 bytes to place it in byte 2 */
+
+/* SubsystemSeverityFilter */
+#define SEVERITY_FILTER_MASK 0x0F /* mask out the Cause half, SeverityFilter is
+				   * in the lower nibble */
+#define CAUSE_FILTER_MASK 0xF0	/* mask out the Severity half, CauseFilter is in
+				 * the upper nibble */
+#define CAUSE_FILTER_SHIFT_AMT	4 /* shift amount to place it in lower or upper
+				   * nibble */
+
+/* Copied from EFI's EFI_TIME struct in efidef.h.  EFI headers are not allowed
+* in some of the Supervisor areas, such as Monitor, so it has been "ported" here
+* for use in diagnostic event timestamps... */
+struct diag_efi_time  {
+	u16 year;		/* 1998 - 20XX */
+	u8 month;		/* 1 - 12 */
+	u8 day;			/* 1 - 31 */
+	u8 hour;		/* 0 - 23 */
+	u8 minute;		/* 0 - 59 */
+	u8 second;		/* 0 - 59 */
+	u8 pad1;
+	u32 nanosecond;	/* 0 - 999, 999, 999 */
+	s16 timezone;		/* -1440 to 1440 or 2047 */
+	u8 daylight;
+	u8 pad2;
+};
+
+enum spar_component_types  {
+	 ULTRA_COMPONENT_GUEST = 0,
+	 ULTRA_COMPONENT_MONITOR = 0x01,
+	 ULTRA_COMPONENT_CCM = 0x02,	/* Common Control module */
+	 /* RESERVED 0x03 - 0x7 */
+
+	 /* Ultravisor Components */
+	 ULTRA_COMPONENT_BOOT = 0x08,
+	 ULTRA_COMPONENT_IDLE = 0x09,
+	 ULTRA_COMPONENT_CONTROL = 0x0A,
+	 ULTRA_COMPONENT_LOGGER = 0x0B,
+	 ULTRA_COMPONENT_ACPI = 0X0C,
+	 /* RESERVED 0x0D - 0x0F */
+
+	 /* sPAR Components */
+	 ULTRA_COMPONENT_COMMAND = 0x10,
+	 ULTRA_COMPONENT_IODRIVER = 0x11,
+	 ULTRA_COMPONENT_CONSOLE = 0x12,
+	 ULTRA_COMPONENT_OPERATIONS = 0x13,
+	 ULTRA_COMPONENT_MANAGEMENT = 0x14,
+	 ULTRA_COMPONENT_DIAG = 0x15,
+	 ULTRA_COMPONENT_HWDIAG = 0x16,
+	 ULTRA_COMPONENT_PSERVICES = 0x17,
+	 ULTRA_COMPONENT_PDIAG = 0x18
+	 /* RESERVED 0x18 - 0x1F */
+};
+
+/* Structure: diag_channel_event Purpose: Contains attributes that make up an
+ * event to be written to the DIAG_CHANNEL memory.  Attributes: EventId: Id of
+ * the diagnostic event to write to memory.  Severity: Severity of the event
+ * (Error, Info, etc).  ModuleName: Module/file name where event originated.
+ * LineNumber: Line number in module name where event originated.  Timestamp:
+ * Date/time when event was received by ReportEvent, and written to DiagChannel.
+ * Reserved: Padding to align structure on a 64-byte cache line boundary.
+ * AdditionalInfo: Array of characters for additional event info (may be
+ * empty).  */
+struct diag_channel_event {
+	u32 event_id;
+	u32 severity;
+	u8 module_name[MAX_MODULE_NAME_SIZE];
+	u32 line_number;
+	struct diag_efi_time timestamp;	/* Size = 16 bytes */
+	u32 partition_number;	/* Filled in by Diag Switch as pool blocks are
+				 * filled */
+	u16 vcpu_number;
+	u16 lcpu_number;
+	u8 component_type;	/* ULTRA_COMPONENT_TYPES */
+	u8 subsystem;
+	u16 reserved0;		/* pad to u64 alignment */
+	u32 block_no;		/* filled in by DiagSwitch as pool blocks are
+				 * filled */
+	u32 block_no_high;
+	u32 event_no;		/* filled in by DiagSwitch as pool blocks are
+				 * filled */
+	u32 event_no_high;
+
+	/* The block_no and event_no fields are set only by DiagSwitch
+	 * and referenced only by WinDiagDisplay formatting tool as
+	 * additional diagnostic information.  Other tools including
+	 * WinDiagDisplay currently ignore these 'Reserved' bytes. */
+	u8 reserved[8];
+	u8 additional_info[MAX_ADDITIONAL_INFO_SIZE];
+
+	/* NOTE: Changes to diag_channel_event generally need to be reflected in
+	 * existing copies *
+	 * - for AppOS at
+	 * GuestLinux/visordiag_early/supervisor_diagchannel.h *
+	 * - for WinDiagDisplay at
+	 * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */
+};
+
+/* Levels of severity for diagnostic events, in order from lowest severity to
+* highest (i.e. fatal errors are the most severe, and should always be logged,
+* but info events rarely need to be logged except during debugging).  The values
+* DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid severity
+* values.  They exist merely to dilineate the list, so that future additions
+* won't require changes to the driver (i.e. when checking for out-of-range
+* severities in SetSeverity).  The values DIAG_SEVERITY_OVERRIDE and
+* DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events but
+* they are valid for controlling the amount of event data.  This enum is also
+* defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs.  If a
+* change is made to this enum, they should also be reflected in that file.  */
+enum diag_severity {
+		DIAG_SEVERITY_ENUM_BEGIN = 0,
+		DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN,
+		DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE,	/* 0 */
+		DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1,	/* 1 */
+		DIAG_SEVERITY_WARNING = DIAG_SEVERITY_INFO + 1,	/* 2 */
+		DIAG_SEVERITY_ERR = DIAG_SEVERITY_WARNING + 1,	/* 3 */
+		DIAG_SEVERITY_PRINT = DIAG_SEVERITY_ERR + 1,	/* 4 */
+		DIAG_SEVERITY_SHUTOFF = DIAG_SEVERITY_PRINT + 1, /* 5 */
+		DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF,	/* 5 */
+		DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR,
+		DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT
+};
+
+/* Event Cause enums
+*
+* Levels of cause for diagnostic events, in order from least to greatest cause
+* Internal errors are most urgent since ideally they should never exist
+* Invalid requests are preventable by avoiding invalid inputs
+* Operations errors depend on environmental factors which may impact which
+* requests are possible
+* Manifest provides intermediate value to capture firmware and configuration
+* version information
+* Trace provides suplimental debug information in release firmware
+* Unknown Log captures unclasified LogEvent calls.
+* Debug is the least urgent since it provides suplimental debug information only
+* in debug firmware
+* Unknown Debug captures unclassified DebugEvent calls.
+* This enum is also defined in
+* DotNet\sParFramework\ControlFramework\ControlFramework.cs.
+* If a change is made to this enum, they should also be reflected in that
+* file.  */
+
+/* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of
+* "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to
+* the Diag partition. This cause-severity combination will be used by Logger
+* DiagSwitch to segregate events into block types. The files are transferred in
+* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event
+* structure. In the file transfer mode, some event fields will have different
+* meaning: EventId specifies the file offset, severity specifies the block type,
+* ModuleName specifies the filename, LineNumber specifies the number of valid
+* data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */
+
+/* The Diag DiagWriter appends event blocks to events.raw as today, and for data
+ * blocks uses diag_channel_event
+ * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified
+ * by ModuleName). */
+
+/* The Dell PDiag uses this new mechanism to stash DSET .zip onto the
+ * 'diagnostic' virtual disk.  */
+enum diag_cause {
+	DIAG_CAUSE_UNKNOWN = 0,
+	DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1,	/* 1 */
+	DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1,	/* 2 */
+	DIAG_CAUSE_UNKNOWN_LOG = DIAG_CAUSE_DEBUG + 1,	/* 3 */
+	DIAG_CAUSE_TRACE = DIAG_CAUSE_UNKNOWN_LOG + 1,	/* 4 */
+	DIAG_CAUSE_MANIFEST = DIAG_CAUSE_TRACE + 1,	/* 5 */
+	DIAG_CAUSE_OPERATIONS_ERROR = DIAG_CAUSE_MANIFEST + 1,	/* 6 */
+	DIAG_CAUSE_INVALID_REQUEST = DIAG_CAUSE_OPERATIONS_ERROR + 1,	/* 7 */
+	DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */
+	DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1,	/* 9 */
+	DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER	/* 9 */
+};
+
+/* Event Cause category defined into the byte 2 of Severity */
+#define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT)
+#define CAUSE_TRACE (DIAG_CAUSE_TRACE << CAUSE_SHIFT_AMT)
+#define CAUSE_MANIFEST (DIAG_CAUSE_MANIFEST << CAUSE_SHIFT_AMT)
+#define CAUSE_OPERATIONS_ERROR (DIAG_CAUSE_OPERATIONS_ERROR << CAUSE_SHIFT_AMT)
+#define CAUSE_INVALID_REQUEST (DIAG_CAUSE_INVALID_REQUEST << CAUSE_SHIFT_AMT)
+#define CAUSE_INTERNAL_ERROR (DIAG_CAUSE_INTERNAL_ERROR << CAUSE_SHIFT_AMT)
+#define CAUSE_FILE_XFER (DIAG_CAUSE_FILE_XFER << CAUSE_SHIFT_AMT)
+#define CAUSE_ENUM_END CAUSE_FILE_XFER
+
+/* Combine Cause and Severity categories into one */
+#define CAUSE_DEBUG_SEVERITY_VERBOSE \
+	(CAUSE_DEBUG | DIAG_SEVERITY_VERBOSE)
+#define CAUSE_TRACE_SEVERITY_VERBOSE \
+	(CAUSE_TRACE | DIAG_SEVERITY_VERBOSE)
+#define CAUSE_MANIFEST_SEVERITY_VERBOSE\
+	(CAUSE_MANIFEST | DIAG_SEVERITY_VERBOSE)
+#define CAUSE_OPERATIONS_SEVERITY_VERBOSE \
+	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_VERBOSE)
+#define CAUSE_INVALID_SEVERITY_VERBOSE \
+	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_VERBOSE)
+#define CAUSE_INTERNAL_SEVERITY_VERBOSE \
+	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_VERBOSE)
+
+#define CAUSE_DEBUG_SEVERITY_INFO \
+	(CAUSE_DEBUG | DIAG_SEVERITY_INFO)
+#define CAUSE_TRACE_SEVERITY_INFO \
+	(CAUSE_TRACE | DIAG_SEVERITY_INFO)
+#define CAUSE_MANIFEST_SEVERITY_INFO \
+	(CAUSE_MANIFEST | DIAG_SEVERITY_INFO)
+#define CAUSE_OPERATIONS_SEVERITY_INFO \
+	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_INFO)
+#define CAUSE_INVALID_SEVERITY_INFO \
+	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_INFO)
+#define CAUSE_INTERNAL_SEVERITY_INFO \
+	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_INFO)
+
+#define CAUSE_DEBUG_SEVERITY_WARN \
+	(CAUSE_DEBUG | DIAG_SEVERITY_WARNING)
+#define CAUSE_TRACE_SEVERITY_WARN \
+	(CAUSE_TRACE | DIAG_SEVERITY_WARNING)
+#define CAUSE_MANIFEST_SEVERITY_WARN \
+	(CAUSE_MANIFEST | DIAG_SEVERITY_WARNING)
+#define CAUSE_OPERATIONS_SEVERITY_WARN \
+	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_WARNING)
+#define CAUSE_INVALID_SEVERITY_WARN \
+	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_WARNING)
+#define CAUSE_INTERNAL_SEVERITY_WARN \
+	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_WARNING)
+
+#define CAUSE_DEBUG_SEVERITY_ERR \
+	(CAUSE_DEBUG | DIAG_SEVERITY_ERR)
+#define CAUSE_TRACE_SEVERITY_ERR \
+	(CAUSE_TRACE | DIAG_SEVERITY_ERR)
+#define CAUSE_MANIFEST_SEVERITY_ERR \
+	(CAUSE_MANIFEST | DIAG_SEVERITY_ERR)
+#define CAUSE_OPERATIONS_SEVERITY_ERR \
+	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_ERR)
+#define CAUSE_INVALID_SEVERITY_ERR \
+	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_ERR)
+#define CAUSE_INTERNAL_SEVERITY_ERR \
+	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_ERR)
+
+#define CAUSE_DEBUG_SEVERITY_PRINT \
+	(CAUSE_DEBUG | DIAG_SEVERITY_PRINT)
+#define CAUSE_TRACE_SEVERITY_PRINT \
+	(CAUSE_TRACE | DIAG_SEVERITY_PRINT)
+#define CAUSE_MANIFEST_SEVERITY_PRINT \
+	(CAUSE_MANIFEST | DIAG_SEVERITY_PRINT)
+#define CAUSE_OPERATIONS_SEVERITY_PRINT \
+	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_PRINT)
+#define CAUSE_INVALID_SEVERITY_PRINT \
+	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_PRINT)
+#define CAUSE_INTERNAL_SEVERITY_PRINT \
+	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_PRINT)
+#define CAUSE_FILE_XFER_SEVERITY_PRINT \
+	(CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT)
+
+/* Structure: diag_channel_protocol_header
+ *
+ * Purpose: Contains attributes that make up the header specific to the
+ * DIAG_CHANNEL area.
+ *
+ * Attributes:
+ *
+ * DiagLock: Diag Channel spinlock.
+ *
+ *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise
+ *			0, and assume the channel is not ready for use yet.
+ *
+ * Reserved: Padding to align the fields in this structure.
+ *
+ *SubsystemSeverityFilter: Level of severity on a subsystem basis that controls
+ *			whether events are logged.  Any event's severity for a
+ *			particular subsystem below this level will be discarded.
+ */
+struct diag_channel_protocol_header {
+	u32 diag_lock;
+	u8 channel_initialized;
+	u8 reserved[3];
+	u8 subsystem_severity_filter[64];
+};
+
+/* The Diagram for the Diagnostic Channel: */
+/* ----------------------- */
+/* | Channel Header        |	Defined by ULTRA_CHANNEL_PROTOCOL */
+/* ----------------------- */
+/* | Signal Queue Header   |	Defined by SIGNAL_QUEUE_HEADER */
+/* ----------------------- */
+/* | DiagChannel Header    |	Defined by diag_channel_protocol_header */
+/* ----------------------- */
+/* | Channel Event Info    |	Defined by diag_channel_event*MAX_EVENTS */
+/* ----------------------- */
+/* | Reserved              |	Reserved (pad out to 4MB) */
+/* ----------------------- */
+
+/* Offsets/sizes for diagnostic channel attributes... */
+#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header))
+#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header))
+#define DIAG_CH_PROTOCOL_HEADER_OFFSET \
+	(DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE)
+#define DIAG_CH_PROTOCOL_HEADER_SIZE \
+	(sizeof(struct diag_channel_protocol_header))
+#define DIAG_CH_EVENT_OFFSET \
+	(DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE)
+#define DIAG_CH_SIZE (4096 * 1024)
+
+/* For Control and Idle Partitions with larger (8 MB) diagnostic(root)
+ * channels */
+#define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE)	/* 8 MB */
+
+/*
+ * Structure: spar_diag_channel_protocol
+ *
+ * Purpose: Contains attributes that make up the DIAG_CHANNEL memory.
+ *
+ * Attributes:
+ *
+ * CommonChannelHeader:	Header info common to all channels.
+ *
+ * QueueHeader: Queue header common to all channels - used to determine where to
+ * store event.
+ *
+ * DiagChannelHeader: Diagnostic channel header info (see
+ * diag_channel_protocol_header comments).
+ *
+ * Events: Area where diagnostic events (up to MAX_EVENTS) are written.
+ *
+ *Reserved: Reserved area to allow for correct channel size padding.
+*/
+struct spar_diag_channel_protocol  {
+	struct channel_header common_channel_header;
+	struct signal_queue_header queue_header;
+	struct diag_channel_protocol_header diag_channel_header;
+	struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) /
+				   sizeof(struct diag_channel_event)];
+};
+
+#endif
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 110/141] staging: unisys: Move files out of common-spar
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (108 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 109/141] staging: unisys: Move diagchannel to include Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 111/141] staging: unisys: Get rid of references to common-spar Benjamin Romer
                   ` (33 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Move last three files out of common-spar

iochannel.h --> include (will be used by visorhba and visornic)
version.h --> moved to include
controlvmcompletionstatus.h --> moved to visorbus, part of
		controlvmchannel.h

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 .../common-spar/include/channels/iochannel.h       | 651 ---------------------
 .../include/controlvmcompletionstatus.h            |  94 ---
 .../staging/unisys/common-spar/include/version.h   |  45 --
 drivers/staging/unisys/include/iochannel.h         | 651 +++++++++++++++++++++
 drivers/staging/unisys/include/version.h           |  45 ++
 .../unisys/visorbus/controlvmcompletionstatus.h    |  94 +++
 6 files changed, 790 insertions(+), 790 deletions(-)
 delete mode 100644 drivers/staging/unisys/common-spar/include/channels/iochannel.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
 delete mode 100644 drivers/staging/unisys/common-spar/include/version.h
 create mode 100644 drivers/staging/unisys/include/iochannel.h
 create mode 100644 drivers/staging/unisys/include/version.h
 create mode 100644 drivers/staging/unisys/visorbus/controlvmcompletionstatus.h

diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h
deleted file mode 100644
index cbb5875..0000000
--- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h
+++ /dev/null
@@ -1,651 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION */
-/* All rights reserved. */
-#ifndef __IOCHANNEL_H__
-#define __IOCHANNEL_H__
-
-/*
- * Everything needed for IOPart-GuestPart communication is define in
- * this file.  Note: Everything is OS-independent because this file is
- * used by Windows, Linux and possible EFI drivers.  */
-
-/*
- * Communication flow between the IOPart and GuestPart uses the channel headers
- * channel state.  The following states are currently being used:
- *       UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
- *
- * additional states will be used later.  No locking is needed to switch between
- * states due to the following rules:
- *
- *      1.  IOPart is only the only partition allowed to change from UNIT
- *      2.  IOPart is only the only partition allowed to change from
- *		CHANNEL_ATTACHING
- *      3.  GuestPart is only the only partition allowed to change from
- *		CHANNEL_ATTACHED
- *
- * The state changes are the following: IOPart sees the channel is in UNINIT,
- *        UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
- *        CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
- *        CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
- */
-
-#include <linux/uuid.h>
-
-#include "vmcallinterface.h"
-
-#define _ULTRA_CONTROLVM_CHANNEL_INLINE_
-#include <linux/dma-direction.h>
-#include "controlvmchannel.h"
-#include "vbuschannel.h"
-#undef _ULTRA_CONTROLVM_CHANNEL_INLINE_
-#include "channel.h"
-#include "channel_guid.h"
-
-#define ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-#define ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE \
-	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-
-/* Must increment these whenever you insert or delete fields within this channel
- * struct.  Also increment whenever you change the meaning of fields within this
- * channel struct so as to break pre-existing software.  Note that you can
- * usually add fields to the END of the channel struct withOUT needing to
- * increment this.
- */
-#define ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID 2
-#define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
-#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
-
-#define SPAR_VHBA_CHANNEL_OK_CLIENT(ch)			\
-	(spar_check_channel_client(ch, spar_vhba_channel_protocol_uuid, \
-				   "vhba", MIN_IO_CHANNEL_SIZE,	\
-				   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
-				   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
-
-#define SPAR_VNIC_CHANNEL_OK_CLIENT(ch)			\
-	(spar_check_channel_client(ch, spar_vnic_channel_protocol_uuid, \
-				   "vnic", MIN_IO_CHANNEL_SIZE,	\
-				   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
-				   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
-
-/*
- * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
- * IO Partition is defined below.
- */
-
-/*
- * Defines and enums.
- */
-
-#define MINNUM(a, b) (((a) < (b)) ? (a) : (b))
-#define MAXNUM(a, b) (((a) > (b)) ? (a) : (b))
-
-/* these define the two queues per data channel between iopart and
- * ioguestparts
- */
-#define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to
-			    * iopart */
-
-#define IOCHAN_FROM_IOPART 1 /* used by ioguestpart to 'remove' signals from
-			      * iopart - same queue as previous queue */
-
-/* size of cdb - i.e., scsi cmnd */
-#define MAX_CMND_SIZE 16
-
-#define MAX_SENSE_SIZE 64
-
-#define MAX_PHYS_INFO 64
-
-/* various types of network packets that can be sent in cmdrsp */
-enum net_types {
-	NET_RCV_POST = 0,	/* submit buffer to hold receiving
-				 * incoming packet */
-	/* virtnic -> uisnic */
-	NET_RCV,		/* incoming packet received */
-	/* uisnic -> virtpci */
-	NET_XMIT,		/* for outgoing net packets      */
-	/* virtnic -> uisnic */
-	NET_XMIT_DONE,		/* outgoing packet xmitted */
-	/* uisnic -> virtpci */
-	NET_RCV_ENBDIS,		/* enable/disable packet reception */
-	/* virtnic -> uisnic */
-	NET_RCV_ENBDIS_ACK,	/* acknowledge enable/disable packet
-				 * reception */
-	/* uisnic -> virtnic */
-	NET_RCV_PROMISC,	/* enable/disable promiscuous mode */
-	/* virtnic -> uisnic */
-	NET_CONNECT_STATUS,	/* indicate the loss or restoration of a network
-				 * connection */
-	/* uisnic -> virtnic */
-	NET_MACADDR,		/* indicates the client has requested to update
-				 * its MAC addr */
-	NET_MACADDR_ACK,	/* MAC address */
-
-};
-
-#define		ETH_HEADER_SIZE 14	/* size of ethernet header */
-
-#define		ETH_MIN_DATA_SIZE 46	/* minimum eth data size */
-#define		ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE)
-
-#define		ETH_MAX_MTU 16384	/* maximum data size */
-
-#ifndef MAX_MACADDR_LEN
-#define MAX_MACADDR_LEN 6	/* number of bytes in MAC address */
-#endif				/* MAX_MACADDR_LEN */
-
-/* various types of scsi task mgmt commands  */
-enum task_mgmt_types {
-	TASK_MGMT_ABORT_TASK = 1,
-	TASK_MGMT_BUS_RESET,
-	TASK_MGMT_LUN_RESET,
-	TASK_MGMT_TARGET_RESET,
-};
-
-/* various types of vdisk mgmt commands  */
-enum vdisk_mgmt_types {
-	VDISK_MGMT_ACQUIRE = 1,
-	VDISK_MGMT_RELEASE,
-};
-
-/* structs with pragma pack  */
-
-/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
-/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
-
-#pragma pack(push, 1)
-
-struct guest_phys_info {
-	u64 address;
-	u64 length;
-};
-
-#define GPI_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(struct guest_phys_info))
-
-struct uisscsi_dest {
-	u32 channel;		/* channel == bus number */
-	u32 id;			/* id == target number */
-	u32 lun;		/* lun == logical unit number */
-};
-
-struct vhba_wwnn {
-	u32 wwnn1;
-	u32 wwnn2;
-};
-
-/* WARNING: Values stired in this structure must contain maximum counts (not
- * maximum values). */
-struct vhba_config_max {	/* 20 bytes */
-	u32 max_channel;	/* maximum channel for devices attached to this
-				 * bus */
-	u32 max_id;		/* maximum SCSI ID for devices attached to this
-				 * bus */
-	u32 max_lun;		/* maximum SCSI LUN for devices attached to this
-				 * bus */
-	u32 cmd_per_lun;	/* maximum number of outstanding commands per
-				 * lun that are allowed at one time */
-	u32 max_io_size;	/* maximum io size for devices attached to this
-				 * bus */
-	/* max io size is often determined by the resource of the hba. e.g */
-	/* max scatter gather list length * page size / sector size */
-};
-
-struct uiscmdrsp_scsi {
-	void *scsicmd;		/* the handle to the cmd that was received -
-				 * send it back as is in the rsp packet.  */
-	u8 cmnd[MAX_CMND_SIZE];	/* the cdb for the command */
-	u32 bufflen;		/* length of data to be transferred out or in */
-	u16 guest_phys_entries;	/* Number of entries in scatter-gather (sg)
-				 * list */
-	struct guest_phys_info gpi_list[MAX_PHYS_INFO];	/* physical address
-							 * information for each
-							 * fragment */
-	enum dma_data_direction  data_dir; /* direction of the data, if any */
-	struct uisscsi_dest vdest;	/* identifies the virtual hba, id,
-					 * channel, lun to which cmd was sent */
-
-	    /* the following fields are needed to queue the rsp back to cmd
-	     * originator */
-	int linuxstat;		/* the original Linux status - for use by linux
-				 * vdisk code */
-	u8 scsistat;		/* the scsi status */
-	u8 addlstat;		/* non-scsi status - covers cases like timeout
-				 * needed by windows guests */
-#define ADDL_SEL_TIMEOUT	4
-
-	/* the following fields are need to determine the result of command */
-	 u8 sensebuf[MAX_SENSE_SIZE];	/* sense info in case cmd failed; */
-	/* it holds the sense_data struct; */
-	/* see that struct for details. */
-	void *vdisk; /* contains pointer to the vdisk so that we can clean up
-		      * when the IO completes. */
-	int no_disk_result;
-	/* used to return no disk inquiry result
-	 * when no_disk_result is set to 1,
-	 * scsi.scsistat is SAM_STAT_GOOD
-	 * scsi.addlstat is 0
-	 * scsi.linuxstat is SAM_STAT_GOOD
-	 * That is, there is NO error.
-	 */
-};
-
-/* Defines to support sending correct inquiry result when no disk is
- * configured.
- */
-
-/* From SCSI SPC2 -
- *
- * If the target is not capable of supporting a device on this logical unit, the
- * device server shall set this field to 7Fh (PERIPHERAL QUALIFIER set to 011b
- * and PERIPHERAL DEVICE TYPE set to 1Fh).
- *
- *The device server is capable of supporting the specified peripheral device
- *type on this logical unit. However, the physical device is not currently
- *connected to this logical unit.
- */
-
-#define DEV_NOT_CAPABLE 0x7f	/* peripheral qualifier of 0x3  */
-				/* peripheral type of 0x1f */
-				/* specifies no device but target present */
-
-#define DEV_DISK_CAPABLE_NOT_PRESENT 0x20 /* peripheral qualifier of 0x1 */
-    /* peripheral type of 0 - disk */
-    /* specifies device capable, but not present */
-
-#define DEV_HISUPPORT 0x10	/* HiSup = 1; shows support for report luns */
-				/* must be returned for lun 0. */
-
-/* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
- * in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
- * & revision.  Yikes! So let us always send back 36 bytes, the minimum for
- * inquiry result.
- */
-#define NO_DISK_INQUIRY_RESULT_LEN 36
-
-#define MIN_INQUIRY_RESULT_LEN 5 /* we need at least 5 bytes minimum for inquiry
-				  * result */
-
-/* SCSI device version for no disk inquiry result */
-#define SCSI_SPC2_VER 4		/* indicates SCSI SPC2 (SPC3 is 5) */
-
-/* Windows and Linux want different things for a non-existent lun. So, we'll let
- * caller pass in the peripheral qualifier and type.
- * NOTE:[4] SCSI returns (n-4); so we return length-1-4 or length-5. */
-
-#define SET_NO_DISK_INQUIRY_RESULT(buf, len, lun, lun0notpresent, notpresent) \
-	do {								\
-		memset(buf, 0,						\
-		       MINNUM(len,					\
-			      (unsigned int)NO_DISK_INQUIRY_RESULT_LEN)); \
-		buf[2] = (u8)SCSI_SPC2_VER;				\
-		if (lun == 0) {						\
-			buf[0] = (u8)lun0notpresent;			\
-			buf[3] = (u8)DEV_HISUPPORT;			\
-		} else							\
-			buf[0] = (u8)notpresent;			\
-		buf[4] = (u8)(						\
-			MINNUM(len,					\
-			       (unsigned int)NO_DISK_INQUIRY_RESULT_LEN) - 5);\
-		if (len >= NO_DISK_INQUIRY_RESULT_LEN) {		\
-			buf[8] = 'D';					\
-			buf[9] = 'E';					\
-			buf[10] = 'L';					\
-			buf[11] = 'L';					\
-			buf[16] = 'P';					\
-			buf[17] = 'S';					\
-			buf[18] = 'E';					\
-			buf[19] = 'U';					\
-			buf[20] = 'D';					\
-			buf[21] = 'O';					\
-			buf[22] = ' ';					\
-			buf[23] = 'D';					\
-			buf[24] = 'E';					\
-			buf[25] = 'V';					\
-			buf[26] = 'I';					\
-			buf[27] = 'C';					\
-			buf[28] = 'E';					\
-			buf[30] = ' ';					\
-			buf[31] = '.';					\
-		}							\
-	} while (0)
-
-/*
- * Struct & Defines to support sense information.
- */
-
-/* The following struct is returned in sensebuf field in uiscmdrsp_scsi.  It is
- * initialized in exactly the manner that is recommended in Windows (hence the
- * odd values).
- * When set, these fields will have the following values:
- * ErrorCode = 0x70		indicates current error
- * Valid = 1			indicates sense info is valid
- * SenseKey			contains sense key as defined by SCSI specs.
- * AdditionalSenseCode		contains sense key as defined by SCSI specs.
- * AdditionalSenseCodeQualifier	contains qualifier to sense code as defined by
- *				scsi docs.
- * AdditionalSenseLength	contains will be sizeof(sense_data)-8=10.
- */
-struct sense_data {
-	u8 errorcode:7;
-	u8 valid:1;
-	u8 segment_number;
-	u8 sense_key:4;
-	u8 reserved:1;
-	u8 incorrect_length:1;
-	u8 end_of_media:1;
-	u8 file_mark:1;
-	u8 information[4];
-	u8 additional_sense_length;
-	u8 command_specific_information[4];
-	u8 additional_sense_code;
-	u8 additional_sense_code_qualifier;
-	u8 fru_code;
-	u8 sense_key_specific[3];
-};
-
-struct net_pkt_xmt {
-	int len;	/* full length of data in the packet */
-	int num_frags;	/* number of fragments in frags containing data */
-	struct phys_info frags[MAX_PHYS_INFO];	/* physical page information for
-						 * each fragment */
-	char ethhdr[ETH_HEADER_SIZE];	/* the ethernet header  */
-	struct {
-		    /* these are needed for csum at uisnic end */
-		u8 valid;	/* 1 = rest of this struct is valid - else
-				 * ignore */
-		u8 hrawoffv;	/* 1 = hwrafoff is valid */
-		u8 nhrawoffv;	/* 1 = nhwrafoff is valid */
-		u16 protocol;	/* specifies packet protocol */
-		u32 csum;	/* value used to set skb->csum at IOPart */
-		u32 hrawoff;	/* value used to set skb->h.raw at IOPart */
-		/* hrawoff points to the start of the TRANSPORT LAYER HEADER */
-		u32 nhrawoff;	/* value used to set skb->nh.raw at IOPart */
-		/* nhrawoff points to the start of the NETWORK LAYER HEADER */
-	} lincsum;
-
-	    /* **** NOTE ****
-	     * The full packet is described in frags but the ethernet header is
-	     * separately kept in ethhdr so that uisnic doesn't have "MAP" the
-	     * guest memory to get to the header. uisnic needs ethhdr to
-	     * determine how to route the packet.
-	     */
-};
-
-struct net_pkt_xmtdone {
-	u32 xmt_done_result;	/* result of NET_XMIT */
-};
-
-/* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The
- * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
- * virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I
- * prefer to use 1 full cache line size for "overhead" so that transfers are
- * better.  IOVM requires that a buffer be represented by 1 phys_info structure
- * which can only cover page_size.
- */
-#define RCVPOST_BUF_SIZE 4032
-#define MAX_NET_RCV_CHAIN \
-	((ETH_MAX_MTU+ETH_HEADER_SIZE + RCVPOST_BUF_SIZE-1) / RCVPOST_BUF_SIZE)
-
-struct net_pkt_rcvpost {
-	    /* rcv buf size must be large enough to include ethernet data len +
-	     * ethernet header len - we are choosing 2K because it is guaranteed
-	     * to be describable */
-	    struct phys_info frag;	/* physical page information for the
-					 * single fragment 2K rcv buf */
-	    u64 unique_num;		/* This is used to make sure that
-					 * receive posts are returned to  */
-	    /* the Adapter which we sent them originally. */
-};
-
-struct net_pkt_rcv {
-	/* the number of receive buffers that can be chained  */
-	/* is based on max mtu and size of each rcv buf */
-	u32 rcv_done_len;	/* length of received data */
-	u8 numrcvbufs;		/* number of receive buffers that contain the */
-	/* incoming data; guest end MUST chain these together. */
-	void *rcvbuf[MAX_NET_RCV_CHAIN];	/* the list of receive buffers
-						 * that must be chained; */
-	/* each entry is a receive buffer provided by NET_RCV_POST. */
-	/* NOTE: first rcvbuf in the chain will also be provided in net.buf. */
-	u64 unique_num;
-	u32 rcvs_dropped_delta;
-};
-
-struct net_pkt_enbdis {
-	void *context;
-	u16 enable;		/* 1 = enable, 0 = disable */
-};
-
-struct net_pkt_macaddr {
-	void *context;
-	u8 macaddr[MAX_MACADDR_LEN];	/* 6 bytes */
-};
-
-/* cmd rsp packet used for VNIC network traffic  */
-struct uiscmdrsp_net {
-	enum net_types type;
-	void *buf;
-	union {
-		struct net_pkt_xmt xmt;		/* used for NET_XMIT */
-		struct net_pkt_xmtdone xmtdone;	/* used for NET_XMIT_DONE */
-		struct net_pkt_rcvpost rcvpost;	/* used for NET_RCV_POST */
-		struct net_pkt_rcv rcv;		/* used for NET_RCV */
-		struct net_pkt_enbdis enbdis;	/* used for NET_RCV_ENBDIS, */
-						/* NET_RCV_ENBDIS_ACK,  */
-						/* NET_RCV_PROMSIC, */
-						/* and NET_CONNECT_STATUS */
-		struct net_pkt_macaddr macaddr;
-	};
-};
-
-struct uiscmdrsp_scsitaskmgmt {
-	enum task_mgmt_types tasktype;
-
-	    /* the type of task */
-	struct uisscsi_dest vdest;
-
-	    /* the vdisk for which this task mgmt is generated */
-	void *scsicmd;
-
-	    /* This is some handle that the guest has saved off for its own use.
-	     * Its value is preserved by iopart & returned as is in the task
-	     * mgmt rsp.
-	     */
-	void *notify;
-
-	   /* For linux guests, this is a pointer to wait_queue_head that a
-	    * thread is waiting on to see if the taskmgmt command has completed.
-	    * For windows guests, this is a pointer to a location that a waiting
-	    * thread is testing to see if the taskmgmt command has completed.
-	    * When the rsp is received by guest, the thread receiving the
-	    * response uses this to notify the thread waiting for taskmgmt
-	    * command completion.  Its value is preserved by iopart & returned
-	    * as is in the task mgmt rsp.
-	    */
-	void *notifyresult;
-
-	    /* this is a handle to location in guest where the result of the
-	     * taskmgmt command (result field) is to saved off when the response
-	     * is handled.  Its value is preserved by iopart & returned as is in
-	     * the task mgmt rsp.
-	     */
-	char result;
-
-	    /* result of taskmgmt command - set by IOPart - values are: */
-#define TASK_MGMT_FAILED  0
-};
-
-/* The following is used by uissd to send disk add/remove notifications to
- * Guest */
-/* Note that the vHba pointer is not used by the Client/Guest side. */
-struct uiscmdrsp_disknotify {
-	u8 add;			/* 0-remove, 1-add */
-	void *v_hba;		/* Pointer to vhba_info for channel info to
-				 * route msg */
-	u32 channel, id, lun;	/* SCSI Path of Disk to added or removed */
-};
-
-/* The following is used by virthba/vSCSI to send the Acquire/Release commands
- * to the IOVM. */
-struct uiscmdrsp_vdiskmgmt {
-	enum vdisk_mgmt_types vdisktype;
-
-	    /* the type of task */
-	struct uisscsi_dest vdest;
-
-	    /* the vdisk for which this task mgmt is generated */
-	void *scsicmd;
-
-	    /* This is some handle that the guest has saved off for its own use.
-	     * Its value is preserved by iopart & returned as is in the task
-	     * mgmt rsp.
-	     */
-	void *notify;
-
-	    /* For linux guests, this is a pointer to wait_queue_head that a
-	     * thread is waiting on to see if the tskmgmt command has completed.
-	     * For win32 guests, this is a pointer to a location that a waiting
-	     * thread is testing to see if the taskmgmt command has completed.
-	     * When the rsp is received by guest, the thread receiving the
-	     * response uses this to notify the thread waiting for taskmgmt
-	     * command completion.  Its value is preserved by iopart & returned
-	     * as is in the task mgmt rsp.
-	     */
-	void *notifyresult;
-
-	    /* this is a handle to location in guest where the result of the
-	     * taskmgmt command (result field) is to saved off when the response
-	     * is handled.  Its value is preserved by iopart & returned as is in
-	     * the task mgmt rsp.
-	     */
-	char result;
-
-	    /* result of taskmgmt command - set by IOPart - values are: */
-#define VDISK_MGMT_FAILED  0
-};
-
-/* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */
-struct uiscmdrsp {
-	char cmdtype;
-
-/* describes what type of information is in the struct */
-#define CMD_SCSI_TYPE		1
-#define CMD_NET_TYPE		2
-#define CMD_SCSITASKMGMT_TYPE	3
-#define CMD_NOTIFYGUEST_TYPE	4
-#define CMD_VDISKMGMT_TYPE	5
-	union {
-		struct uiscmdrsp_scsi scsi;
-		struct uiscmdrsp_net net;
-		struct uiscmdrsp_scsitaskmgmt scsitaskmgmt;
-		struct uiscmdrsp_disknotify disknotify;
-		struct uiscmdrsp_vdiskmgmt vdiskmgmt;
-	};
-	void *private_data;	/* used to send the response when the cmd is
-				 * done (scsi & scsittaskmgmt). */
-	struct uiscmdrsp *next;	/* General Purpose Queue Link */
-	struct uiscmdrsp *activeQ_next;	/* Used to track active commands */
-	struct uiscmdrsp *activeQ_prev;	/* Used to track active commands */
-};
-
-/* This is just the header of the IO channel.  It is assumed that directly after
- * this header there is a large region of memory which contains the command and
- * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS.
- */
-struct spar_io_channel_protocol {
-	struct channel_header channel_header;
-	struct signal_queue_header cmd_q;
-	struct signal_queue_header rsp_q;
-	union {
-		struct {
-			struct vhba_wwnn wwnn;		/* 8 bytes */
-			struct vhba_config_max max;	/* 20 bytes */
-		} vhba;					/* total = 28 bytes */
-		struct {
-			u8 macaddr[MAX_MACADDR_LEN];	/* 6 bytes */
-			u32 num_rcv_bufs;		/* 4 bytes */
-			u32 mtu;			/* 4 bytes */
-			uuid_le zone_uuid;		/* 16 bytes */
-		} vnic;					/* total = 30 bytes */
-	};
-
-#define MAX_CLIENTSTRING_LEN 1024
-	 u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds
-						 * max - 1 bytes */
-};
-
-#pragma pack(pop)
-/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-
-/*
- * INLINE functions for initializing and accessing I/O data channels
- */
-
-#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
-#define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
-
-#define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \
-				  2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
-
-/*
- * INLINE function for expanding a guest's pfn-off-size into multiple 4K page
- * pfn-off-size entires.
- */
-
-/* we deal with 4K page sizes when we it comes to passing page information
- * between */
-/* Guest and IOPartition. */
-#define PI_PAGE_SIZE  0x1000
-#define PI_PAGE_MASK  0x0FFF
-
-/* returns next non-zero index on success or zero on failure (i.e. out of
- * room)
- */
-static inline  u16
-add_physinfo_entries(u32 inp_pfn,	/* input - specifies the pfn to be used
-					 * to add entries */
-		     u16 inp_off,	/* input - specifies the off to be used
-					 * to add entries */
-		     u32 inp_len,	/* input - specifies the len to be used
-					 * to add entries */
-		     u16 index,		/* input - index in array at which new
-					 * entries are added */
-		     u16 max_pi_arr_entries,	/* input - specifies the maximum
-						 * entries pi_arr can hold */
-		     struct phys_info pi_arr[]) /* input & output - array to
-						  * which entries are added */
-{
-	u32 len;
-	u16 i, firstlen;
-
-	firstlen = PI_PAGE_SIZE - inp_off;
-	if (inp_len <= firstlen) {
-		/* the input entry spans only one page - add as is */
-		if (index >= max_pi_arr_entries)
-			return 0;
-		pi_arr[index].pi_pfn = inp_pfn;
-		pi_arr[index].pi_off = (u16)inp_off;
-		pi_arr[index].pi_len = (u16)inp_len;
-		    return index + 1;
-	}
-
-	    /* this entry spans multiple pages */
-	    for (len = inp_len, i = 0; len;
-		 len -= pi_arr[index + i].pi_len, i++) {
-		if (index + i >= max_pi_arr_entries)
-			return 0;
-		pi_arr[index + i].pi_pfn = inp_pfn + i;
-		if (i == 0) {
-			pi_arr[index].pi_off = inp_off;
-			pi_arr[index].pi_len = firstlen;
-		}
-
-		else {
-			pi_arr[index + i].pi_off = 0;
-			pi_arr[index + i].pi_len =
-			    (u16)MINNUM(len, (u32)PI_PAGE_SIZE);
-		}
-	}
-	return index + i;
-}
-
-#endif				/* __IOCHANNEL_H__ */
diff --git a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h b/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
deleted file mode 100644
index f74f5d8..0000000
--- a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* controlvmcompletionstatus.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*  Defines for all valid values returned in the response message header
- *  completionStatus field.  See controlvmchannel.h for description of
- *  the header: _CONTROLVM_MESSAGE_HEADER.
- */
-
-#ifndef __CONTROLVMCOMPLETIONSTATUS_H__
-#define __CONTROLVMCOMPLETIONSTATUS_H__
-
-/* General Errors------------------------------------------------------[0-99] */
-#define CONTROLVM_RESP_SUCCESS                                  0
-#define CONTROLVM_RESP_ERROR_ALREADY_DONE                       1
-#define CONTROLVM_RESP_ERROR_IOREMAP_FAILED                     2
-#define CONTROLVM_RESP_ERROR_KMALLOC_FAILED                     3
-#define CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN                 4
-#define CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT      5
-
-/* CONTROLVM_INIT_CHIPSET-------------------------------------------[100-199] */
-#define CONTROLVM_RESP_ERROR_CLIENT_SWITCHCOUNT_NONZERO         100
-#define CONTROLVM_RESP_ERROR_EXPECTED_CHIPSET_INIT              101
-
-/* Maximum Limit----------------------------------------------------[200-299] */
-#define CONTROLVM_RESP_ERROR_MAX_BUSES		201	/* BUS_CREATE */
-#define CONTROLVM_RESP_ERROR_MAX_DEVICES        202	/* DEVICE_CREATE */
-/* Payload and Parameter Related------------------------------------[400-499] */
-#define CONTROLVM_RESP_ERROR_PAYLOAD_INVALID	400	/* SWITCH_ATTACHEXTPORT,
-							 * DEVICE_CONFIGURE */
-#define CONTROLVM_RESP_ERROR_INITIATOR_PARAMETER_INVALID 401	/* Multiple */
-#define CONTROLVM_RESP_ERROR_TARGET_PARAMETER_INVALID 402 /* DEVICE_CONFIGURE */
-#define CONTROLVM_RESP_ERROR_CLIENT_PARAMETER_INVALID 403 /* DEVICE_CONFIGURE */
-/* Specified[Packet Structure] Value-------------------------------[500-599] */
-#define CONTROLVM_RESP_ERROR_BUS_INVALID	500	/* SWITCH_ATTACHINTPORT,
-							 * BUS_CONFIGURE,
-							 * DEVICE_CREATE,
-							 * DEVICE_CONFIG
-							 * DEVICE_DESTROY */
-#define CONTROLVM_RESP_ERROR_DEVICE_INVALID	501 /* SWITCH_ATTACHINTPORT */
-						    /* DEVICE_CREATE,
-						     * DEVICE_CONFIGURE,
-						     * DEVICE_DESTROY */
-#define CONTROLVM_RESP_ERROR_CHANNEL_INVALID	502 /* DEVICE_CREATE,
-						     * DEVICE_CONFIGURE */
-/* Partition Driver Callback Interface----------------------[600-699] */
-#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE 604	/* BUS_CREATE,
-							 * BUS_DESTROY,
-							 * DEVICE_CREATE,
-							 * DEVICE_DESTROY */
-/* Unable to invoke VIRTPCI callback */
-#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR 605
-							/* BUS_CREATE,
-							 * BUS_DESTROY,
-							 * DEVICE_CREATE,
-							 * DEVICE_DESTROY */
-/* VIRTPCI Callback returned error */
-#define CONTROLVM_RESP_ERROR_GENERIC_DRIVER_CALLBACK_ERROR 606
-							/* SWITCH_ATTACHEXTPORT,
-							 * SWITCH_DETACHEXTPORT
-							 * DEVICE_CONFIGURE */
-
-/* generic device callback returned error */
-/* Bus Related------------------------------------------------------[700-799] */
-#define CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED 700	/* BUS_DESTROY */
-/* Channel Related--------------------------------------------------[800-899] */
-#define CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN 800	/* GET_CHANNELINFO,
-							 * DEVICE_DESTROY */
-#define CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL 801	/* DEVICE_CREATE */
-/* Chipset Shutdown Related---------------------------------------[1000-1099] */
-#define CONTROLVM_RESP_ERROR_CHIPSET_SHUTDOWN_FAILED            1000
-#define CONTROLVM_RESP_ERROR_CHIPSET_SHUTDOWN_ALREADY_ACTIVE    1001
-
-/* Chipset Stop Related-------------------------------------------[1100-1199] */
-#define CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS            1100
-#define CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_SWITCH         1101
-
-/* Device Related-------------------------------------------------[1400-1499] */
-#define CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT                1400
-
-#endif /* __CONTROLVMCOMPLETIONSTATUS_H__ not defined */
diff --git a/drivers/staging/unisys/common-spar/include/version.h b/drivers/staging/unisys/common-spar/include/version.h
deleted file mode 100644
index 83d1da7..0000000
--- a/drivers/staging/unisys/common-spar/include/version.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* version.h */
-
-/*  Common version/release info needed by all components goes here.
- *  (This file must compile cleanly in all environments.)
- *  Ultimately, this will be combined with defines generated dynamically as
- *  part of the sysgen, and some of the defines below may in fact end up
- *  being replaced with dynamically generated ones.
- */
-#ifndef __VERSION_H__
-#define __VERSION_H__
-
-#define SPARVER1 "1"
-#define SPARVER2 "0"
-#define SPARVER3 "0"
-#define SPARVER4 "0"
-
-#define  VERSION        SPARVER1 "." SPARVER2 "." SPARVER3 "." SPARVER4
-
-/* Here are various version forms needed in Windows environments.
- */
-#define VISOR_PRODUCTVERSION      SPARVERCOMMA
-#define VISOR_PRODUCTVERSION_STR  SPARVER1 "." SPARVER2 "." SPARVER3 "." \
-	SPARVER4
-#define VISOR_OBJECTVERSION_STR   SPARVER1 "," SPARVER2 "," SPARVER3 "," \
-	SPARVER4
-
-#define  COPYRIGHT      "Unisys Corporation"
-#define  COPYRIGHTDATE  "2010 - 2013"
-
-#endif
diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h
new file mode 100644
index 0000000..cbb5875
--- /dev/null
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -0,0 +1,651 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION */
+/* All rights reserved. */
+#ifndef __IOCHANNEL_H__
+#define __IOCHANNEL_H__
+
+/*
+ * Everything needed for IOPart-GuestPart communication is define in
+ * this file.  Note: Everything is OS-independent because this file is
+ * used by Windows, Linux and possible EFI drivers.  */
+
+/*
+ * Communication flow between the IOPart and GuestPart uses the channel headers
+ * channel state.  The following states are currently being used:
+ *       UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
+ *
+ * additional states will be used later.  No locking is needed to switch between
+ * states due to the following rules:
+ *
+ *      1.  IOPart is only the only partition allowed to change from UNIT
+ *      2.  IOPart is only the only partition allowed to change from
+ *		CHANNEL_ATTACHING
+ *      3.  GuestPart is only the only partition allowed to change from
+ *		CHANNEL_ATTACHED
+ *
+ * The state changes are the following: IOPart sees the channel is in UNINIT,
+ *        UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
+ *        CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
+ *        CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
+ */
+
+#include <linux/uuid.h>
+
+#include "vmcallinterface.h"
+
+#define _ULTRA_CONTROLVM_CHANNEL_INLINE_
+#include <linux/dma-direction.h>
+#include "controlvmchannel.h"
+#include "vbuschannel.h"
+#undef _ULTRA_CONTROLVM_CHANNEL_INLINE_
+#include "channel.h"
+#include "channel_guid.h"
+
+#define ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+#define ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE \
+	ULTRA_CHANNEL_PROTOCOL_SIGNATURE
+
+/* Must increment these whenever you insert or delete fields within this channel
+ * struct.  Also increment whenever you change the meaning of fields within this
+ * channel struct so as to break pre-existing software.  Note that you can
+ * usually add fields to the END of the channel struct withOUT needing to
+ * increment this.
+ */
+#define ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID 2
+#define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
+#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
+
+#define SPAR_VHBA_CHANNEL_OK_CLIENT(ch)			\
+	(spar_check_channel_client(ch, spar_vhba_channel_protocol_uuid, \
+				   "vhba", MIN_IO_CHANNEL_SIZE,	\
+				   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
+				   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+
+#define SPAR_VNIC_CHANNEL_OK_CLIENT(ch)			\
+	(spar_check_channel_client(ch, spar_vnic_channel_protocol_uuid, \
+				   "vnic", MIN_IO_CHANNEL_SIZE,	\
+				   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
+				   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
+
+/*
+ * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
+ * IO Partition is defined below.
+ */
+
+/*
+ * Defines and enums.
+ */
+
+#define MINNUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXNUM(a, b) (((a) > (b)) ? (a) : (b))
+
+/* these define the two queues per data channel between iopart and
+ * ioguestparts
+ */
+#define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to
+			    * iopart */
+
+#define IOCHAN_FROM_IOPART 1 /* used by ioguestpart to 'remove' signals from
+			      * iopart - same queue as previous queue */
+
+/* size of cdb - i.e., scsi cmnd */
+#define MAX_CMND_SIZE 16
+
+#define MAX_SENSE_SIZE 64
+
+#define MAX_PHYS_INFO 64
+
+/* various types of network packets that can be sent in cmdrsp */
+enum net_types {
+	NET_RCV_POST = 0,	/* submit buffer to hold receiving
+				 * incoming packet */
+	/* virtnic -> uisnic */
+	NET_RCV,		/* incoming packet received */
+	/* uisnic -> virtpci */
+	NET_XMIT,		/* for outgoing net packets      */
+	/* virtnic -> uisnic */
+	NET_XMIT_DONE,		/* outgoing packet xmitted */
+	/* uisnic -> virtpci */
+	NET_RCV_ENBDIS,		/* enable/disable packet reception */
+	/* virtnic -> uisnic */
+	NET_RCV_ENBDIS_ACK,	/* acknowledge enable/disable packet
+				 * reception */
+	/* uisnic -> virtnic */
+	NET_RCV_PROMISC,	/* enable/disable promiscuous mode */
+	/* virtnic -> uisnic */
+	NET_CONNECT_STATUS,	/* indicate the loss or restoration of a network
+				 * connection */
+	/* uisnic -> virtnic */
+	NET_MACADDR,		/* indicates the client has requested to update
+				 * its MAC addr */
+	NET_MACADDR_ACK,	/* MAC address */
+
+};
+
+#define		ETH_HEADER_SIZE 14	/* size of ethernet header */
+
+#define		ETH_MIN_DATA_SIZE 46	/* minimum eth data size */
+#define		ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE)
+
+#define		ETH_MAX_MTU 16384	/* maximum data size */
+
+#ifndef MAX_MACADDR_LEN
+#define MAX_MACADDR_LEN 6	/* number of bytes in MAC address */
+#endif				/* MAX_MACADDR_LEN */
+
+/* various types of scsi task mgmt commands  */
+enum task_mgmt_types {
+	TASK_MGMT_ABORT_TASK = 1,
+	TASK_MGMT_BUS_RESET,
+	TASK_MGMT_LUN_RESET,
+	TASK_MGMT_TARGET_RESET,
+};
+
+/* various types of vdisk mgmt commands  */
+enum vdisk_mgmt_types {
+	VDISK_MGMT_ACQUIRE = 1,
+	VDISK_MGMT_RELEASE,
+};
+
+/* structs with pragma pack  */
+
+/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
+/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
+
+#pragma pack(push, 1)
+
+struct guest_phys_info {
+	u64 address;
+	u64 length;
+};
+
+#define GPI_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(struct guest_phys_info))
+
+struct uisscsi_dest {
+	u32 channel;		/* channel == bus number */
+	u32 id;			/* id == target number */
+	u32 lun;		/* lun == logical unit number */
+};
+
+struct vhba_wwnn {
+	u32 wwnn1;
+	u32 wwnn2;
+};
+
+/* WARNING: Values stired in this structure must contain maximum counts (not
+ * maximum values). */
+struct vhba_config_max {	/* 20 bytes */
+	u32 max_channel;	/* maximum channel for devices attached to this
+				 * bus */
+	u32 max_id;		/* maximum SCSI ID for devices attached to this
+				 * bus */
+	u32 max_lun;		/* maximum SCSI LUN for devices attached to this
+				 * bus */
+	u32 cmd_per_lun;	/* maximum number of outstanding commands per
+				 * lun that are allowed at one time */
+	u32 max_io_size;	/* maximum io size for devices attached to this
+				 * bus */
+	/* max io size is often determined by the resource of the hba. e.g */
+	/* max scatter gather list length * page size / sector size */
+};
+
+struct uiscmdrsp_scsi {
+	void *scsicmd;		/* the handle to the cmd that was received -
+				 * send it back as is in the rsp packet.  */
+	u8 cmnd[MAX_CMND_SIZE];	/* the cdb for the command */
+	u32 bufflen;		/* length of data to be transferred out or in */
+	u16 guest_phys_entries;	/* Number of entries in scatter-gather (sg)
+				 * list */
+	struct guest_phys_info gpi_list[MAX_PHYS_INFO];	/* physical address
+							 * information for each
+							 * fragment */
+	enum dma_data_direction  data_dir; /* direction of the data, if any */
+	struct uisscsi_dest vdest;	/* identifies the virtual hba, id,
+					 * channel, lun to which cmd was sent */
+
+	    /* the following fields are needed to queue the rsp back to cmd
+	     * originator */
+	int linuxstat;		/* the original Linux status - for use by linux
+				 * vdisk code */
+	u8 scsistat;		/* the scsi status */
+	u8 addlstat;		/* non-scsi status - covers cases like timeout
+				 * needed by windows guests */
+#define ADDL_SEL_TIMEOUT	4
+
+	/* the following fields are need to determine the result of command */
+	 u8 sensebuf[MAX_SENSE_SIZE];	/* sense info in case cmd failed; */
+	/* it holds the sense_data struct; */
+	/* see that struct for details. */
+	void *vdisk; /* contains pointer to the vdisk so that we can clean up
+		      * when the IO completes. */
+	int no_disk_result;
+	/* used to return no disk inquiry result
+	 * when no_disk_result is set to 1,
+	 * scsi.scsistat is SAM_STAT_GOOD
+	 * scsi.addlstat is 0
+	 * scsi.linuxstat is SAM_STAT_GOOD
+	 * That is, there is NO error.
+	 */
+};
+
+/* Defines to support sending correct inquiry result when no disk is
+ * configured.
+ */
+
+/* From SCSI SPC2 -
+ *
+ * If the target is not capable of supporting a device on this logical unit, the
+ * device server shall set this field to 7Fh (PERIPHERAL QUALIFIER set to 011b
+ * and PERIPHERAL DEVICE TYPE set to 1Fh).
+ *
+ *The device server is capable of supporting the specified peripheral device
+ *type on this logical unit. However, the physical device is not currently
+ *connected to this logical unit.
+ */
+
+#define DEV_NOT_CAPABLE 0x7f	/* peripheral qualifier of 0x3  */
+				/* peripheral type of 0x1f */
+				/* specifies no device but target present */
+
+#define DEV_DISK_CAPABLE_NOT_PRESENT 0x20 /* peripheral qualifier of 0x1 */
+    /* peripheral type of 0 - disk */
+    /* specifies device capable, but not present */
+
+#define DEV_HISUPPORT 0x10	/* HiSup = 1; shows support for report luns */
+				/* must be returned for lun 0. */
+
+/* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
+ * in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
+ * & revision.  Yikes! So let us always send back 36 bytes, the minimum for
+ * inquiry result.
+ */
+#define NO_DISK_INQUIRY_RESULT_LEN 36
+
+#define MIN_INQUIRY_RESULT_LEN 5 /* we need at least 5 bytes minimum for inquiry
+				  * result */
+
+/* SCSI device version for no disk inquiry result */
+#define SCSI_SPC2_VER 4		/* indicates SCSI SPC2 (SPC3 is 5) */
+
+/* Windows and Linux want different things for a non-existent lun. So, we'll let
+ * caller pass in the peripheral qualifier and type.
+ * NOTE:[4] SCSI returns (n-4); so we return length-1-4 or length-5. */
+
+#define SET_NO_DISK_INQUIRY_RESULT(buf, len, lun, lun0notpresent, notpresent) \
+	do {								\
+		memset(buf, 0,						\
+		       MINNUM(len,					\
+			      (unsigned int)NO_DISK_INQUIRY_RESULT_LEN)); \
+		buf[2] = (u8)SCSI_SPC2_VER;				\
+		if (lun == 0) {						\
+			buf[0] = (u8)lun0notpresent;			\
+			buf[3] = (u8)DEV_HISUPPORT;			\
+		} else							\
+			buf[0] = (u8)notpresent;			\
+		buf[4] = (u8)(						\
+			MINNUM(len,					\
+			       (unsigned int)NO_DISK_INQUIRY_RESULT_LEN) - 5);\
+		if (len >= NO_DISK_INQUIRY_RESULT_LEN) {		\
+			buf[8] = 'D';					\
+			buf[9] = 'E';					\
+			buf[10] = 'L';					\
+			buf[11] = 'L';					\
+			buf[16] = 'P';					\
+			buf[17] = 'S';					\
+			buf[18] = 'E';					\
+			buf[19] = 'U';					\
+			buf[20] = 'D';					\
+			buf[21] = 'O';					\
+			buf[22] = ' ';					\
+			buf[23] = 'D';					\
+			buf[24] = 'E';					\
+			buf[25] = 'V';					\
+			buf[26] = 'I';					\
+			buf[27] = 'C';					\
+			buf[28] = 'E';					\
+			buf[30] = ' ';					\
+			buf[31] = '.';					\
+		}							\
+	} while (0)
+
+/*
+ * Struct & Defines to support sense information.
+ */
+
+/* The following struct is returned in sensebuf field in uiscmdrsp_scsi.  It is
+ * initialized in exactly the manner that is recommended in Windows (hence the
+ * odd values).
+ * When set, these fields will have the following values:
+ * ErrorCode = 0x70		indicates current error
+ * Valid = 1			indicates sense info is valid
+ * SenseKey			contains sense key as defined by SCSI specs.
+ * AdditionalSenseCode		contains sense key as defined by SCSI specs.
+ * AdditionalSenseCodeQualifier	contains qualifier to sense code as defined by
+ *				scsi docs.
+ * AdditionalSenseLength	contains will be sizeof(sense_data)-8=10.
+ */
+struct sense_data {
+	u8 errorcode:7;
+	u8 valid:1;
+	u8 segment_number;
+	u8 sense_key:4;
+	u8 reserved:1;
+	u8 incorrect_length:1;
+	u8 end_of_media:1;
+	u8 file_mark:1;
+	u8 information[4];
+	u8 additional_sense_length;
+	u8 command_specific_information[4];
+	u8 additional_sense_code;
+	u8 additional_sense_code_qualifier;
+	u8 fru_code;
+	u8 sense_key_specific[3];
+};
+
+struct net_pkt_xmt {
+	int len;	/* full length of data in the packet */
+	int num_frags;	/* number of fragments in frags containing data */
+	struct phys_info frags[MAX_PHYS_INFO];	/* physical page information for
+						 * each fragment */
+	char ethhdr[ETH_HEADER_SIZE];	/* the ethernet header  */
+	struct {
+		    /* these are needed for csum at uisnic end */
+		u8 valid;	/* 1 = rest of this struct is valid - else
+				 * ignore */
+		u8 hrawoffv;	/* 1 = hwrafoff is valid */
+		u8 nhrawoffv;	/* 1 = nhwrafoff is valid */
+		u16 protocol;	/* specifies packet protocol */
+		u32 csum;	/* value used to set skb->csum at IOPart */
+		u32 hrawoff;	/* value used to set skb->h.raw at IOPart */
+		/* hrawoff points to the start of the TRANSPORT LAYER HEADER */
+		u32 nhrawoff;	/* value used to set skb->nh.raw at IOPart */
+		/* nhrawoff points to the start of the NETWORK LAYER HEADER */
+	} lincsum;
+
+	    /* **** NOTE ****
+	     * The full packet is described in frags but the ethernet header is
+	     * separately kept in ethhdr so that uisnic doesn't have "MAP" the
+	     * guest memory to get to the header. uisnic needs ethhdr to
+	     * determine how to route the packet.
+	     */
+};
+
+struct net_pkt_xmtdone {
+	u32 xmt_done_result;	/* result of NET_XMIT */
+};
+
+/* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The
+ * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
+ * virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I
+ * prefer to use 1 full cache line size for "overhead" so that transfers are
+ * better.  IOVM requires that a buffer be represented by 1 phys_info structure
+ * which can only cover page_size.
+ */
+#define RCVPOST_BUF_SIZE 4032
+#define MAX_NET_RCV_CHAIN \
+	((ETH_MAX_MTU+ETH_HEADER_SIZE + RCVPOST_BUF_SIZE-1) / RCVPOST_BUF_SIZE)
+
+struct net_pkt_rcvpost {
+	    /* rcv buf size must be large enough to include ethernet data len +
+	     * ethernet header len - we are choosing 2K because it is guaranteed
+	     * to be describable */
+	    struct phys_info frag;	/* physical page information for the
+					 * single fragment 2K rcv buf */
+	    u64 unique_num;		/* This is used to make sure that
+					 * receive posts are returned to  */
+	    /* the Adapter which we sent them originally. */
+};
+
+struct net_pkt_rcv {
+	/* the number of receive buffers that can be chained  */
+	/* is based on max mtu and size of each rcv buf */
+	u32 rcv_done_len;	/* length of received data */
+	u8 numrcvbufs;		/* number of receive buffers that contain the */
+	/* incoming data; guest end MUST chain these together. */
+	void *rcvbuf[MAX_NET_RCV_CHAIN];	/* the list of receive buffers
+						 * that must be chained; */
+	/* each entry is a receive buffer provided by NET_RCV_POST. */
+	/* NOTE: first rcvbuf in the chain will also be provided in net.buf. */
+	u64 unique_num;
+	u32 rcvs_dropped_delta;
+};
+
+struct net_pkt_enbdis {
+	void *context;
+	u16 enable;		/* 1 = enable, 0 = disable */
+};
+
+struct net_pkt_macaddr {
+	void *context;
+	u8 macaddr[MAX_MACADDR_LEN];	/* 6 bytes */
+};
+
+/* cmd rsp packet used for VNIC network traffic  */
+struct uiscmdrsp_net {
+	enum net_types type;
+	void *buf;
+	union {
+		struct net_pkt_xmt xmt;		/* used for NET_XMIT */
+		struct net_pkt_xmtdone xmtdone;	/* used for NET_XMIT_DONE */
+		struct net_pkt_rcvpost rcvpost;	/* used for NET_RCV_POST */
+		struct net_pkt_rcv rcv;		/* used for NET_RCV */
+		struct net_pkt_enbdis enbdis;	/* used for NET_RCV_ENBDIS, */
+						/* NET_RCV_ENBDIS_ACK,  */
+						/* NET_RCV_PROMSIC, */
+						/* and NET_CONNECT_STATUS */
+		struct net_pkt_macaddr macaddr;
+	};
+};
+
+struct uiscmdrsp_scsitaskmgmt {
+	enum task_mgmt_types tasktype;
+
+	    /* the type of task */
+	struct uisscsi_dest vdest;
+
+	    /* the vdisk for which this task mgmt is generated */
+	void *scsicmd;
+
+	    /* This is some handle that the guest has saved off for its own use.
+	     * Its value is preserved by iopart & returned as is in the task
+	     * mgmt rsp.
+	     */
+	void *notify;
+
+	   /* For linux guests, this is a pointer to wait_queue_head that a
+	    * thread is waiting on to see if the taskmgmt command has completed.
+	    * For windows guests, this is a pointer to a location that a waiting
+	    * thread is testing to see if the taskmgmt command has completed.
+	    * When the rsp is received by guest, the thread receiving the
+	    * response uses this to notify the thread waiting for taskmgmt
+	    * command completion.  Its value is preserved by iopart & returned
+	    * as is in the task mgmt rsp.
+	    */
+	void *notifyresult;
+
+	    /* this is a handle to location in guest where the result of the
+	     * taskmgmt command (result field) is to saved off when the response
+	     * is handled.  Its value is preserved by iopart & returned as is in
+	     * the task mgmt rsp.
+	     */
+	char result;
+
+	    /* result of taskmgmt command - set by IOPart - values are: */
+#define TASK_MGMT_FAILED  0
+};
+
+/* The following is used by uissd to send disk add/remove notifications to
+ * Guest */
+/* Note that the vHba pointer is not used by the Client/Guest side. */
+struct uiscmdrsp_disknotify {
+	u8 add;			/* 0-remove, 1-add */
+	void *v_hba;		/* Pointer to vhba_info for channel info to
+				 * route msg */
+	u32 channel, id, lun;	/* SCSI Path of Disk to added or removed */
+};
+
+/* The following is used by virthba/vSCSI to send the Acquire/Release commands
+ * to the IOVM. */
+struct uiscmdrsp_vdiskmgmt {
+	enum vdisk_mgmt_types vdisktype;
+
+	    /* the type of task */
+	struct uisscsi_dest vdest;
+
+	    /* the vdisk for which this task mgmt is generated */
+	void *scsicmd;
+
+	    /* This is some handle that the guest has saved off for its own use.
+	     * Its value is preserved by iopart & returned as is in the task
+	     * mgmt rsp.
+	     */
+	void *notify;
+
+	    /* For linux guests, this is a pointer to wait_queue_head that a
+	     * thread is waiting on to see if the tskmgmt command has completed.
+	     * For win32 guests, this is a pointer to a location that a waiting
+	     * thread is testing to see if the taskmgmt command has completed.
+	     * When the rsp is received by guest, the thread receiving the
+	     * response uses this to notify the thread waiting for taskmgmt
+	     * command completion.  Its value is preserved by iopart & returned
+	     * as is in the task mgmt rsp.
+	     */
+	void *notifyresult;
+
+	    /* this is a handle to location in guest where the result of the
+	     * taskmgmt command (result field) is to saved off when the response
+	     * is handled.  Its value is preserved by iopart & returned as is in
+	     * the task mgmt rsp.
+	     */
+	char result;
+
+	    /* result of taskmgmt command - set by IOPart - values are: */
+#define VDISK_MGMT_FAILED  0
+};
+
+/* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */
+struct uiscmdrsp {
+	char cmdtype;
+
+/* describes what type of information is in the struct */
+#define CMD_SCSI_TYPE		1
+#define CMD_NET_TYPE		2
+#define CMD_SCSITASKMGMT_TYPE	3
+#define CMD_NOTIFYGUEST_TYPE	4
+#define CMD_VDISKMGMT_TYPE	5
+	union {
+		struct uiscmdrsp_scsi scsi;
+		struct uiscmdrsp_net net;
+		struct uiscmdrsp_scsitaskmgmt scsitaskmgmt;
+		struct uiscmdrsp_disknotify disknotify;
+		struct uiscmdrsp_vdiskmgmt vdiskmgmt;
+	};
+	void *private_data;	/* used to send the response when the cmd is
+				 * done (scsi & scsittaskmgmt). */
+	struct uiscmdrsp *next;	/* General Purpose Queue Link */
+	struct uiscmdrsp *activeQ_next;	/* Used to track active commands */
+	struct uiscmdrsp *activeQ_prev;	/* Used to track active commands */
+};
+
+/* This is just the header of the IO channel.  It is assumed that directly after
+ * this header there is a large region of memory which contains the command and
+ * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS.
+ */
+struct spar_io_channel_protocol {
+	struct channel_header channel_header;
+	struct signal_queue_header cmd_q;
+	struct signal_queue_header rsp_q;
+	union {
+		struct {
+			struct vhba_wwnn wwnn;		/* 8 bytes */
+			struct vhba_config_max max;	/* 20 bytes */
+		} vhba;					/* total = 28 bytes */
+		struct {
+			u8 macaddr[MAX_MACADDR_LEN];	/* 6 bytes */
+			u32 num_rcv_bufs;		/* 4 bytes */
+			u32 mtu;			/* 4 bytes */
+			uuid_le zone_uuid;		/* 16 bytes */
+		} vnic;					/* total = 30 bytes */
+	};
+
+#define MAX_CLIENTSTRING_LEN 1024
+	 u8 client_string[MAX_CLIENTSTRING_LEN];/* NULL terminated - so holds
+						 * max - 1 bytes */
+};
+
+#pragma pack(pop)
+/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
+
+/*
+ * INLINE functions for initializing and accessing I/O data channels
+ */
+
+#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
+#define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
+
+#define MIN_IO_CHANNEL_SIZE COVER(SIZEOF_PROTOCOL + \
+				  2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
+
+/*
+ * INLINE function for expanding a guest's pfn-off-size into multiple 4K page
+ * pfn-off-size entires.
+ */
+
+/* we deal with 4K page sizes when we it comes to passing page information
+ * between */
+/* Guest and IOPartition. */
+#define PI_PAGE_SIZE  0x1000
+#define PI_PAGE_MASK  0x0FFF
+
+/* returns next non-zero index on success or zero on failure (i.e. out of
+ * room)
+ */
+static inline  u16
+add_physinfo_entries(u32 inp_pfn,	/* input - specifies the pfn to be used
+					 * to add entries */
+		     u16 inp_off,	/* input - specifies the off to be used
+					 * to add entries */
+		     u32 inp_len,	/* input - specifies the len to be used
+					 * to add entries */
+		     u16 index,		/* input - index in array at which new
+					 * entries are added */
+		     u16 max_pi_arr_entries,	/* input - specifies the maximum
+						 * entries pi_arr can hold */
+		     struct phys_info pi_arr[]) /* input & output - array to
+						  * which entries are added */
+{
+	u32 len;
+	u16 i, firstlen;
+
+	firstlen = PI_PAGE_SIZE - inp_off;
+	if (inp_len <= firstlen) {
+		/* the input entry spans only one page - add as is */
+		if (index >= max_pi_arr_entries)
+			return 0;
+		pi_arr[index].pi_pfn = inp_pfn;
+		pi_arr[index].pi_off = (u16)inp_off;
+		pi_arr[index].pi_len = (u16)inp_len;
+		    return index + 1;
+	}
+
+	    /* this entry spans multiple pages */
+	    for (len = inp_len, i = 0; len;
+		 len -= pi_arr[index + i].pi_len, i++) {
+		if (index + i >= max_pi_arr_entries)
+			return 0;
+		pi_arr[index + i].pi_pfn = inp_pfn + i;
+		if (i == 0) {
+			pi_arr[index].pi_off = inp_off;
+			pi_arr[index].pi_len = firstlen;
+		}
+
+		else {
+			pi_arr[index + i].pi_off = 0;
+			pi_arr[index + i].pi_len =
+			    (u16)MINNUM(len, (u32)PI_PAGE_SIZE);
+		}
+	}
+	return index + i;
+}
+
+#endif				/* __IOCHANNEL_H__ */
diff --git a/drivers/staging/unisys/include/version.h b/drivers/staging/unisys/include/version.h
new file mode 100644
index 0000000..83d1da7
--- /dev/null
+++ b/drivers/staging/unisys/include/version.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/* version.h */
+
+/*  Common version/release info needed by all components goes here.
+ *  (This file must compile cleanly in all environments.)
+ *  Ultimately, this will be combined with defines generated dynamically as
+ *  part of the sysgen, and some of the defines below may in fact end up
+ *  being replaced with dynamically generated ones.
+ */
+#ifndef __VERSION_H__
+#define __VERSION_H__
+
+#define SPARVER1 "1"
+#define SPARVER2 "0"
+#define SPARVER3 "0"
+#define SPARVER4 "0"
+
+#define  VERSION        SPARVER1 "." SPARVER2 "." SPARVER3 "." SPARVER4
+
+/* Here are various version forms needed in Windows environments.
+ */
+#define VISOR_PRODUCTVERSION      SPARVERCOMMA
+#define VISOR_PRODUCTVERSION_STR  SPARVER1 "." SPARVER2 "." SPARVER3 "." \
+	SPARVER4
+#define VISOR_OBJECTVERSION_STR   SPARVER1 "," SPARVER2 "," SPARVER3 "," \
+	SPARVER4
+
+#define  COPYRIGHT      "Unisys Corporation"
+#define  COPYRIGHTDATE  "2010 - 2013"
+
+#endif
diff --git a/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h b/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
new file mode 100644
index 0000000..f74f5d8
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
@@ -0,0 +1,94 @@
+/* controlvmcompletionstatus.c
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*  Defines for all valid values returned in the response message header
+ *  completionStatus field.  See controlvmchannel.h for description of
+ *  the header: _CONTROLVM_MESSAGE_HEADER.
+ */
+
+#ifndef __CONTROLVMCOMPLETIONSTATUS_H__
+#define __CONTROLVMCOMPLETIONSTATUS_H__
+
+/* General Errors------------------------------------------------------[0-99] */
+#define CONTROLVM_RESP_SUCCESS                                  0
+#define CONTROLVM_RESP_ERROR_ALREADY_DONE                       1
+#define CONTROLVM_RESP_ERROR_IOREMAP_FAILED                     2
+#define CONTROLVM_RESP_ERROR_KMALLOC_FAILED                     3
+#define CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN                 4
+#define CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT      5
+
+/* CONTROLVM_INIT_CHIPSET-------------------------------------------[100-199] */
+#define CONTROLVM_RESP_ERROR_CLIENT_SWITCHCOUNT_NONZERO         100
+#define CONTROLVM_RESP_ERROR_EXPECTED_CHIPSET_INIT              101
+
+/* Maximum Limit----------------------------------------------------[200-299] */
+#define CONTROLVM_RESP_ERROR_MAX_BUSES		201	/* BUS_CREATE */
+#define CONTROLVM_RESP_ERROR_MAX_DEVICES        202	/* DEVICE_CREATE */
+/* Payload and Parameter Related------------------------------------[400-499] */
+#define CONTROLVM_RESP_ERROR_PAYLOAD_INVALID	400	/* SWITCH_ATTACHEXTPORT,
+							 * DEVICE_CONFIGURE */
+#define CONTROLVM_RESP_ERROR_INITIATOR_PARAMETER_INVALID 401	/* Multiple */
+#define CONTROLVM_RESP_ERROR_TARGET_PARAMETER_INVALID 402 /* DEVICE_CONFIGURE */
+#define CONTROLVM_RESP_ERROR_CLIENT_PARAMETER_INVALID 403 /* DEVICE_CONFIGURE */
+/* Specified[Packet Structure] Value-------------------------------[500-599] */
+#define CONTROLVM_RESP_ERROR_BUS_INVALID	500	/* SWITCH_ATTACHINTPORT,
+							 * BUS_CONFIGURE,
+							 * DEVICE_CREATE,
+							 * DEVICE_CONFIG
+							 * DEVICE_DESTROY */
+#define CONTROLVM_RESP_ERROR_DEVICE_INVALID	501 /* SWITCH_ATTACHINTPORT */
+						    /* DEVICE_CREATE,
+						     * DEVICE_CONFIGURE,
+						     * DEVICE_DESTROY */
+#define CONTROLVM_RESP_ERROR_CHANNEL_INVALID	502 /* DEVICE_CREATE,
+						     * DEVICE_CONFIGURE */
+/* Partition Driver Callback Interface----------------------[600-699] */
+#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE 604	/* BUS_CREATE,
+							 * BUS_DESTROY,
+							 * DEVICE_CREATE,
+							 * DEVICE_DESTROY */
+/* Unable to invoke VIRTPCI callback */
+#define CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR 605
+							/* BUS_CREATE,
+							 * BUS_DESTROY,
+							 * DEVICE_CREATE,
+							 * DEVICE_DESTROY */
+/* VIRTPCI Callback returned error */
+#define CONTROLVM_RESP_ERROR_GENERIC_DRIVER_CALLBACK_ERROR 606
+							/* SWITCH_ATTACHEXTPORT,
+							 * SWITCH_DETACHEXTPORT
+							 * DEVICE_CONFIGURE */
+
+/* generic device callback returned error */
+/* Bus Related------------------------------------------------------[700-799] */
+#define CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED 700	/* BUS_DESTROY */
+/* Channel Related--------------------------------------------------[800-899] */
+#define CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN 800	/* GET_CHANNELINFO,
+							 * DEVICE_DESTROY */
+#define CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL 801	/* DEVICE_CREATE */
+/* Chipset Shutdown Related---------------------------------------[1000-1099] */
+#define CONTROLVM_RESP_ERROR_CHIPSET_SHUTDOWN_FAILED            1000
+#define CONTROLVM_RESP_ERROR_CHIPSET_SHUTDOWN_ALREADY_ACTIVE    1001
+
+/* Chipset Stop Related-------------------------------------------[1100-1199] */
+#define CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS            1100
+#define CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_SWITCH         1101
+
+/* Device Related-------------------------------------------------[1400-1499] */
+#define CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT                1400
+
+#endif /* __CONTROLVMCOMPLETIONSTATUS_H__ not defined */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 111/141] staging: unisys: Get rid of references to common-spar
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (109 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 110/141] staging: unisys: Move files out of common-spar Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 112/141] staging: unisys: get rid of sparstop Benjamin Romer
                   ` (32 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Makefiles still had common-spar listed in ccflags.

This gets rid of them.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/Makefile     | 2 --
 drivers/staging/unisys/visorchannel/Makefile | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
index 72d4d44..fa27ee5 100644
--- a/drivers/staging/unisys/visorbus/Makefile
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -10,6 +10,4 @@ visorbus-y += visorchipset.o
 visorbus-y += periodic_work.o
 
 ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
 ccflags-y += -Idrivers/staging/unisys/visorutil
diff --git a/drivers/staging/unisys/visorchannel/Makefile b/drivers/staging/unisys/visorchannel/Makefile
index e079c96..0c0cacb 100644
--- a/drivers/staging/unisys/visorchannel/Makefile
+++ b/drivers/staging/unisys/visorchannel/Makefile
@@ -7,6 +7,4 @@ obj-$(CONFIG_UNISYS_VISORCHANNEL)	+= visorchannel.o
 visorchannel-y := visorchannel_main.o visorchannel_funcs.o
 
 ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
 ccflags-y += -Idrivers/staging/unisys/visorutil
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 112/141] staging: unisys: get rid of sparstop
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (110 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 111/141] staging: unisys: Get rid of references to common-spar Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 113/141] staging: unisys: remove remaining utility headers Benjamin Romer
                   ` (31 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/sparstop.h | 29 -----------------------------
 1 file changed, 29 deletions(-)
 delete mode 100644 drivers/staging/unisys/include/sparstop.h

diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h
deleted file mode 100644
index 6150d2d..0000000
--- a/drivers/staging/unisys/include/sparstop.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* sparstop.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __SPARSTOP_H__
-#define __SPARSTOP_H__
-
-#include "version.h"
-#include <linux/ctype.h>
-
-typedef void (*SPARSTOP_COMPLETE_FUNC) (void *context, int status);
-
-int sp_stop(void *context, SPARSTOP_COMPLETE_FUNC get_complete_func);
-void test_remove_stop_device(void);
-
-#endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 113/141] staging: unisys: remove remaining utility headers
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (111 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 112/141] staging: unisys: get rid of sparstop Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 114/141] staging: unisys: Embed struct device for easier handling of attr Benjamin Romer
                   ` (30 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

remove uisqueue.h, uisthread.h, and uisutils.h
replace HOSTADDRESS with u64
remove "uisutils.h" from header list in visorchipset.c

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/uisqueue.h      | 396 -------------------------
 drivers/staging/unisys/include/uisthread.h     |  42 ---
 drivers/staging/unisys/include/uisutils.h      | 293 ------------------
 drivers/staging/unisys/visorbus/visorchipset.c |  37 ++-
 4 files changed, 36 insertions(+), 732 deletions(-)
 delete mode 100644 drivers/staging/unisys/include/uisqueue.h
 delete mode 100644 drivers/staging/unisys/include/uisthread.h
 delete mode 100644 drivers/staging/unisys/include/uisutils.h

diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h
deleted file mode 100644
index 08ba16e..0000000
--- a/drivers/staging/unisys/include/uisqueue.h
+++ /dev/null
@@ -1,396 +0,0 @@
-/* uisqueue.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys IO Virtualization header NOTE: This file contains only Linux
- * specific structs.  All OS-independent structs are in iochannel.h.xx
- */
-
-#ifndef __UISQUEUE_H__
-#define __UISQUEUE_H__
-
-#include "linux/version.h"
-#include "iochannel.h"
-#include <linux/atomic.h>
-#include <linux/semaphore.h>
-#include <linux/uuid.h>
-
-#include "controlvmchannel.h"
-#include "controlvmcompletionstatus.h"
-
-struct uisqueue_info {
-	struct channel_header __iomem *chan;
-	/* channel containing queues in which scsi commands &
-	 * responses are queued
-	 */
-	u64 packets_sent;
-	u64 packets_received;
-	u64 interrupts_sent;
-	u64 interrupts_received;
-	u64 max_not_empty_cnt;
-	u64 total_wakeup_cnt;
-	u64 non_empty_wakeup_cnt;
-
-	struct {
-		struct signal_queue_header reserved1;	/*  */
-		struct signal_queue_header reserved2;	/*  */
-	} safe_uis_queue;
-	unsigned int (*send_int_if_needed)(struct uisqueue_info *info,
-					   unsigned int whichcqueue,
-					   unsigned char issue_irq_if_empty,
-					   u64 irq_handle,
-					   unsigned char io_termination);
-};
-
-/* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response
- * to the specified queue, at the tail if the queue is full but
- * oktowait == 0, then it return 0 indicating failure.  otherwise it
- * wait for the queue to become non-full. If command is queued, return
- * 1 for success.
- */
-#define DONT_ISSUE_INTERRUPT 0
-#define ISSUE_INTERRUPT		 1
-
-#define DONT_WAIT			 0
-#define OK_TO_WAIT			 1
-#define UISLIB_LOCK_PREFIX \
-		".section .smp_locks,\"a\"\n"   \
-		_ASM_ALIGN "\n"                 \
-		_ASM_PTR "661f\n" /* address */ \
-		".previous\n"                   \
-		"661:\n\tlock; "
-
-unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt,
-					   unsigned long long set);
-unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt,
-					    unsigned long long set);
-
-int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
-					 struct uiscmdrsp *cmdrsp,
-					 unsigned int queue,
-					 void *insertlock,
-					 unsigned char issue_irq_if_empty,
-					 u64 irq_handle,
-					 char oktowait,
-					 u8 *channel_id);
-
-/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
- * and copies it to the area pointed by cmdrsp param.
- * returns 0 if queue is empty, 1 otherwise
- */
-int
-
-uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp,
-		    unsigned int queue);
-
-#define MAX_NAME_SIZE_UISQUEUE 64
-
-struct extport_info {
-	u8 valid:1;
-	/* if 1, indicates this extport slot is occupied
-	 * if 0, indicates that extport slot is unoccupied */
-
-	u32 num_devs_using;
-	/* When extport is added, this is set to 0.  For exports
-	* located in NETWORK switches:
-	* Each time a VNIC, i.e., intport, is added to the switch this
-	* is used to assign a pref_pnic for the VNIC and when assigned
-	* to a VNIC this counter is incremented. When a VNIC is
-	* deleted, the extport corresponding to the VNIC's pref_pnic
-	* is located and its num_devs_using is decremented. For VNICs,
-	* num_devs_using is basically used to load-balance transmit
-	* traffic from VNICs.
-	*/
-
-	struct switch_info *swtch;
-	struct pci_id pci_id;
-	char name[MAX_NAME_SIZE_UISQUEUE];
-	union {
-		struct vhba_wwnn wwnn;
-		unsigned char macaddr[MAX_MACADDR_LEN];
-	};
-};
-
-struct device_info {
-	void __iomem *chanptr;
-	u64 channel_addr;
-	u64 channel_bytes;
-	uuid_le channel_uuid;
-	uuid_le instance_uuid;
-	struct irq_info intr;
-	struct switch_info *swtch;
-	char devid[30];		/* "vbus<busno>:dev<devno>" */
-	u16 polling;
-	struct semaphore interrupt_callback_lock;
-	u32 bus_no;
-	u32 dev_no;
-	int (*interrupt)(void *);
-	void *interrupt_context;
-	void *private_data;
-	struct list_head list_polling_device_channels;
-	unsigned long long moved_to_tail_cnt;
-	unsigned long long first_busy_cnt;
-	unsigned long long last_on_list_cnt;
-};
-
-enum switch_type {
-	RECOVERY_LAN = 1,
-	IB_LAN = 2
-};
-
-struct bus_info {
-	u32 bus_no, device_count;
-	struct device_info **device;
-	u64 guest_handle, recv_bus_irq_handle;
-	uuid_le bus_inst_uuid;
-	struct ultra_vbus_channel_protocol __iomem *bus_channel;
-	int bus_channel_bytes;
-	struct proc_dir_entry *proc_dir;	/* proc/uislib/vbus/<x> */
-	struct proc_dir_entry *proc_info;	/* proc/uislib/vbus/<x>/info */
-	char name[25];
-	char partition_name[99];
-	struct bus_info *next;
-	u8 local_vnic;		/* 1 if local vnic created internally
-				 * by IOVM; 0 otherwise... */
-};
-
-struct sn_list_entry {
-	struct uisscsi_dest pdest;	/* scsi bus, target, lun for
-					 * phys disk */
-	u8 sernum[MAX_SERIAL_NUM];	/* serial num of physical
-					 * disk.. The length is always
-					 * MAX_SERIAL_NUM, padded with
-					 * spaces */
-	struct sn_list_entry *next;
-};
-
-/*
- * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
- * code that processes the ControlVm channel messages.
- */
-
-enum iopart_msg_type {
-	IOPART_ADD_VNIC,
-	IOPART_DEL_VNIC,
-	IOPART_DEL_ALL_VNICS,
-	IOPART_ADD_VHBA,
-	IOPART_ADD_VDISK,
-	IOPART_DEL_VHBA,
-	IOPART_DEL_VDISK,
-	IOPART_DEL_ALL_VDISKS_FOR_VHBA,
-	IOPART_DEL_ALL_VHBAS,
-	IOPART_ATTACH_PHBA,
-	IOPART_DETACH_PHBA,	/* 10 */
-	IOPART_ATTACH_PNIC,
-	IOPART_DETACH_PNIC,
-	IOPART_DETACH_VHBA,
-	IOPART_DETACH_VNIC,
-	IOPART_PAUSE_VDISK,
-	IOPART_RESUME_VDISK,
-	IOPART_ADD_DEVICE,	/* add generic device */
-	IOPART_DEL_DEVICE,	/* del generic device */
-};
-
-struct add_virt_iopart {
-	void *chanptr;		/* pointer to data channel */
-	u64 guest_handle;	/* used to convert guest physical
-				 * address to real physical address
-				 * for DMA, for ex. */
-	u64 recv_bus_irq_handle;	/* used to register to receive
-					 * bus level interrupts. */
-	struct irq_info intr;	/* contains recv & send
-					 * interrupt info */
-	/* recvInterruptHandle is used to register to receive
-	* interrupts on the data channel. Used by GuestLinux/Windows
-	* IO drivers to connect to interrupt.  sendInterruptHandle is
-	* used by IOPart drivers as parameter to
-	* Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in
-	* guest linux/windows IO drivers when data channel queue for
-	* vhba/vnic goes from EMPTY to NON-EMPTY. */
-	struct switch_info *swtch;	/* pointer to the virtual
-					 * switch to which the vnic is
-					 * connected */
-
-	u8 use_g2g_copy;	/* Used to determine if a virtual HBA
-				 * needs to use G2G copy. */
-	u8 filler[7];
-
-	u32 bus_no;
-	u32 dev_no;
-	char *params;
-	ulong params_bytes;
-
-};
-
-struct add_vdisk_iopart {
-	void *chanptr;		      /* pointer to data channel */
-	int implicit;
-	struct uisscsi_dest vdest;    /* scsi bus, target, lun for virt disk */
-	struct uisscsi_dest pdest;    /* scsi bus, target, lun for phys disk */
-	u8 sernum[MAX_SERIAL_NUM];    /* serial num of physical disk */
-	u32 serlen;		      /* length of serial num */
-};
-
-struct del_vdisk_iopart {
-	void *chanptr;		     /* pointer to data channel */
-	struct uisscsi_dest vdest;   /* scsi bus, target, lun for virt disk */
-};
-
-struct del_virt_iopart {
-	void *chanptr;		     /* pointer to data channel */
-};
-
-struct det_virt_iopart {	     /* detach internal port */
-	void *chanptr;		     /* pointer to data channel */
-	struct switch_info *swtch;
-};
-
-struct paures_vdisk_iopart {
-	void *chanptr;		     /* pointer to data channel */
-	struct uisscsi_dest vdest;   /* scsi bus, target, lun for virt disk */
-};
-
-struct add_switch_iopart {	     /* add switch */
-	struct switch_info *swtch;
-	char *params;
-	ulong params_bytes;
-};
-
-struct del_switch_iopart {	     /* destroy switch */
-	struct switch_info *swtch;
-};
-
-struct io_msgs {
-	enum iopart_msg_type msgtype;
-
-	/* additional params needed by some messages */
-	union {
-		struct add_virt_iopart add_vhba;
-		struct add_virt_iopart add_vnic;
-		struct add_vdisk_iopart add_vdisk;
-		struct del_virt_iopart del_vhba;
-		struct del_virt_iopart del_vnic;
-		struct det_virt_iopart det_vhba;
-		struct det_virt_iopart det_vnic;
-		struct del_vdisk_iopart del_vdisk;
-		struct del_virt_iopart del_all_vdisks_for_vhba;
-		struct add_virt_iopart add_device;
-		struct del_virt_iopart del_device;
-		struct det_virt_iopart det_intport;
-		struct add_switch_iopart add_switch;
-		struct del_switch_iopart del_switch;
-		struct extport_info *ext_port;	/* for attach or detach
-						 * pnic/generic delete all
-						 * vhbas/allvnics need no
-						 * parameters */
-		struct paures_vdisk_iopart paures_vdisk;
-	};
-};
-
-/*
-* Guest messages sent to VirtControlChanFunc by code that processes
-* the ControlVm channel messages.
-*/
-
-enum guestpart_msg_type {
-	GUEST_ADD_VBUS,
-	GUEST_ADD_VHBA,
-	GUEST_ADD_VNIC,
-	GUEST_DEL_VBUS,
-	GUEST_DEL_VHBA,
-	GUEST_DEL_VNIC,
-	GUEST_DEL_ALL_VHBAS,
-	GUEST_DEL_ALL_VNICS,
-	GUEST_DEL_ALL_VBUSES,	/* deletes all vhbas & vnics on all
-				 * buses and deletes all buses */
-	GUEST_PAUSE_VHBA,
-	GUEST_PAUSE_VNIC,
-	GUEST_RESUME_VHBA,
-	GUEST_RESUME_VNIC
-};
-
-struct add_vbus_guestpart {
-	void __iomem *chanptr;		/* pointer to data channel for bus -
-					 * NOT YET USED */
-	u32 bus_no;		/* bus number to be created/deleted */
-	u32 dev_count;	/* max num of devices on bus */
-	uuid_le bus_uuid;	/* indicates type of bus */
-	uuid_le instance_uuid;	/* instance guid for device */
-};
-
-struct del_vbus_guestpart {
-	u32 bus_no;		/* bus number to be deleted */
-	/* once we start using the bus's channel, add can dump busNo
-	* into the channel header and then delete will need only one
-	* parameter, chanptr. */
-};
-
-struct add_virt_guestpart {
-	void __iomem *chanptr;		/* pointer to data channel */
-	u32 bus_no;		/* bus number for the operation */
-	u32 device_no;		/* number of device on the bus */
-	uuid_le instance_uuid;	/* instance guid for device */
-	struct irq_info intr;	/* recv/send interrupt info */
-	/* recvInterruptHandle contains info needed in order to
-	 * register to receive interrupts on the data channel.
-	 * sendInterruptHandle contains handle which is provided to
-	 * monitor VMCALL that will cause an interrupt to be generated
-	 * for the other end.
-	 */
-};
-
-struct pause_virt_guestpart {
-	void __iomem *chanptr;		/* pointer to data channel */
-};
-
-struct resume_virt_guestpart {
-	void __iomem *chanptr;		/* pointer to data channel */
-};
-
-struct del_virt_guestpart {
-	void __iomem *chanptr;		/* pointer to data channel */
-};
-
-struct init_chipset_guestpart {
-	u32 bus_count;		/* indicates the max number of busses */
-	u32 switch_count;	/* indicates the max number of switches */
-};
-
-struct guest_msgs {
-	enum guestpart_msg_type msgtype;
-
-	/* additional params needed by messages */
-	union {
-		struct add_vbus_guestpart add_vbus;
-		struct add_virt_guestpart add_vhba;
-		struct add_virt_guestpart add_vnic;
-		struct pause_virt_guestpart pause_vhba;
-		struct pause_virt_guestpart pause_vnic;
-		struct resume_virt_guestpart resume_vhba;
-		struct resume_virt_guestpart resume_vnic;
-		struct del_vbus_guestpart del_vbus;
-		struct del_virt_guestpart del_vhba;
-		struct del_virt_guestpart del_vnic;
-		struct del_vbus_guestpart del_all_vhbas;
-		struct del_vbus_guestpart del_all_vnics;
-		/* del_all_vbuses needs no parameters */
-	};
-	struct init_chipset_guestpart init_chipset;
-
-};
-
-#endif				/* __UISQUEUE_H__ */
diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h
deleted file mode 100644
index 52c3eb4..0000000
--- a/drivers/staging/unisys/include/uisthread.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* uisthread.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*****************************************************************************/
-/* Unisys thread utilities header                                            */
-/*****************************************************************************/
-
-#ifndef __UISTHREAD_H__
-#define __UISTHREAD_H__
-
-#include "linux/completion.h"
-
-struct uisthread_info {
-	struct task_struct *task;
-	int id;
-	struct completion has_stopped;
-};
-
-/* returns 0 for failure, 1 for success */
-int uisthread_start(
-	struct uisthread_info *thrinfo,
-	int (*threadfn)(void *),
-	void *thrcontext,
-	char *name);
-
-void uisthread_stop(struct uisthread_info *thrinfo);
-
-#endif /* __UISTHREAD_H__ */
diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
deleted file mode 100644
index d58858b..0000000
--- a/drivers/staging/unisys/include/uisutils.h
+++ /dev/null
@@ -1,293 +0,0 @@
-/* uisutils.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys Virtual HBA utilities header
- */
-
-#ifndef __UISUTILS__H__
-#define __UISUTILS__H__
-#include <linux/string.h>
-#include <linux/io.h>
-#include <linux/sched.h>
-#include <linux/gfp.h>
-#include <linux/uuid.h>
-#include <linux/if_ether.h>
-
-#include "vmcallinterface.h"
-#include "channel.h"
-#include "uisthread.h"
-#include "uisqueue.h"
-#include "vbusdeviceinfo.h"
-#include <linux/atomic.h>
-
-/* This is the MAGIC number stuffed by virthba in host->this_id. Used to
- * identify virtual hbas.
- */
-#define UIS_MAGIC_VHBA 707
-
-/* global function pointers that act as callback functions into
- * uisnicmod, uissdmod, and virtpcimod
- */
-extern int (*uisnic_control_chan_func)(struct io_msgs *);
-extern int (*uissd_control_chan_func)(struct io_msgs *);
-extern int (*virt_control_chan_func)(struct guest_msgs *);
-
-/* Return values of above callback functions: */
-#define CCF_ERROR        0	/* completed and failed */
-#define CCF_OK           1	/* completed successfully */
-#define CCF_PENDING      2	/* operation still pending */
-extern atomic_t uisutils_registered_services;
-
-struct req_handler_info {
-	uuid_le switch_uuid;
-	int (*controlfunc)(struct io_msgs *);
-	unsigned long min_channel_bytes;
-	int (*server_channel_ok)(unsigned long channel_bytes);
-	int (*server_channel_init)(void *x, unsigned char *client_str,
-				   u32 client_str_len, u64 bytes);
-	char switch_type_name[99];
-	struct list_head list_link;	/* links into ReqHandlerInfo_list */
-};
-
-struct req_handler_info *req_handler_find(uuid_le switch_uuid);
-
-#define uislib_ioremap_cache(addr, size) \
-	dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
-
-static inline void __iomem *
-dbg_ioremap_cache(u64 addr, unsigned long size, char *file, int line)
-{
-	void __iomem *new;
-
-	new = ioremap_cache(addr, size);
-	return new;
-}
-
-#define uislib_ioremap(addr, size) dbg_ioremap(addr, size, __FILE__, __LINE__)
-
-static inline void *
-dbg_ioremap(u64 addr, unsigned long size, char *file, int line)
-{
-	void *new;
-
-	new = ioremap(addr, size);
-	return new;
-}
-
-#define uislib_iounmap(addr) dbg_iounmap(addr, __FILE__, __LINE__)
-
-static inline void
-dbg_iounmap(void __iomem *addr, char *file, int line)
-{
-	iounmap(addr);
-}
-
-#define PROC_READ_BUFFER_SIZE 131072	/* size of the buffer to allocate to
-					 * hold all of /proc/XXX/info */
-int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
-			     char *format, ...);
-
-int uisctrl_register_req_handler(int type, void *fptr,
-			struct ultra_vbus_deviceinfo *chipset_driver_info);
-
-unsigned char *util_map_virt(struct phys_info *sg);
-void util_unmap_virt(struct phys_info *sg);
-unsigned char *util_map_virt_atomic(struct phys_info *sg);
-void util_unmap_virt_atomic(void *buf);
-int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
-				 u64 channel_addr, ulong n_channel_bytes);
-int  uislib_client_inject_del_bus(u32 bus_no);
-
-int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
-				  u64 phys_chan_addr, u32 chan_bytes,
-				  int is_test_addr, uuid_le inst_uuid,
-				  struct irq_info *intr);
-int  uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no);
-int  uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no);
-int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no);
-int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
-				  u64 phys_chan_addr, u32 chan_bytes,
-				  int is_test_addr, uuid_le inst_uuid,
-				  struct irq_info *intr);
-int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no);
-int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no);
-int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no);
-#ifdef STORAGE_CHANNEL
-u64 uislib_storage_channel(int client_id);
-#endif
-int uislib_get_owned_pdest(struct uisscsi_dest *pdest);
-
-int uislib_send_event(enum controlvm_id id,
-		      struct controlvm_message_packet *event);
-
-/* structure used by vhba & vnic to keep track of queue & thread info */
-struct chaninfo {
-	struct uisqueue_info *queueinfo;
-	/* this specifies the queue structures for a channel */
-	/* ALLOCATED BY THE OTHER END - WE JUST GET A POINTER TO THE MEMORY */
-	spinlock_t insertlock;
-	/* currently used only in virtnic when sending data to uisnic */
-	/* to synchronize the inserts into the signal queue */
-	struct uisthread_info threadinfo;
-	/* this specifies the thread structures used by the thread that */
-	/* handles this channel */
-};
-
-/* this is the wait code for all the threads - it is used to get
-* something from a queue choices: wait_for_completion_interruptible,
-* _timeout, interruptible_timeout
-*/
-#define UIS_THREAD_WAIT_MSEC(x) { \
-	set_current_state(TASK_INTERRUPTIBLE); \
-	schedule_timeout(msecs_to_jiffies(x)); \
-}
-
-#define UIS_THREAD_WAIT_USEC(x) { \
-	set_current_state(TASK_INTERRUPTIBLE); \
-	schedule_timeout(usecs_to_jiffies(x)); \
-}
-
-#define UIS_THREAD_WAIT UIS_THREAD_WAIT_MSEC(5)
-
-#define UIS_THREAD_WAIT_SEC(x) { \
-	set_current_state(TASK_INTERRUPTIBLE); \
-	schedule_timeout((x)*HZ); \
-}
-
-/* This is a hack until we fix IOVM to initialize the channel header
- * correctly at DEVICE_CREATE time, INSTEAD OF waiting until
- * DEVICE_CONFIGURE time.
- */
-static inline void
-wait_for_valid_guid(uuid_le __iomem *guid)
-{
-	uuid_le tmpguid;
-
-	while (1) {
-		memcpy_fromio((void *)&tmpguid,
-			      (void __iomem *)guid, sizeof(uuid_le));
-		if (uuid_le_cmp(tmpguid, NULL_UUID_LE) != 0)
-			break;
-		UIS_THREAD_WAIT_SEC(5);
-	}
-}
-
-static inline unsigned int
-issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
-{
-	struct vmcall_io_controlvm_addr_params params;
-	int result = VMCALL_SUCCESS;
-	u64 physaddr;
-
-	physaddr = virt_to_phys(&params);
-	ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result);
-	if (VMCALL_SUCCESSFUL(result)) {
-		*control_addr = params.address;
-		*control_bytes = params.channel_bytes;
-	}
-	return result;
-}
-
-static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr)
-{
-	struct vmcall_io_diag_addr_params params;
-	int result = VMCALL_SUCCESS;
-	u64 physaddr;
-
-	physaddr = virt_to_phys(&params);
-	ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result);
-	if (VMCALL_SUCCESSFUL(result))
-		*diag_channel_addr = params.address;
-	return result;
-}
-
-static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr)
-{
-	struct vmcall_io_visorserial_addr_params params;
-	int result = VMCALL_SUCCESS;
-	u64 physaddr;
-
-	physaddr = virt_to_phys(&params);
-	ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result);
-	if (VMCALL_SUCCESSFUL(result))
-		*channel_addr = params.address;
-	return result;
-}
-
-static inline s64 issue_vmcall_query_guest_virtual_time_offset(void)
-{
-	u64 result = VMCALL_SUCCESS;
-	u64 physaddr = 0;
-
-	ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr,
-			result);
-	return result;
-}
-
-struct log_info_t {
-	unsigned long long last_cycles;
-	unsigned long long delta_sum[64];
-	unsigned long long delta_cnt[64];
-	unsigned long long max_delta[64];
-	unsigned long long min_delta[64];
-};
-
-static inline int issue_vmcall_update_physical_time(u64 adjustment)
-{
-	int result = VMCALL_SUCCESS;
-
-	ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result);
-	return result;
-}
-
-static inline unsigned int issue_vmcall_channel_mismatch(const char *chname,
-			      const char *item_name, u32 line_no,
-			      const char *path_n_fn)
-{
-	struct vmcall_channel_version_mismatch_params params;
-	int result = VMCALL_SUCCESS;
-	u64 physaddr;
-	char *last_slash = NULL;
-
-	strlcpy(params.chname, chname, sizeof(params.chname));
-	strlcpy(params.item_name, item_name, sizeof(params.item_name));
-	params.line_no = line_no;
-
-	last_slash = strrchr(path_n_fn, '/');
-	if (last_slash != NULL) {
-		last_slash++;
-		strlcpy(params.file_name, last_slash, sizeof(params.file_name));
-	} else
-		strlcpy(params.file_name,
-			"Cannot determine source filename",
-			sizeof(params.file_name));
-
-	physaddr = virt_to_phys(&params);
-	ISSUE_IO_VMCALL(VMCALL_CHANNEL_VERSION_MISMATCH, physaddr, result);
-	return result;
-}
-
-#define UIS_DAEMONIZE(nam)
-
-void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no,
-				      int (*interrupt)(void *),
-				      void *interrupt_context);
-void uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no);
-void uislib_force_channel_interrupt(u32 bus_no, u32 dev_no);
-
-#endif /* __UISUTILS__H__ */
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index e6d7075..b96a40c 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -26,14 +26,15 @@
 #include <linux/uuid.h>
 #include <linux/crash_dump.h>
 
+#include "channel_guid.h"
 #include "controlvmchannel.h"
 #include "controlvmcompletionstatus.h"
 #include "guestlinuxdebug.h"
 #include "periodic_work.h"
-#include "uisutils.h"
 #include "version.h"
 #include "visorbus.h"
 #include "visorbus_private.h"
+#include "vmcallinterface.h"
 
 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
 
@@ -1856,6 +1857,22 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr)
 	return true;
 }
 
+static inline unsigned int
+issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
+{
+	struct vmcall_io_controlvm_addr_params params;
+	int result = VMCALL_SUCCESS;
+	u64 physaddr;
+
+	physaddr = virt_to_phys(&params);
+	ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result);
+	if (VMCALL_SUCCESSFUL(result)) {
+		*control_addr = params.address;
+		*control_bytes = params.channel_bytes;
+	}
+	return result;
+}
+
 static u64 controlvm_get_channel_address(void)
 {
 	u64 addr = 0;
@@ -2239,6 +2256,24 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
 	return 0;
 }
 
+static inline s64 issue_vmcall_query_guest_virtual_time_offset(void)
+{
+	u64 result = VMCALL_SUCCESS;
+	u64 physaddr = 0;
+
+	ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr,
+			result);
+	return result;
+}
+
+static inline int issue_vmcall_update_physical_time(u64 adjustment)
+{
+	int result = VMCALL_SUCCESS;
+
+	ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result);
+	return result;
+}
+
 static long visorchipset_ioctl(struct file *file, unsigned int cmd,
 			       unsigned long arg)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 114/141] staging: unisys: Embed struct device for easier handling of attr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (112 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 113/141] staging: unisys: remove remaining utility headers Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 115/141] staging: unisys: Wire up proper device attr for bus Benjamin Romer
                   ` (29 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Handling the sysfs attributes become easier to deal with when you can just
run container_of(dev) to get devdata.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 28 ++++++++-----------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 77afa9d..1266259 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -41,7 +41,7 @@ int visorbus_debugref;
 struct visorbus_devdata {
 	int devno;		/* this is the chipset busNo */
 	struct list_head list_all;
-	struct device *dev;
+	struct device dev;
 	struct kobject kobj;
 	struct visorchannel *chan;	/* channel area for bus itself */
 	bool vbus_valid;
@@ -1329,7 +1329,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 	dev->channel_bytes = chan_info.n_channel_bytes;
 	dev->chipset_bus_no = chipset_bus_no;
 	dev->chipset_dev_no = chipset_dev_no;
-	dev->device.parent = devdata->dev;
+	dev->device.parent = &devdata->dev;
 	sema_init(&dev->visordriver_callback_lock, 1);	/* unlocked */
 	dev->device.bus = &visorbus_type;
 	device_initialize(&dev->device);
@@ -1636,34 +1636,24 @@ create_bus_instance(int id)
 {
 	struct visorbus_devdata *rc = NULL;
 	struct visorbus_devdata *devdata = NULL;
-	struct device *dev;
 	struct visorchipset_bus_info bus_info;
 
 	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
+	devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
+	if (!devdata) {
 		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
 		rc = NULL;
 		goto away;
 	}
-	memset(dev, 0, sizeof(struct device));
-	dev_set_name(dev, "visorbus%d", id);
-	dev->release = visorbus_release_busdevice;
-	if (device_register(dev) < 0) {
+	dev_set_name(&devdata->dev, "visorbus%d", id);
+	devdata->dev.release = visorbus_release_busdevice;
+	if (device_register(&devdata->dev) < 0) {
 		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
 				 POSTCODE_SEVERITY_ERR);
 		rc = NULL;
 		goto away;
 	}
-	devdata = kmalloc(sizeof(*devdata), GFP_KERNEL);
-	if (!devdata) {
-		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
-		rc = NULL;
-		goto away;
-	}
-	memset(devdata, 0, sizeof(struct visorbus_devdata));
 	devdata->devno = id;
-	devdata->dev = dev;
 	if ((visorchipset_get_bus_info(id, &bus_info)) &&
 	    (bus_info.chan_info.channel_addr > 0) &&
 	    (bus_info.chan_info.n_channel_bytes > 0)) {
@@ -1707,7 +1697,7 @@ create_bus_instance(int id)
 	list_add_tail(&devdata->list_all, &list_all_bus_instances);
 	if (id == 0)
 			devdata = devdata;	/* for testing ONLY */
-	dev_set_drvdata(dev, devdata);
+	dev_set_drvdata(&devdata->dev, devdata);
 	rc = devdata;
 away:
 	return rc;
@@ -1732,7 +1722,7 @@ remove_bus_instance(struct visorbus_devdata *devdata)
 		devdata->chan = NULL;
 	}
 	list_del(&devdata->list_all);
-	device_unregister(devdata->dev);
+	device_unregister(&devdata->dev);
 }
 
 /** Create and register the one-and-only one instance of
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 115/141] staging: unisys: Wire up proper device attr for bus
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (113 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 114/141] staging: unisys: Embed struct device for easier handling of attr Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 116/141] staging: unisys: Move the visorbus device underneath devices Benjamin Romer
                   ` (28 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This patch moves the attributes to underneath the bus device correctly.
This will help remove a bunch of cruft from the code and let the kernel
infrastructure manage the sysfs files instead of the driver.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 75 +++++++++++++++++++------
 1 file changed, 58 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 1266259..6204105 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -659,7 +659,7 @@ struct businst_attribute {
 #define to_businst_attr(_attr) \
 	container_of(_attr, struct businst_attribute, attr)
 #define to_visorbus_devdata(obj) \
-	container_of(obj, struct visorbus_devdata, kobj)
+	container_of(obj, struct visorbus_devdata, dev)
 
 static ssize_t
 businst_attr_show(struct kobject *kobj, struct attribute *attr,
@@ -774,8 +774,10 @@ unregister_bustype_attributes(void)
  *
  */
 
-static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst,
-					     char *buf) {
+static ssize_t partition_handle_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int len = 0;
 
@@ -786,8 +788,10 @@ static ssize_t businst_attr_partition_handle(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst,
-					   char *buf) {
+static ssize_t partition_guid_show(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int len = 0;
 
@@ -797,8 +801,10 @@ static ssize_t businst_attr_partition_guid(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst,
-					   char *buf) {
+static ssize_t partition_name_show(struct device *dev,
+				   struct device_attribute *attr,
+				   char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int len = 0;
 
@@ -809,8 +815,10 @@ static ssize_t businst_attr_partition_name(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst,
-					 char *buf) {
+static ssize_t channel_addr_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int len = 0;
 
@@ -820,8 +828,10 @@ static ssize_t businst_attr_channel_addr(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst,
-					   char *buf) {
+static ssize_t channel_bytes_show(struct device *dev,
+				  struct device_attribute *attr,
+				  char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int len = 0;
 
@@ -831,8 +841,10 @@ static ssize_t businst_attr_nchannel_bytes(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst,
-				       char *buf) {
+static ssize_t channel_id_show(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	int len = 0;
 
 	if (businst && businst->chan) {
@@ -843,8 +855,10 @@ static ssize_t businst_attr_channel_id(struct visorbus_devdata *businst,
 	return len;
 }
 
-static ssize_t businst_attr_client_bus_info(struct visorbus_devdata *businst,
-					    char *buf) {
+static ssize_t client_bus_info_show(struct device *dev,
+				    struct device_attribute *attr,
+				    char *buf) {
+	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
 	struct visorchipset_bus_info bus_info;
 	int i, x, remain = PAGE_SIZE;
 	unsigned long off;
@@ -918,6 +932,34 @@ static struct businst_attribute ba_channel_id =
 static struct businst_attribute ba_client_bus_info =
 	__ATTR(client_bus_info, S_IRUGO, businst_attr_client_bus_info, NULL);
 
+static DEVICE_ATTR_RO(partition_handle);
+static DEVICE_ATTR_RO(partition_guid);
+static DEVICE_ATTR_RO(partition_name);
+static DEVICE_ATTR_RO(channel_addr);
+static DEVICE_ATTR_RO(channel_bytes);
+static DEVICE_ATTR_RO(channel_id);
+static DEVICE_ATTR_RO(client_bus_info);
+
+static struct attribute *dev_attrs[] = {
+		&dev_attr_partition_handle.attr,
+		&dev_attr_partition_guid.attr,
+		&dev_attr_partition_name.attr,
+		&dev_attr_channel_addr.attr,
+		&dev_attr_channel_bytes.attr,
+		&dev_attr_channel_id.attr,
+		&dev_attr_client_bus_info.attr,
+		NULL
+};
+
+static struct attribute_group dev_attr_grp = {
+		.attrs = dev_attrs,
+};
+
+static const struct attribute_group *visorbus_groups[] = {
+		&dev_attr_grp,
+		NULL
+};
+
 static int
 register_businst_attributes(struct visorbus_devdata *businst)
 {
@@ -1646,6 +1688,7 @@ create_bus_instance(int id)
 		goto away;
 	}
 	dev_set_name(&devdata->dev, "visorbus%d", id);
+	devdata->dev.groups = visorbus_groups;
 	devdata->dev.release = visorbus_release_busdevice;
 	if (device_register(&devdata->dev) < 0) {
 		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
@@ -1692,7 +1735,6 @@ create_bus_instance(int id)
 			}
 		}
 	}
-	register_businst_attributes(devdata);
 	bus_count++;
 	list_add_tail(&devdata->list_all, &list_all_bus_instances);
 	if (id == 0)
@@ -1715,7 +1757,6 @@ remove_bus_instance(struct visorbus_devdata *devdata)
 	 * successfully been able to trace thru the code to see where/how
 	 * release() gets called.  But I know it does.
 	 */
-	unregister_businst_attributes(devdata);
 	bus_count--;
 	if (devdata->chan) {
 		visorchannel_destroy(devdata->chan);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 116/141] staging: unisys: Move the visorbus device underneath devices
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (114 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 115/141] staging: unisys: Wire up proper device attr for bus Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 117/141] staging: unisys: remove unused bus attribute code Benjamin Romer
                   ` (27 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Mimicing what other drivers do, this seems appropriate.  Yeah, it
is a bus, but it is a bus _device_.  This makes things work better
and smoother.  Now the sysfs looks like

[root@dhcp-17-174 visorbus]# ls -l /sys/bus/visorbus/devices/
total 0
lrwxrwxrwx. 1 root root 0 Apr 17 16:09 vbus1:dev2 ->
		../../../devices/visorbus1/vbus1:dev2
lrwxrwxrwx. 1 root root 0 Apr 17 16:09 visorbus1 ->
		../../../devices/visorbus1

Which looks correct.  All the attributes are still correct too, based on my
very minimal testing of 'ls -lR'. :-)

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 6204105..2246c09 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1688,6 +1688,7 @@ create_bus_instance(int id)
 		goto away;
 	}
 	dev_set_name(&devdata->dev, "visorbus%d", id);
+	devdata->dev.bus = &visorbus_type;
 	devdata->dev.groups = visorbus_groups;
 	devdata->dev.release = visorbus_release_busdevice;
 	if (device_register(&devdata->dev) < 0) {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 117/141] staging: unisys: remove unused bus attribute code
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (115 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 116/141] staging: unisys: Move the visorbus device underneath devices Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 118/141] staging: unisys: Properly move version file into bus attr Benjamin Romer
                   ` (26 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This was replaced by an earlier patch and it not needed.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 197 ------------------------
 1 file changed, 197 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 2246c09..4c35d34 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -606,114 +606,9 @@ void unregister_channel_attributes(struct visor_device *dev)
 	kobject_put(&dev->kobjchannel);
 	dev->kobjchannel.parent = NULL;
 }
-/*   This is actually something they forgot to put in the kernel.
- *   struct bus_type in the kernel SHOULD have a "busses" member, which
- *   should be treated similarly to the "devices" and "drivers" members.
- *   There SHOULD be:
- *   - a "businst_attribute" analogous to the existing "bus_attribute"
- *   - a "businst_create_file" and "businst_remove_file" analogous to the
- *     existing "bus_create_file" and "bus_remove_file".
- *   That's what I created businst.c and businst.h to do.
- *
- *   We want to add the "busses" sub-tree in sysfs, where we will house the
- *   names and properties of each bus instance:
- *
- *       /sys/bus/<bustypename>/
- *           version
- *           devices
- *               <devname1> --> /sys/devices/<businstancename><devname1>
- *               <devname2> --> /sys/devices/<businstancename><devname2>
- *           drivers
- *               <driverinstancename1>
- *                   <driverinstance1property1>
- *                   <driverinstance1property2>
- *                   ...
- *               <driverinstancename2>
- *                   <driverinstance2property1>
- *                   <driverinstance2property2>
- *                   ...
- *   >>      busses
- *   >>          <businstancename1>
- *   >>              <businstance1property1>
- *   >>              <businstance1property2>
- *   >>              ...
- *   >>          <businstancename2>
- *   >>              <businstance2property1>
- *   >>              <businstance2property2>
- *   >>              ...
- *
- *   I considered adding bus instance properties under
- *   /sys/devices/<businstancename>.  But I thought there may be existing
- *   notions that ONLY device sub-trees should live under
- *   /sys/devices/<businstancename>.  So I stayed out of there.
- *
- */
-
-struct businst_attribute {
-	struct attribute attr;
-	 ssize_t (*show)(struct visorbus_devdata*, char *buf);
-	 ssize_t (*store)(struct visorbus_devdata*, const char *buf,
-			  size_t count);
-};
-
-#define to_businst_attr(_attr) \
-	container_of(_attr, struct businst_attribute, attr)
 #define to_visorbus_devdata(obj) \
 	container_of(obj, struct visorbus_devdata, dev)
 
-static ssize_t
-businst_attr_show(struct kobject *kobj, struct attribute *attr,
-		  char *buf)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->show)
-		ret = businst_attr->show(bus, buf);
-	return ret;
-}
-
-static ssize_t
-businst_attr_store(struct kobject *kobj, struct attribute *attr,
-		   const char *buf, size_t count)
-{
-	struct businst_attribute *businst_attr = to_businst_attr(attr);
-	struct visorbus_devdata *bus = to_visorbus_devdata(kobj);
-	ssize_t ret = 0;
-
-	if (businst_attr->store)
-		ret = businst_attr->store(bus, buf, count);
-	return ret;
-}
-
-static int
-businst_create_file(struct visorbus_devdata *bus,
-		    struct businst_attribute *attr)
-{
-	return sysfs_create_file(&bus->kobj, &attr->attr);
-}
-
-static void
-businst_remove_file(struct visorbus_devdata *bus,
-		    struct businst_attribute *attr)
-{
-	sysfs_remove_file(&bus->kobj, &attr->attr);
-}
-
-static const struct sysfs_ops businst_sysfs_ops = {
-	.show = businst_attr_show,
-	.store = businst_attr_store,
-};
-
-static struct kobj_type businst_kobj_type = {
-	.sysfs_ops = &businst_sysfs_ops
-};
-
-static struct kset businstances = { /* should actually be a member of
-				     * bus_type */
-};
-
 /*  BUS type attributes
  *
  *  define & implement display of bus attributes under
@@ -736,23 +631,6 @@ register_bustype_attributes(void)
 	int rc = 0;
 
 	rc = bus_create_file(&visorbus_type, &bustype_attr_version);
-	if (rc < 0)
-			goto away;
-
-	/* Here we make up for the fact that bus_type does not yet have a
-	 * member to keep track of multiple bus instances for a given bus
-	 * type.  This is useful for stashing properties for each bus
-	 * instance.
-	 */
-	kobject_set_name(&businstances.kobj, "busses");
-	businstances.kobj.ktype = &businst_kobj_type;
-	businstances.kobj.parent = &visorbus_type.p->subsys.kobj;
-	rc = kset_register(&businstances);
-	if (rc < 0)
-			goto away;
-
-	rc = 0;
-away:
 	return rc;
 }
 
@@ -760,7 +638,6 @@ static void
 unregister_bustype_attributes(void)
 {
 	bus_remove_file(&visorbus_type, &bustype_attr_version);
-	kset_unregister(&businstances);
 }
 
 /*  BUS instance attributes
@@ -917,21 +794,6 @@ static ssize_t client_bus_info_show(struct device *dev,
 	return PAGE_SIZE - remain;
 }
 
-static struct businst_attribute ba_partition_handle =
-	__ATTR(partition_handle, S_IRUGO, businst_attr_partition_handle, NULL);
-static struct businst_attribute ba_partition_guid =
-	__ATTR(partition_guid, S_IRUGO, businst_attr_partition_guid, NULL);
-static struct businst_attribute ba_partition_name =
-	__ATTR(partition_name, S_IRUGO, businst_attr_partition_name, NULL);
-static struct businst_attribute ba_channel_addr =
-	__ATTR(channel_addr, S_IRUGO, businst_attr_channel_addr, NULL);
-static struct businst_attribute ba_nchannel_bytes =
-	__ATTR(nchannel_bytes, S_IRUGO, businst_attr_nchannel_bytes, NULL);
-static struct businst_attribute ba_channel_id =
-	__ATTR(channel_id, S_IRUGO, businst_attr_channel_id, NULL);
-static struct businst_attribute ba_client_bus_info =
-	__ATTR(client_bus_info, S_IRUGO, businst_attr_client_bus_info, NULL);
-
 static DEVICE_ATTR_RO(partition_handle);
 static DEVICE_ATTR_RO(partition_guid);
 static DEVICE_ATTR_RO(partition_name);
@@ -960,65 +822,6 @@ static const struct attribute_group *visorbus_groups[] = {
 		NULL
 };
 
-static int
-register_businst_attributes(struct visorbus_devdata *businst)
-{
-	int rc = 0;
-
-	businst->kobj.kset = &businstances;	/* identify parent sysfs dir */
-	rc = kobject_init_and_add(&businst->kobj, &businst_kobj_type,
-				  NULL, "visorbus%d", businst->devno);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_partition_handle);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_partition_guid);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_partition_name);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_channel_addr);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_nchannel_bytes);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_channel_id);
-	if (rc < 0)
-			goto away;
-
-	rc = businst_create_file(businst, &ba_client_bus_info);
-	if (rc < 0)
-			goto away;
-
-	kobject_uevent(&businst->kobj, KOBJ_ADD);
-
-	rc = 0;
-away:
-	return rc;
-}
-
-static void
-unregister_businst_attributes(struct visorbus_devdata *businst)
-{
-	businst_remove_file(businst, &ba_partition_handle);
-	businst_remove_file(businst, &ba_partition_guid);
-	businst_remove_file(businst, &ba_partition_name);
-	businst_remove_file(businst, &ba_channel_addr);
-	businst_remove_file(businst, &ba_nchannel_bytes);
-	businst_remove_file(businst, &ba_channel_id);
-	businst_remove_file(businst, &ba_client_bus_info);
-	kobject_put(&businst->kobj);
-}
-
 /*  DRIVER attributes
  *
  *  define & implement display of driver attributes under
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 118/141] staging: unisys: Properly move version file into bus attr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (116 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 117/141] staging: unisys: remove unused bus attribute code Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 119/141] staging: unisys: Remove dead kobj structs Benjamin Romer
                   ` (25 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Simplify things by moving the version file handling into the core.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 66 +++++++++++--------------
 1 file changed, 30 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 4c35d34..b3e69d6 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -88,6 +88,35 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
 static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
 static void fix_vbus_dev_info(struct visor_device *visordev);
 
+/*  BUS type attributes
+ *
+ *  define & implement display of bus attributes under
+ *  /sys/bus/visorbus.
+ *
+ */
+
+static ssize_t version_show(struct bus_type *bus, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%s\n", VERSION);
+}
+
+static BUS_ATTR_RO(version);
+
+static struct attribute *visorbus_bus_attrs[] = {
+	&bus_attr_version.attr,
+	NULL,
+};
+
+static const struct attribute_group visorbus_bus_group = {
+	.attrs = visorbus_bus_attrs,
+};
+
+const struct attribute_group *visorbus_bus_groups[] = {
+	&visorbus_bus_group,
+	NULL,
+};
+
+
 /** This describes the TYPE of bus.
  *  (Don't confuse this with an INSTANCE of the bus.)
  */
@@ -95,6 +124,7 @@ static struct bus_type visorbus_type = {
 	.name = "visorbus",
 	.match = visorbus_match,
 	.uevent = visorbus_uevent,
+	.bus_groups = visorbus_bus_groups,
 };
 
 static struct delayed_work periodic_work;
@@ -609,37 +639,6 @@ void unregister_channel_attributes(struct visor_device *dev)
 #define to_visorbus_devdata(obj) \
 	container_of(obj, struct visorbus_devdata, dev)
 
-/*  BUS type attributes
- *
- *  define & implement display of bus attributes under
- *  /sys/bus/visorbus.
- *
- */
-
-static ssize_t
-BUSTYPE_ATTR_version(struct bus_type *bus, char *buf)
-{
-	return snprintf(buf, PAGE_SIZE, "%s\n", VERSION);
-}
-
-static struct bus_attribute bustype_attr_version =
-__ATTR(version, S_IRUGO, BUSTYPE_ATTR_version, NULL);
-
-static int
-register_bustype_attributes(void)
-{
-	int rc = 0;
-
-	rc = bus_create_file(&visorbus_type, &bustype_attr_version);
-	return rc;
-}
-
-static void
-unregister_bustype_attributes(void)
-{
-	bus_remove_file(&visorbus_type, &bustype_attr_version);
-}
-
 /*  BUS instance attributes
  *
  *  define & implement display of bus attributes under
@@ -1580,10 +1579,6 @@ create_bus_type(void)
 
 	visorbus_type.dev_attrs = visor_device_attrs;
 	rc = bus_register(&visorbus_type);
-	if (rc < 0)
-			return rc;
-
-	rc = register_bustype_attributes();
 	return rc;
 }
 
@@ -1592,7 +1587,6 @@ create_bus_type(void)
 static void
 remove_bus_type(void)
 {
-	unregister_bustype_attributes();
 	bus_unregister(&visorbus_type);
 }
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 119/141] staging: unisys: Remove dead kobj structs
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (117 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 118/141] staging: unisys: Properly move version file into bus attr Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 120/141] staging: unisys: Clean up device sysfs attributes Benjamin Romer
                   ` (24 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Remove stale code.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 32 -------------------------
 1 file changed, 32 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index b3e69d6..8237f92 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -48,38 +48,6 @@ struct visorbus_devdata {
 	struct spar_vbus_headerinfo vbus_hdr_info;
 };
 
-/* These forward declarations are required since our drivers are out-of-tree.
- * The structures referenced are kernel-private and are not in the headers, but
- * it is impossible to make a functioning bus driver without them.
- */
-struct subsys_private {
-	struct kset subsys;
-	struct kset *devices_kset;
-
-	struct kset *drivers_kset;
-	struct klist klist_devices;
-	struct klist klist_drivers;
-	struct blocking_notifier_head bus_notifier;
-	unsigned int drivers_autoprobe:1;
-	struct bus_type *bus;
-
-	struct list_head class_interfaces;
-	struct kset glue_dirs;
-	struct mutex class_mutex; /* ignore */
-	struct class *class;
-};
-
-struct bus_type_private {
-	struct kset subsys;
-	struct kset *drivers_kset;
-	struct kset *devices_kset;
-	struct klist klist_devices;
-	struct klist klist_drivers;
-	struct blocking_notifier_head bus_notifier;
-	unsigned int drivers_autoprobe:1;
-	struct bus_type *bus;
-};
-
 #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
 #define POLLJIFFIES_TESTWORK         100
 #define POLLJIFFIES_NORMALCHANNEL     10
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 120/141] staging: unisys: Clean up device sysfs attributes
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (118 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 119/141] staging: unisys: Remove dead kobj structs Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 121/141] staging: unisys: Prep for removing 'info' structs Benjamin Romer
                   ` (23 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Properly hook into the struct device groups element.  This allows the
core
infrastructure to manage the files instead of the bus layer.  And makes
the code easier to read.

I didn't clean up the _show functions just modified them a bit to handle
the different args for now.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h       |   1 -
 drivers/staging/unisys/visorbus/visorbus_main.c | 219 +++++++-----------------
 2 files changed, 65 insertions(+), 155 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index d542822..6c551df 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -128,7 +128,6 @@ struct visor_device {
 	struct periodic_work *periodic_work;
 	bool being_removed;
 	bool responded_to_device_create;
-	struct kobject kobjchannel;	/* visorbus<x>/dev<y>/channel/ */
 	struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
 	struct {
 		int major, minor;
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 8237f92..6bd7ef5 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -396,97 +396,97 @@ unregister_devmajorminor_attributes(struct visor_device *dev)
 	dev->kobjdevmajorminor.parent = NULL;
 }
 
-/* Implement publishing of channel attributes under:
- *
- *     /sys/bus/visorbus<x>/dev<y>/channel
- *
- */
-
-#define to_channel_attr(_attr) \
-	container_of(_attr, struct channel_attribute, attr)
-#define to_visor_device_from_kobjchannel(obj) \
-	container_of(obj, struct visor_device, kobjchannel)
-
-struct channel_attribute {
-	struct attribute attr;
-	 ssize_t (*show)(struct visor_device*, char *buf);
-	 ssize_t (*store)(struct visor_device*, const char *buf, size_t count);
-};
-
 /* begin implementation of specific channel attributes to appear under
 * /sys/bus/visorbus<x>/dev<y>/channel
 */
-static ssize_t devicechannel_attr_physaddr(struct visor_device *dev, char *buf)
+static ssize_t physaddr_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
 {
-	if (!dev->visorchannel)
+	struct visor_device *vdev = to_visor_device(dev);
+
+	if (!vdev->visorchannel)
 		return 0;
 	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
-			visorchannel_get_physaddr(dev->visorchannel));
+			visorchannel_get_physaddr(vdev->visorchannel));
 }
 
-static ssize_t devicechannel_attr_nbytes(struct visor_device *dev, char *buf)
+static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr,
+			   char *buf)
 {
-	if (!dev->visorchannel)
+	struct visor_device *vdev = to_visor_device(dev);
+
+	if (!vdev->visorchannel)
 		return 0;
 	return snprintf(buf, PAGE_SIZE, "0x%lx\n",
-			visorchannel_get_nbytes(dev->visorchannel));
+			visorchannel_get_nbytes(vdev->visorchannel));
 }
 
-static ssize_t devicechannel_attr_clientpartition(struct visor_device *dev,
-						  char *buf) {
-	if (!dev->visorchannel)
+static ssize_t clientpartition_show(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	struct visor_device *vdev = to_visor_device(dev);
+
+	if (!vdev->visorchannel)
 		return 0;
 	return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
-			visorchannel_get_clientpartition(dev->visorchannel));
+			visorchannel_get_clientpartition(vdev->visorchannel));
 }
 
-static ssize_t devicechannel_attr_typeguid(struct visor_device *dev, char *buf)
+static ssize_t typeguid_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
 {
+	struct visor_device *vdev = to_visor_device(dev);
 	char s[99];
 
-	if (!dev->visorchannel)
+	if (!vdev->visorchannel)
 		return 0;
 	return snprintf(buf, PAGE_SIZE, "%s\n",
-			visorchannel_id(dev->visorchannel, s));
+			visorchannel_id(vdev->visorchannel, s));
 }
 
-static ssize_t devicechannel_attr_zoneguid(struct visor_device *dev, char *buf)
+static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
 {
+	struct visor_device *vdev = to_visor_device(dev);
 	char s[99];
 
-	if (!dev->visorchannel)
+	if (!vdev->visorchannel)
 		return 0;
 	return snprintf(buf, PAGE_SIZE, "%s\n",
-			visorchannel_zoneid(dev->visorchannel, s));
+			visorchannel_zoneid(vdev->visorchannel, s));
 }
 
-static ssize_t devicechannel_attr_typename(struct visor_device *dev, char *buf)
+static ssize_t typename_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
 {
+	struct visor_device *vdev = to_visor_device(dev);
 	int i = 0;
-	struct bus_type *xbus = dev->device.bus;
-	struct device_driver *xdrv = dev->device.driver;
+	struct bus_type *xbus = dev->bus;
+	struct device_driver *xdrv = dev->driver;
 	struct visor_driver *drv = NULL;
 
-	if (!dev->visorchannel || !xbus || !xdrv)
+	if (!vdev->visorchannel || !xbus || !xdrv)
 		return 0;
-	i = xbus->match(&dev->device, xdrv);
+	i = xbus->match(dev, xdrv);
 	if (!i)
 		return 0;
 	drv = to_visor_driver(xdrv);
 	return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
 }
 
-static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf)
+static ssize_t dump_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
 {
+	struct visor_device *vdev = to_visor_device(dev);
 	int count = 0;
 /* TODO: replace this with debugfs code
 	struct seq_file *m = NULL;
-	if (dev->visorchannel == NULL)
+	if (vdev->visorchannel == NULL)
 		return 0;
 	m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
 	if (m == NULL)
 		return 0;
-	visorchannel_debug(dev->visorchannel, 1, m, 0);
+	visorchannel_debug(vdev->visorchannel, 1, m, 0);
 	count = m->count;
 	visor_seq_file_done_buffer(m);
 	m = NULL;
@@ -494,116 +494,36 @@ static ssize_t devicechannel_attr_dump(struct visor_device *dev, char *buf)
 	return count;
 }
 
-static struct channel_attribute all_channel_attrs[] = {
-	__ATTR(physaddr, S_IRUGO,
-	       devicechannel_attr_physaddr, NULL),
-	__ATTR(nbytes, S_IRUGO,
-	       devicechannel_attr_nbytes, NULL),
-	__ATTR(clientpartition, S_IRUGO,
-	       devicechannel_attr_clientpartition, NULL),
-	__ATTR(typeguid, S_IRUGO,
-	       devicechannel_attr_typeguid, NULL),
-	__ATTR(zoneguid, S_IRUGO,
-	       devicechannel_attr_zoneguid, NULL),
-	__ATTR(typename, S_IRUGO,
-	       devicechannel_attr_typename, NULL),
-	__ATTR(dump, S_IRUGO,
-	       devicechannel_attr_dump, NULL),
+static DEVICE_ATTR_RO(physaddr);
+static DEVICE_ATTR_RO(nbytes);
+static DEVICE_ATTR_RO(clientpartition);
+static DEVICE_ATTR_RO(typeguid);
+static DEVICE_ATTR_RO(zoneguid);
+static DEVICE_ATTR_RO(typename);
+static DEVICE_ATTR_RO(dump);
+
+static struct attribute *channel_attrs[] = {
+		&dev_attr_physaddr.attr,
+		&dev_attr_nbytes.attr,
+		&dev_attr_clientpartition.attr,
+		&dev_attr_typeguid.attr,
+		&dev_attr_zoneguid.attr,
+		&dev_attr_typename.attr,
+		&dev_attr_dump.attr,
 };
 
-/* end implementation of specific channel attributes */
-
-static ssize_t channel_attr_show(struct kobject *kobj, struct attribute *attr,
-				 char *buf)
-{
-	struct channel_attribute *channel_attr = to_channel_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
-	ssize_t ret = 0;
-
-	if (channel_attr->show)
-		ret = channel_attr->show(dev, buf);
-	return ret;
-}
-
-static ssize_t channel_attr_store(struct kobject *kobj, struct attribute *attr,
-				  const char *buf, size_t count)
-{
-	struct channel_attribute *channel_attr = to_channel_attr(attr);
-	struct visor_device *dev = to_visor_device_from_kobjchannel(kobj);
-	ssize_t ret = 0;
-
-	if (channel_attr->store)
-		ret = channel_attr->store(dev, buf, count);
-	return ret;
-}
-
-static int channel_create_file(struct visor_device *dev,
-			       struct channel_attribute *attr)
-{
-	return sysfs_create_file(&dev->kobjchannel, &attr->attr);
-}
-
-static void channel_remove_file(struct visor_device *dev,
-				struct channel_attribute *attr)
-{
-	sysfs_remove_file(&dev->kobjchannel, &attr->attr);
-}
-
-static const struct sysfs_ops channel_sysfs_ops = {
-	.show = channel_attr_show,
-	.store = channel_attr_store,
+static struct attribute_group channel_attr_grp = {
+		.name = "channel",
+		.attrs = channel_attrs,
 };
 
-static struct kobj_type channel_kobj_type = {
-	.sysfs_ops = &channel_sysfs_ops
+static const struct attribute_group *visorbus_dev_groups[] = {
+		&channel_attr_grp,
+		NULL
 };
 
-int register_channel_attributes(struct visor_device *dev)
-{
-	int rc = 0, i = 0, x = 0;
-
-	if (dev->kobjchannel.parent)
-		goto away;	/* already registered */
-	x = kobject_init_and_add(&dev->kobjchannel, &channel_kobj_type,
-				 &dev->device.kobj, "channel");
-	if (x < 0) {
-		rc = x;
-		goto away;
-	}
-
-	kobject_uevent(&dev->kobjchannel, KOBJ_ADD);
-
-	for (i = 0;
-	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
-	     i++)
-		x = channel_create_file(dev, &all_channel_attrs[i]);
-	if (x < 0) {
-		while (--i >= 0)
-			channel_remove_file(dev, &all_channel_attrs[i]);
-		kobject_del(&dev->kobjchannel);
-		kobject_put(&dev->kobjchannel);
-		rc = x;
-		goto away;
-	}
-away:
-	return rc;
-}
-
-void unregister_channel_attributes(struct visor_device *dev)
-{
-	int i = 0;
-
-	if (!dev->kobjchannel.parent)
-		return;		/* already unregistered */
-	for (i = 0;
-	     i < sizeof(all_channel_attrs) / sizeof(struct channel_attribute);
-	     i++)
-		channel_remove_file(dev, &all_channel_attrs[i]);
+/* end implementation of specific channel attributes */
 
-	kobject_del(&dev->kobjchannel);
-	kobject_put(&dev->kobjchannel);
-	dev->kobjchannel.parent = NULL;
-}
 #define to_visorbus_devdata(obj) \
 	container_of(obj, struct visorbus_devdata, dev)
 
@@ -1144,6 +1064,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 	dev->device.parent = &devdata->dev;
 	sema_init(&dev->visordriver_callback_lock, 1);	/* unlocked */
 	dev->device.bus = &visorbus_type;
+	dev->device.groups = visorbus_dev_groups;
 	device_initialize(&dev->device);
 	dev->device.release = visorbus_release_device;
 	/* keep a reference just for us (now 2) */
@@ -1191,13 +1112,6 @@ create_visor_device(struct visorbus_devdata *devdata,
 	}
 
 	/* note: device_register is simply device_initialize + device_add */
-	rc = register_channel_attributes(dev);
-	if (rc < 0) {
-		POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
-				 DIAG_SEVERITY_ERR);
-		goto away;
-	}
-
 	registered1 = true;
 
 	rc = register_devmajorminor_attributes(dev);
@@ -1214,8 +1128,6 @@ away:
 	if (rc < 0) {
 		if (registered2)
 			unregister_devmajorminor_attributes(dev);
-		if (registered1)
-			unregister_channel_attributes(dev);
 		if (gotten)
 			put_device(&dev->device);
 		if (visorchannel)
@@ -1233,7 +1145,6 @@ remove_visor_device(struct visor_device *dev)
 {
 	list_del(&dev->list_all);
 	unregister_devmajorminor_attributes(dev);
-	unregister_channel_attributes(dev);
 	put_device(&dev->device);
 	device_unregister(&dev->device);
 }
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 121/141] staging: unisys: Prep for removing 'info' structs
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (119 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 120/141] staging: unisys: Clean up device sysfs attributes Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 122/141] staging: unisys: Add visor device find routine Benjamin Romer
                   ` (22 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The visorbus driver has three _info structs lying around
(device, bus, channel) that store subsets of info from the
bigger structs.

Having these structs around make resource handling very difficult
and more complicated than it needs to be.  Use the device
infrastructure and instead pass 'struct visor_device' all
over the place.

In order to do that 'struct visor_device' needs to get smarter.
This patch adds the pieces to prep for it.  The new elements
will be used in later patches.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h          | 22 ++++++++++++++++++++++
 drivers/staging/unisys/visorbus/visorbus_private.h |  9 ---------
 drivers/staging/unisys/visorbus/visorchannel.c     |  4 ++++
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 6c551df..bba4825 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -37,12 +37,23 @@
 
 #include "periodic_work.h"
 #include "channel.h"
+#include "controlvmchannel.h"
+#include "vbuschannel.h"
 
 struct visor_driver;
 struct visor_device;
+extern struct bus_type visorbus_type;
 
 typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
 					      int status);
+struct visorchipset_state {
+	u32 created:1;
+	u32 attached:1;
+	u32 configured:1;
+	u32 running:1;
+	/* Add new fields above. */
+	/* Remaining bits in this 32-bit word are unused. */
+};
 
 /** This struct describes a specific Supervisor channel, by providing its
  *  GUID, name, and sizes.
@@ -141,6 +152,17 @@ struct visor_device {
 	bool resuming;
 	unsigned long chipset_bus_no;
 	unsigned long chipset_dev_no;
+	struct visorchipset_state state;
+	uuid_le type;
+	uuid_le inst;
+	u8 *name;
+	u8 *description;
+	struct controlvm_message_header pending_msg_hdr;
+	struct spar_vbus_headerinfo vbus_hdr_info;
+	u32 switch_no;
+	u32 internal_port_no;
+	uuid_le partition_uuid;
+	struct irq_info intr;
 };
 
 #define to_visor_device(x) container_of(x, struct visor_device, device)
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 8326e4d..bbc64bd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -27,15 +27,6 @@
 
 struct visorchannel;
 
-struct visorchipset_state {
-	u32 created:1;
-	u32 attached:1;
-	u32 configured:1;
-	u32 running:1;
-	/* Add new fields above. */
-	/* Remaining bits in this 32-bit word are unused. */
-};
-
 enum visorchipset_addresstype {
 	/** address is guest physical, but outside of the physical memory
 	 *  region that is controlled by the running OS (this is the normal
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 2d3e4d6..a9c3ae1 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -23,6 +23,7 @@
 #include "version.h"
 #include "visorbus.h"
 #include <linux/uuid.h>
+#include "controlvmchannel.h"
 
 #define MYDRVNAME "visorchannel"
 
@@ -44,6 +45,9 @@ struct visorchannel {
 		struct signal_queue_header event_queue;
 		struct signal_queue_header ack_queue;
 	} safe_uis_queue;
+	struct irq_info intr;
+	uuid_le type;
+	uuid_le inst;
 };
 
 /* Creates the struct visorchannel abstraction for a data area in memory,
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 122/141] staging: unisys: Add visor device find routine
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (120 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 121/141] staging: unisys: Prep for removing 'info' structs Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 123/141] staging: unisys: Add a function to set the clientpartition Benjamin Romer
                   ` (21 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

If we are going to remove the bus_info structs than we need a way
to find the devices when the *_create/destroy cmds are sent over
the vmchannel.

This function crudely impements what pci has.  It takes a bus_no
and dev_no and finds the matching 'struct visor_device'.

This function can/should be optimzed later once we get our heads
wrapped around its needs.  For now, I am using dev_no=0 to mean
the visorbus itself.

The function is limited to chipset.c only because it is only needed
to do the lookups upon receiving a vmchannel command.  Future patches
will make sure the resulting 'struct visor_device' is used every
where else.

Also allow visorbus_type to be more visible for use.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c |  2 +-
 drivers/staging/unisys/visorbus/visorchipset.c  | 39 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 6bd7ef5..bc865cd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -88,7 +88,7 @@ const struct attribute_group *visorbus_bus_groups[] = {
 /** This describes the TYPE of bus.
  *  (Don't confuse this with an INSTANCE of the bus.)
  */
-static struct bus_type visorbus_type = {
+struct bus_type visorbus_type = {
 	.name = "visorbus",
 	.match = visorbus_match,
 	.uevent = visorbus_uevent,
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index b96a40c..42bf02a 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -711,6 +711,45 @@ dev_info_clear(void *v)
 	memset(p, 0, sizeof(struct visorchipset_device_info));
 }
 
+struct visor_busdev {
+	u32 bus_no;
+	u32 dev_no;
+};
+
+static int match_visorbus_dev_by_id(struct device *dev, void *data)
+{
+	struct visor_device *vdev = to_visor_device(dev);
+	struct visor_busdev *id = (struct visor_busdev *)data;
+	u32 bus_no = id->bus_no;
+	u32 dev_no = id->dev_no;
+
+	if (((bus_no == -1) || (vdev->chipset_bus_no == bus_no)) &&
+	    ((dev_no == -1) || (vdev->chipset_dev_no == dev_no)))
+		return 1;
+
+	return 0;
+}
+struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
+					       struct visor_device *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct visor_device *vdev = NULL;
+	struct visor_busdev id = {
+			.bus_no = bus_no,
+			.dev_no = dev_no
+		};
+
+	if (from)
+		dev_start = &from->device;
+	dev = bus_find_device(&visorbus_type, dev_start, (void *)&id,
+			      match_visorbus_dev_by_id);
+	if (dev)
+		vdev = to_visor_device(dev);
+	return vdev;
+}
+EXPORT_SYMBOL(visorbus_get_device_by_id);
+
 static struct visorchipset_bus_info *
 bus_find(struct list_head *list, u32 bus_no)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 123/141] staging: unisys: Add a function to set the clientpartition
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (121 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 122/141] staging: unisys: Add visor device find routine Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 124/141] staging: unisys: Add checks for creation Benjamin Romer
                   ` (20 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This patch is an attempt to help hide the channel info behind
accessory functions.  I was trying to keep visorchannel as private
as possible.

The only function missing that seemed to be needed for now was
the ability to set the clientpartition.  So I expose that here.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      | 2 ++
 drivers/staging/unisys/visorbus/visorchannel.c | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index bba4825..32de5aa 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -213,6 +213,8 @@ ulong visorchannel_get_nbytes(struct visorchannel *channel);
 char *visorchannel_id(struct visorchannel *channel, char *s);
 char *visorchannel_zoneid(struct visorchannel *channel, char *s);
 u64 visorchannel_get_clientpartition(struct visorchannel *channel);
+int visorchannel_set_clientpartition(struct visorchannel *channel,
+				     u64 partition_handle);
 uuid_le visorchannel_get_uuid(struct visorchannel *channel);
 char *visorchannel_uuid_id(uuid_le *guid, char *s);
 void visorchannel_debug(struct visorchannel *channel, int num_queues,
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index a9c3ae1..1789f9d 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -190,6 +190,15 @@ visorchannel_get_clientpartition(struct visorchannel *channel)
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
 
+int
+visorchannel_set_clientpartition(struct visorchannel *channel,
+				 u64 partition_handle)
+{
+	channel->chan_hdr.partition_handle = partition_handle;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(visorchannel_set_clientpartition);
+
 uuid_le
 visorchannel_get_uuid(struct visorchannel *channel)
 {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 124/141] staging: unisys: Add checks for creation
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (122 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 123/141] staging: unisys: Add a function to set the clientpartition Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device Benjamin Romer
                   ` (19 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

There was a bunch of channel creation checks before the
visorchannel_create function was called, moving some of those
checks inside.  This keeps the outside code cleaner and handles
the situation where a caller forgets to make these checks.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 1789f9d..6e7675e 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -62,6 +62,9 @@ visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes,
 	int err;
 	size_t size = sizeof(struct channel_header);
 
+	if (physaddr == 0)
+		return NULL;
+
 	channel = kzalloc(sizeof(*channel), gfp);
 	if (!channel)
 		goto cleanup;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (123 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 124/141] staging: unisys: Add checks for creation Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-09  9:01   ` Dan Carpenter
  2015-05-05 22:37 ` [PATCH 126/141] staging: unisys: Convert the epilog " Benjamin Romer
                   ` (18 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This patch handles the first round of conversion of the initial
vmchannel command to use/allocate a struct visor_device instead
of the _info struct.

This is accomplished by using the find_device_by_id function implemented
in an earlier patch.  Most of the conversion is straight forward.

Notable differences:
  - visor_device allocation happens here instead of visorbus_main.c
    -> just easier to initialize the data than pass it along.
  - visor channel allocation happens here instead of later
    -> the channel info is in inmsg, use it now as opposed to
       passing it along (visor channel deletion is broken because
       my brain melted on trying to understand the proper cleanup path)
  - device_creation bus and dev lookups could be better
    -> I hacked up an initial implementation to get me going,
       in retrospect we could probably use for_each_child_device or
       something.  Add that to the TODO list. :-)

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 121 +++++++++++++------------
 1 file changed, 63 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 42bf02a..c8f8b56 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1197,9 +1197,10 @@ bus_create(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->create_bus.bus_no;
 	int rc = CONTROLVM_RESP_SUCCESS;
-	struct visorchipset_bus_info *bus_info;
+	struct visor_device *bus_info;
+	struct visorchannel *visorchannel;
 
-	bus_info = bus_find(&bus_info_list, bus_no);
+	bus_info = visorbus_get_device_by_id(bus_no, 0, NULL);
 	if (bus_info && (bus_info->state.created == 1)) {
 		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1214,29 +1215,27 @@ bus_create(struct controlvm_message *inmsg)
 		goto cleanup;
 	}
 
-	INIT_LIST_HEAD(&bus_info->entry);
-	bus_info->bus_no = bus_no;
+	bus_info->chipset_bus_no = bus_no;
 
 	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
-	if (inmsg->hdr.flags.test_message == 1)
-		bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
-	else
-		bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-
-	bus_info->flags.server = inmsg->hdr.flags.server;
-	bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
-	bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
-	bus_info->chan_info.channel_type_uuid =
-			cmd->create_bus.bus_data_type_uuid;
-	bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
-
-	list_add(&bus_info->entry, &bus_info_list);
+	visorchannel = visorchannel_create(cmd->create_bus.channel_addr,
+					   cmd->create_bus.channel_bytes,
+					   GFP_KERNEL,
+					   cmd->create_bus.bus_data_type_uuid);
+	if (!visorchannel) {
+		rc = -ENOMEM;
+		/*TODO free bus_info*/
+		goto cleanup;
+	}
+	bus_info->visorchannel = visorchannel;
+	bus_info->type = cmd->create_bus.bus_data_type_uuid;
+	bus_info->inst = cmd->create_bus.bus_inst_uuid;
 
 	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
 cleanup:
-	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
+	bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
 		   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1245,16 +1244,16 @@ bus_destroy(struct controlvm_message *inmsg)
 {
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->destroy_bus.bus_no;
-	struct visorchipset_bus_info *bus_info;
+	struct visor_device *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	bus_info = bus_find(&bus_info_list, bus_no);
+	bus_info = visorbus_get_device_by_id(bus_no, 0, NULL);
 	if (!bus_info)
 		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 	else if (bus_info->state.created == 0)
 		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 
-	bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
+	bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
 		   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1264,15 +1263,14 @@ bus_configure(struct controlvm_message *inmsg,
 {
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no;
-	struct visorchipset_bus_info *bus_info;
+	struct visor_device *bus_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
-	char s[99];
 
 	bus_no = cmd->configure_bus.bus_no;
 	POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	bus_info = bus_find(&bus_info_list, bus_no);
+	bus_info = visorbus_get_device_by_id(bus_no, 0, NULL);
 	if (!bus_info) {
 		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1286,16 +1284,16 @@ bus_configure(struct controlvm_message *inmsg,
 				 POSTCODE_SEVERITY_ERR);
 		rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
 	} else {
-		bus_info->partition_handle = cmd->configure_bus.guest_handle;
+		visorchannel_set_clientpartition(bus_info->visorchannel,
+				cmd->configure_bus.guest_handle);
 		bus_info->partition_uuid = parser_id_get(parser_ctx);
 		parser_param_start(parser_ctx, PARSERSTRING_NAME);
 		bus_info->name = parser_string_get(parser_ctx);
 
-		visorchannel_uuid_id(&bus_info->partition_uuid, s);
 		POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
 				 POSTCODE_SEVERITY_INFO);
 	}
-	bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
+	bus_epilog(bus_info, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
 		   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1305,28 +1303,30 @@ my_device_create(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->create_device.bus_no;
 	u32 dev_no = cmd->create_device.dev_no;
-	struct visorchipset_device_info *dev_info;
-	struct visorchipset_bus_info *bus_info;
+	struct visor_device *bus_info;
+	struct visor_device *dev_info = NULL;
+	struct visorchannel *visorchannel;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
-	if (dev_info && (dev_info->state.created == 1)) {
+	bus_info = visorbus_get_device_by_id(bus_no, 0, NULL);
+	if (!bus_info) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 		goto cleanup;
 	}
-	bus_info = bus_find(&bus_info_list, bus_no);
-	if (!bus_info) {
+	if (bus_info->state.created == 0) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
 		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 		goto cleanup;
 	}
-	if (bus_info->state.created == 0) {
+
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
+	if (dev_info && (dev_info->state.created == 1)) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 		goto cleanup;
 	}
 	dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
@@ -1337,33 +1337,38 @@ my_device_create(struct controlvm_message *inmsg)
 		goto cleanup;
 	}
 
-	INIT_LIST_HEAD(&dev_info->entry);
-	dev_info->bus_no = bus_no;
-	dev_info->dev_no = dev_no;
-	dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
+	INIT_LIST_HEAD(&dev_info->list_all);
+	dev_info->chipset_bus_no = bus_no;
+	dev_info->chipset_dev_no = dev_no;
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	if (inmsg->hdr.flags.test_message == 1)
-		dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
-	else
-		dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-	dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
-	dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
-	dev_info->chan_info.channel_type_uuid =
-			cmd->create_device.data_type_uuid;
-	dev_info->chan_info.intr = cmd->create_device.intr;
-	list_add(&dev_info->entry, &dev_info_list);
+	visorchannel = visorchannel_create(cmd->create_device.channel_addr,
+					   cmd->create_device.channel_bytes,
+					   GFP_KERNEL,
+					   cmd->create_device.data_type_uuid);
+	if (!visorchannel) {
+		rc = -ENOMEM;
+		/*TODO free dev_info*/
+		goto cleanup;
+	}
+	dev_info->visorchannel = visorchannel;
+	dev_info->type = cmd->create_device.data_type_uuid;
+	dev_info->inst = cmd->create_device.dev_inst_uuid;
+	dev_info->intr = cmd->create_device.intr;
+
+	/* not sure where the best place to set the 'parent' */
+	dev_info->device.parent = &bus_info->device;
 	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 cleanup:
 	/* get the bus and devNo for DiagPool channel */
 	if (dev_info &&
-	    is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
+	    is_diagpool_channel(cmd->create_device.data_type_uuid)) {
 		g_diagpool_bus_no = bus_no;
 		g_diagpool_dev_no = dev_no;
 	}
-	device_epilog(bus_no, dev_no, segment_state_running,
+	device_epilog(dev_info, segment_state_running,
 		      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
 		      inmsg->hdr.flags.response_expected == 1, 1);
 }
@@ -1375,10 +1380,10 @@ my_device_changestate(struct controlvm_message *inmsg)
 	u32 bus_no = cmd->device_change_state.bus_no;
 	u32 dev_no = cmd->device_change_state.dev_no;
 	struct spar_segment_state state = cmd->device_change_state.state;
-	struct visorchipset_device_info *dev_info;
+	struct visor_device *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
 	if (!dev_info) {
 		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1389,7 +1394,7 @@ my_device_changestate(struct controlvm_message *inmsg)
 		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
 	}
 	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
-		device_epilog(bus_no, dev_no, state,
+		device_epilog(dev_info, state,
 			      CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
 			      inmsg->hdr.flags.response_expected == 1, 1);
 }
@@ -1400,17 +1405,17 @@ my_device_destroy(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->destroy_device.bus_no;
 	u32 dev_no = cmd->destroy_device.dev_no;
-	struct visorchipset_device_info *dev_info;
+	struct visor_device *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
 	if (!dev_info)
 		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
 	else if (dev_info->state.created == 0)
 		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 
 	if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
-		device_epilog(bus_no, dev_no, segment_state_running,
+		device_epilog(dev_info, segment_state_running,
 			      CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
 			      inmsg->hdr.flags.response_expected == 1, 1);
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (124 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-08  8:00   ` Dan Carpenter
  2015-05-05 22:37 ` [PATCH 127/141] staging: unisys: Convert the notifier " Benjamin Romer
                   ` (17 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This patch is the second wave of changes to the _epilog functions to
struct visor_device.

Straightforward conversion, nothing really complicated here other
than the nice cleanup because device is now known.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 35 +++++++++-----------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index c8f8b56..51d708f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1049,18 +1049,12 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 }
 
 static void
-bus_epilog(u32 bus_no,
+bus_epilog(struct visor_device *bus_info,
 	   u32 cmd, struct controlvm_message_header *msg_hdr,
 	   int response, bool need_response)
 {
-	struct visorchipset_bus_info *bus_info;
 	bool notified = false;
 
-	bus_info = bus_find(&bus_info_list, bus_no);
-
-	if (!bus_info)
-		return;
-
 	if (need_response) {
 		memcpy(&bus_info->pending_msg_hdr, msg_hdr,
 		       sizeof(struct controlvm_message_header));
@@ -1073,13 +1067,13 @@ bus_epilog(u32 bus_no,
 		switch (cmd) {
 		case CONTROLVM_BUS_CREATE:
 			if (busdev_notifiers.bus_create) {
-				(*busdev_notifiers.bus_create) (bus_no);
+				(*busdev_notifiers.bus_create) (bus_info);
 				notified = true;
 			}
 			break;
 		case CONTROLVM_BUS_DESTROY:
 			if (busdev_notifiers.bus_destroy) {
-				(*busdev_notifiers.bus_destroy) (bus_no);
+				(*busdev_notifiers.bus_destroy) (bus_info);
 				notified = true;
 			}
 			break;
@@ -1092,28 +1086,25 @@ bus_epilog(u32 bus_no,
 		 */
 		;
 	else
-		bus_responder(cmd, bus_no, response);
+		bus_responder(cmd, bus_info, response);
 	up(&notifier_lock);
 }
 
 static void
-device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
-	      struct controlvm_message_header *msg_hdr, int response,
+device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
+	      u32 cmd, struct controlvm_message_header *msg_hdr, int response,
 	      bool need_response, bool for_visorbus)
 {
 	struct visorchipset_busdev_notifiers *notifiers;
 	bool notified = false;
+	u32 bus_no = dev_info->chipset_bus_no;
+	u32 dev_no = dev_info->chipset_dev_no;
 
-	struct visorchipset_device_info *dev_info =
-		device_find(&dev_info_list, bus_no, dev_no);
 	char *envp[] = {
 		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
 		NULL
 	};
 
-	if (!dev_info)
-		return;
-
 	notifiers = &busdev_notifiers;
 
 	if (need_response) {
@@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 		switch (cmd) {
 		case CONTROLVM_DEVICE_CREATE:
 			if (notifiers->device_create) {
-				(*notifiers->device_create) (bus_no, dev_no);
+				(*notifiers->device_create) (dev_info);
 				notified = true;
 			}
 			break;
@@ -1138,8 +1129,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 			    state.operating ==
 				segment_state_running.operating) {
 				if (notifiers->device_resume) {
-					(*notifiers->device_resume) (bus_no,
-								     dev_no);
+					(*notifiers->device_resume) (dev_info);
 					notified = true;
 				}
 			}
@@ -1151,8 +1141,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 				 * where server is lost
 				 */
 				if (notifiers->device_pause) {
-					(*notifiers->device_pause) (bus_no,
-								    dev_no);
+					(*notifiers->device_pause) (dev_info);
 					notified = true;
 				}
 			} else if (state.alive == segment_state_paused.alive &&
@@ -1174,7 +1163,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
 			break;
 		case CONTROLVM_DEVICE_DESTROY:
 			if (notifiers->device_destroy) {
-				(*notifiers->device_destroy) (bus_no, dev_no);
+				(*notifiers->device_destroy) (dev_info);
 				notified = true;
 			}
 			break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 127/141] staging: unisys: Convert the notifier functions to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (125 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 126/141] staging: unisys: Convert the epilog " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 128/141] staging: unisys: Convert the bus/device creation " Benjamin Romer
                   ` (16 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The next stage is the notifier functions are converted to use
struct visor_device.  The cleanup here is nice because no allocation
is needed.  No lookup needed.  No channel creation needed.

Things simplify down to the obvious calls.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    | 125 +++++----------------
 drivers/staging/unisys/visorbus/visorbus_private.h |  12 +-
 2 files changed, 35 insertions(+), 102 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index bc865cd..2863d15 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -24,6 +24,7 @@
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
 #include "vbusdeviceinfo.h"
+#include "controlvmchannel.h"
 
 #define MYDRVNAME "visorbus"
 
@@ -56,6 +57,13 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
 static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
 static void fix_vbus_dev_info(struct visor_device *visordev);
 
+static void chipset_bus_create(struct visor_device *vdev);
+static void chipset_bus_destroy(struct visor_device *vdev);
+static void chipset_device_create(struct visor_device *vdev);
+static void chipset_device_destroy(struct visor_device *vdev);
+static void chipset_device_pause(struct visor_device *vdev);
+static void chipset_device_resume(struct visor_device *vdev);
+
 /*  BUS type attributes
  *
  *  define & implement display of bus attributes under
@@ -108,12 +116,6 @@ static long long bus_count;	/** number of bus instances */
 static long long total_devices_created;
 					/** ever-increasing */
 
-static void chipset_bus_create(u32 bus_no);
-static void chipset_bus_destroy(u32 bus_no);
-static void chipset_device_create(u32 bus_no, u32 dev_no);
-static void chipset_device_destroy(u32 bus_no, u32 dev_no);
-static void chipset_device_pause(u32 bus_no, u32 dev_no);
-static void chipset_device_resume(u32 bus_no, u32 dev_no);
 
 /** These functions are implemented herein, and are called by the chipset
  *  driver to notify us about specific events.
@@ -1484,29 +1486,14 @@ remove_all_visor_devices(void)
 	}
 }
 
-static bool entered_testing_mode;
-static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST];
-static unsigned long test_bus_nos[MAXDEVICETEST];
-static unsigned long test_dev_nos[MAXDEVICETEST];
-
 static void
-chipset_bus_create(u32 bus_no)
+chipset_bus_create(struct visor_device *vdev)
 {
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata;
-	int rc = -1;
+	int rc;
+	u32 bus_no = vdev->chipset_bus_no;
 
 	POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
-	if (!visorchipset_get_bus_info(bus_no, &bus_info))
-		goto away;
-	devdata = create_bus_instance(bus_no);
-	if (!devdata)
-		goto away;
-	if (!visorchipset_set_bus_context(bus_no, devdata))
-		goto away;
-	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
-	rc = 0;
-away:
+	rc = create_bus_instance(vdev);
 	if (rc < 0) {
 		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1515,96 +1502,42 @@ away:
 	POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 	if (chipset_responders.bus_create)
-		(*chipset_responders.bus_create) (bus_no, rc);
+		(*chipset_responders.bus_create) (vdev, rc);
 }
 
 static void
-chipset_bus_destroy(u32 bus_no)
+chipset_bus_destroy(struct visor_device *vdev)
 {
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata;
-	int rc = -1;
-
-	if (!visorchipset_get_bus_info(bus_no, &bus_info))
-		goto away;
-	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
-	if (!devdata)
-		goto away;
-	remove_bus_instance(devdata);
-	if (!visorchipset_set_bus_context(bus_no, NULL))
-		goto away;
-	rc = 0;
-away:
-	if (rc < 0)
-		return;
+	remove_bus_instance(vdev);
 	if (chipset_responders.bus_destroy)
-		(*chipset_responders.bus_destroy)(bus_no, rc);
+		(*chipset_responders.bus_destroy)(vdev, 0);
 }
 
 static void
-chipset_device_create(u32 bus_no, u32 dev_no)
+chipset_device_create(struct visor_device *dev)
 {
-	struct visorchipset_device_info dev_info;
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata = NULL;
 	int rc = -1;
+	u32 bus_no = dev->chipset_bus_no;
+	u32 dev_no = dev->chipset_dev_no;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	if (entered_testing_mode)
-		return;
-	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
-		goto away;
-	if (!visorchipset_get_bus_info(bus_no, &bus_info))
-		goto away;
-	if (visorbus_devicetest)
-		if (total_devices_created < MAXDEVICETEST) {
-			test_channel_infos[total_devices_created] =
-			    dev_info.chan_info;
-			test_bus_nos[total_devices_created] = bus_no;
-			test_dev_nos[total_devices_created] = dev_no;
-		}
-	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-	rc = 0;
-away:
-	if (rc < 0) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
-	rc = create_visor_device(devdata, bus_no, dev_no,
-				 dev_info.chan_info, bus_info.partition_handle);
+	rc = create_visor_device(dev);
 	POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 	if (rc < 0)
 		if (chipset_responders.device_create)
-			(*chipset_responders.device_create)(bus_no, dev_no, rc);
+			(*chipset_responders.device_create)(dev, rc);
 }
 
 static void
-chipset_device_destroy(u32 bus_no, u32 dev_no)
+chipset_device_destroy(struct visor_device *dev)
 {
-	struct visorchipset_device_info dev_info;
-	struct visor_device *dev;
-	int rc = -1;
-
-	if (entered_testing_mode)
-		return;
-	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
-		goto away;
-	dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
-	if (!dev)
-		goto away;
-	rc = 0;
-away:
-	if (rc < 0)
-			return;
+	int rc = 0;
 
 	if (chipset_responders.device_destroy)
-		(*chipset_responders.device_destroy) (bus_no, dev_no, rc);
+		(*chipset_responders.device_destroy) (dev, rc);
 	remove_visor_device(dev);
 }
 
@@ -1721,20 +1654,20 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
 away:
 	if (rc < 0) {
 		if (notify_func)
-				(*notify_func)(bus_no, dev_no, rc);
+				(*notify_func)(dev, rc);
 	}
 }
 
 static void
-chipset_device_pause(u32 bus_no, u32 dev_no)
+chipset_device_pause(struct visor_device *dev)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, true);
+	initiate_chipset_device_pause_resume(dev, true);
 }
 
 static void
-chipset_device_resume(u32 bus_no, u32 dev_no)
+chipset_device_resume(struct visor_device *dev)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, false);
+	initiate_chipset_device_pause_resume(dev, false);
 }
 
 struct channel_size_info {
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index bbc64bd..9b84a1d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -104,12 +104,12 @@ struct visorchipset_bus_info {
  *  visorchipset.)
  */
 struct visorchipset_busdev_notifiers {
-	void (*bus_create)(u32 bus_no);
-	void (*bus_destroy)(u32 bus_no);
-	void (*device_create)(u32 bus_no, u32 dev_no);
-	void (*device_destroy)(u32 bus_no, u32 dev_no);
-	void (*device_pause)(u32 bus_no, u32 dev_no);
-	void (*device_resume)(u32 bus_no, u32 dev_no);
+	void (*bus_create)(struct visor_device *vdev);
+	void (*bus_destroy)(struct visor_device *vdev);
+	void (*device_create)(struct visor_device *vdev);
+	void (*device_destroy)(struct visor_device *vdev);
+	void (*device_pause)(struct visor_device *vdev);
+	void (*device_resume)(struct visor_device *vdev);
 };
 
 /*  These functions live inside visorchipset, and will be called to indicate
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 128/141] staging: unisys: Convert the bus/device creation to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (126 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 127/141] staging: unisys: Convert the notifier " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 129/141] staging: unisys: Convert the responders " Benjamin Romer
                   ` (15 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The next layer is the bus/device creation to be converted over to
struct visor_device.  Again because memory was allocated already
and the channel created, the code is simplified.  No lookups,
very few sanity checks.

Eventually most of these functions could be dissolved into the parent
function because there isn't really anything left.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 162 ++++++------------------
 1 file changed, 37 insertions(+), 125 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 2863d15..a3062ea 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1028,42 +1028,15 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
  *  device.
  */
 static int
-create_visor_device(struct visorbus_devdata *devdata,
-		    unsigned long chipset_bus_no, unsigned long chipset_dev_no,
-		    struct visorchipset_channel_info chan_info,
-		    u64 partition_handle)
+create_visor_device(struct visor_device *dev)
 {
 	int rc = -1;
-	struct visorchannel *visorchannel = NULL;
-	struct visor_device *dev = NULL;
-	bool gotten = false, registered1 = false, registered2 = false;
+	u32 chipset_bus_no = dev->chipset_bus_no;
+	u32 chipset_dev_no = dev->chipset_dev_no;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
 			 POSTCODE_SEVERITY_INFO);
-	/* prepare chan_hdr (abstraction to read/write channel memory) */
-	visorchannel = visorchannel_create(chan_info.channel_addr,
-					   chan_info.n_channel_bytes,
-					   GFP_KERNEL,
-					   chan_info.channel_type_uuid);
-	if (!visorchannel) {
-		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
-				 DIAG_SEVERITY_ERR);
-		goto away;
-	}
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
-				 DIAG_SEVERITY_ERR);
-		goto away;
-	}
 
-	memset(dev, 0, sizeof(struct visor_device));
-	dev->visorchannel = visorchannel;
-	dev->channel_type_guid = chan_info.channel_type_uuid;
-	dev->channel_bytes = chan_info.n_channel_bytes;
-	dev->chipset_bus_no = chipset_bus_no;
-	dev->chipset_dev_no = chipset_dev_no;
-	dev->device.parent = &devdata->dev;
 	sema_init(&dev->visordriver_callback_lock, 1);	/* unlocked */
 	dev->device.bus = &visorbus_type;
 	dev->device.groups = visorbus_dev_groups;
@@ -1071,7 +1044,6 @@ create_visor_device(struct visorbus_devdata *devdata,
 	dev->device.release = visorbus_release_device;
 	/* keep a reference just for us (now 2) */
 	get_device(&dev->device);
-	gotten = true;
 	dev->periodic_work =
 		visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL,
 					   periodic_dev_workqueue,
@@ -1087,7 +1059,7 @@ create_visor_device(struct visorbus_devdata *devdata,
 	 * (NOT bus instance).  That's why we need to include the bus
 	 * number within the name.
 	 */
-	dev_set_name(&dev->device, "vbus%lu:dev%lu",
+	dev_set_name(&dev->device, "vbus%u:dev%u",
 		     chipset_bus_no, chipset_dev_no);
 
 	/*  device_add does this:
@@ -1113,9 +1085,6 @@ create_visor_device(struct visorbus_devdata *devdata,
 		goto away;
 	}
 
-	/* note: device_register is simply device_initialize + device_add */
-	registered1 = true;
-
 	rc = register_devmajorminor_attributes(dev);
 	if (rc < 0) {
 		POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
@@ -1123,22 +1092,13 @@ create_visor_device(struct visorbus_devdata *devdata,
 		goto away;
 	}
 
-	registered2 = true;
-	rc = 0;
+	total_devices_created++;
+	list_add_tail(&dev->list_all, &list_all_device_instances);
+
+	return rc;
 
 away:
-	if (rc < 0) {
-		if (registered2)
-			unregister_devmajorminor_attributes(dev);
-		if (gotten)
-			put_device(&dev->device);
-		if (visorchannel)
-			visorchannel_destroy(visorchannel);
-		kfree(dev);
-	} else {
-		total_devices_created++;
-		list_add_tail(&dev->list_all, &list_all_device_instances);
-	}
+	put_device(&dev->device);
 	return rc;
 }
 
@@ -1356,75 +1316,36 @@ fix_vbus_dev_info(struct visor_device *visordev)
 
 /** Create a device instance for the visor bus itself.
  */
-static struct visorbus_devdata *
-create_bus_instance(int id)
+static int
+create_bus_instance(struct visor_device *vdev)
 {
-	struct visorbus_devdata *rc = NULL;
-	struct visorbus_devdata *devdata = NULL;
-	struct visorchipset_bus_info bus_info;
+	int rc;
+	u32 id = vdev->chipset_bus_no;
 
 	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-	devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
-	if (!devdata) {
-		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
-		rc = NULL;
-		goto away;
-	}
-	dev_set_name(&devdata->dev, "visorbus%d", id);
-	devdata->dev.bus = &visorbus_type;
-	devdata->dev.groups = visorbus_groups;
-	devdata->dev.release = visorbus_release_busdevice;
-	if (device_register(&devdata->dev) < 0) {
+	dev_set_name(&vdev->device, "visorbus%d", id);
+	vdev->device.bus = &visorbus_type;
+	vdev->device.groups = visorbus_groups;
+	vdev->device.release = visorbus_release_busdevice;
+	rc = device_register(&vdev->device);
+	if (rc < 0) {
 		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
 				 POSTCODE_SEVERITY_ERR);
-		rc = NULL;
 		goto away;
 	}
-	devdata->devno = id;
-	if ((visorchipset_get_bus_info(id, &bus_info)) &&
-	    (bus_info.chan_info.channel_addr > 0) &&
-	    (bus_info.chan_info.n_channel_bytes > 0)) {
-		u64 channel_addr = bus_info.chan_info.channel_addr;
-		unsigned long n_channel_bytes =
-				(unsigned long)
-				bus_info.chan_info.n_channel_bytes;
-		uuid_le channel_type_guid =
-				bus_info.chan_info.channel_type_uuid;
-
-		devdata->chan = visorchannel_create(channel_addr,
-						    n_channel_bytes,
-						    GFP_KERNEL,
-						    channel_type_guid);
-		if (!devdata->chan) {
-			POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr,
-					 POSTCODE_SEVERITY_ERR);
-		} else {
-			if (bus_info.flags.server) {
-				init_vbus_channel(devdata->chan);
-			} else {
-				if (get_vbus_header_info(devdata->chan,
-							 &devdata->
-							 vbus_hdr_info) >= 0) {
-					devdata->vbus_valid = true;
-					write_vbus_chp_info(devdata->chan,
-							    &devdata->
-							    vbus_hdr_info,
-							    &chipset_driverinfo
-							    );
-					write_vbus_bus_info(devdata->chan,
-							    &devdata->
-								vbus_hdr_info,
-							&clientbus_driverinfo);
-				}
-			}
+	if (vdev->visorchannel) {
+		struct visorchannel *channel = vdev->visorchannel;
+
+		if (get_vbus_header_info(channel, &vdev->vbus_hdr_info) >= 0) {
+			write_vbus_chp_info(channel, &vdev->vbus_hdr_info,
+					    &chipset_driverinfo);
+			write_vbus_bus_info(channel, &vdev->vbus_hdr_info,
+					    &clientbus_driverinfo);
 		}
 	}
 	bus_count++;
-	list_add_tail(&devdata->list_all, &list_all_bus_instances);
-	if (id == 0)
-			devdata = devdata;	/* for testing ONLY */
-	dev_set_drvdata(&devdata->dev, devdata);
-	rc = devdata;
+	list_add_tail(&vdev->list_all, &list_all_bus_instances);
+	dev_set_drvdata(&vdev->device, vdev);
 away:
 	return rc;
 }
@@ -1432,7 +1353,7 @@ away:
 /** Remove a device instance for the visor bus itself.
  */
 static void
-remove_bus_instance(struct visorbus_devdata *devdata)
+remove_bus_instance(struct visor_device *dev)
 {
 	/* Note that this will result in the release method for
 	 * devdata->dev being called, which will call
@@ -1442,12 +1363,12 @@ remove_bus_instance(struct visorbus_devdata *devdata)
 	 * release() gets called.  But I know it does.
 	 */
 	bus_count--;
-	if (devdata->chan) {
-		visorchannel_destroy(devdata->chan);
-		devdata->chan = NULL;
+	if (dev->visorchannel) {
+		visorchannel_destroy(dev->visorchannel);
+		dev->visorchannel = NULL;
 	}
-	list_del(&devdata->list_all);
-	device_unregister(&devdata->dev);
+	list_del(&dev->list_all);
+	device_unregister(&dev->device);
 }
 
 /** Create and register the one-and-only one instance of
@@ -1588,13 +1509,11 @@ resume_state_change_complete(struct visor_device *dev, int status)
  * callback function.
  */
 static void
-initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
+initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
 {
-	struct visorchipset_device_info dev_info;
-	struct visor_device *dev = NULL;
 	int rc = -1, x;
 	struct visor_driver *drv = NULL;
-	void (*notify_func)(u32 bus_no, u32 dev_no, int response) = NULL;
+	void (*notify_func)(struct visor_device *dev, int response) = NULL;
 
 	if (is_pause)
 		notify_func = chipset_responders.device_pause;
@@ -1603,13 +1522,6 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
 	if (!notify_func)
 			goto away;
 
-	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
-			goto away;
-
-	dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
-	if (!dev)
-			goto away;
-
 	drv = to_visor_driver(dev->device.driver);
 	if (!drv)
 			goto away;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 129/141] staging: unisys: Convert the responders to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (127 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 128/141] staging: unisys: Convert the bus/device creation " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 130/141] staging: unisys: Convert the device attributes " Benjamin Romer
                   ` (14 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

This is the next stage of conversion, the command responders to
struct visor_device.

Most of this is mechanical and straightforward. I will point out some
quirks that I ran into and what I did:

- bus_responder
  - bus_info_clear is no longer used as I am now expecting the core
    infrastructure to cleanup correctly, so this code simplified more
    than expected.  I am not sure the cleanup happens and perhaps a
    couple of put_devices might be needed, but in theory some release
    functions should be called to cleanup.
- dev_responder
  - same as the bus_responder but with dev_info_clear.

Both of the above quirks should be verified that things still work
correctly.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    | 10 +--
 drivers/staging/unisys/visorbus/visorbus_private.h | 12 ++--
 drivers/staging/unisys/visorbus/visorchipset.c     | 84 +++++++---------------
 3 files changed, 34 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index a3062ea..1a46788 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -841,9 +841,7 @@ away:
 	if (!dev->responded_to_device_create) {
 		dev->responded_to_device_create = true;
 		if (chipset_responders.device_create)
-			(*chipset_responders.device_create)(dev->chipset_bus_no,
-							    dev->chipset_dev_no,
-							    rc);
+			(*chipset_responders.device_create)(dev, rc);
 	}
 	return rc;
 }
@@ -1479,8 +1477,7 @@ pause_state_change_complete(struct visor_device *dev, int status)
 	/* Notify the chipset driver that the pause is complete, which
 	* will presumably want to send some sort of response to the
 	* initiator. */
-	(*chipset_responders.device_pause) (dev->chipset_bus_no,
-					    dev->chipset_dev_no, status);
+	(*chipset_responders.device_pause) (dev, status);
 }
 
 /* This is the callback function specified for a function driver, to
@@ -1500,8 +1497,7 @@ resume_state_change_complete(struct visor_device *dev, int status)
 	/* Notify the chipset driver that the resume is complete,
 	 * which will presumably want to send some sort of response to
 	 * the initiator. */
-	(*chipset_responders.device_resume) (dev->chipset_bus_no,
-					     dev->chipset_dev_no, status);
+	(*chipset_responders.device_resume) (dev, status);
 }
 
 /* Tell the subordinate function driver for a specific device to pause
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 9b84a1d..5b3c0cd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -119,12 +119,12 @@ struct visorchipset_busdev_notifiers {
  *      -1 = it failed
  */
 struct visorchipset_busdev_responders {
-	void (*bus_create)(u32 bus_no, int response);
-	void (*bus_destroy)(u32 bus_no, int response);
-	void (*device_create)(u32 bus_no, u32 dev_no, int response);
-	void (*device_destroy)(u32 bus_no, u32 dev_no, int response);
-	void (*device_pause)(u32 bus_no, u32 dev_no, int response);
-	void (*device_resume)(u32 bus_no, u32 dev_no, int response);
+	void (*bus_create)(struct visor_device *p, int response);
+	void (*bus_destroy)(struct visor_device *p, int response);
+	void (*device_create)(struct visor_device *p, int response);
+	void (*device_destroy)(struct visor_device *p, int response);
+	void (*device_pause)(struct visor_device *p, int response);
+	void (*device_resume)(struct visor_device *p, int response);
 };
 
 /** Register functions (in the bus driver) to get called by visorchipset
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 51d708f..84b47a1 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -228,13 +228,13 @@ static void parahotplug_process_list(void);
  */
 static struct visorchipset_busdev_notifiers busdev_notifiers;
 
-static void bus_create_response(u32 bus_no, int response);
-static void bus_destroy_response(u32 bus_no, int response);
-static void device_create_response(u32 bus_no, u32 dev_no, int response);
-static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
-static void device_resume_response(u32 bus_no, u32 dev_no, int response);
+static void bus_create_response(struct visor_device *dev, int response);
+static void bus_destroy_response(struct visor_device *dev, int response);
+static void device_create_response(struct visor_device *dev, int response);
+static void device_destroy_response(struct visor_device *dev, int response);
+static void device_resume_response(struct visor_device *dev, int response);
 
-static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no,
+static void visorchipset_device_pause_response(struct visor_device *dev,
 					       int response);
 
 static struct visorchipset_busdev_responders busdev_responders = {
@@ -958,26 +958,10 @@ enum crash_obj_type {
 };
 
 static void
-bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
+bus_responder(enum controlvm_id cmd_id, struct visor_device *p, int response)
 {
-	struct visorchipset_bus_info *p;
-	bool need_clear = false;
-
-	p = bus_find(&bus_info_list, bus_no);
-	if (!p)
-		return;
-
-	if (response < 0) {
-		if ((cmd_id == CONTROLVM_BUS_CREATE) &&
-		    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
-			/* undo the row we just created... */
-			busdevices_del(&dev_info_list, bus_no);
-	} else {
-		if (cmd_id == CONTROLVM_BUS_CREATE)
+	if (cmd_id == CONTROLVM_BUS_CREATE)
 			p->state.created = 1;
-		if (cmd_id == CONTROLVM_BUS_DESTROY)
-			need_clear = true;
-	}
 
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
 		return;		/* no controlvm response needed */
@@ -985,23 +969,15 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 		return;
 	controlvm_respond(&p->pending_msg_hdr, response);
 	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear) {
-		bus_info_clear(p);
-		busdevices_del(&dev_info_list, bus_no);
-	}
 }
 
 static void
 device_changestate_responder(enum controlvm_id cmd_id,
-			     u32 bus_no, u32 dev_no, int response,
+			     struct visor_device *p, int response,
 			     struct spar_segment_state response_state)
 {
-	struct visorchipset_device_info *p;
 	struct controlvm_message outmsg;
 
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
 		return;		/* no controlvm response needed */
 	if (p->pending_msg_hdr.id != cmd_id)
@@ -1009,8 +985,8 @@ device_changestate_responder(enum controlvm_id cmd_id,
 
 	controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
 
-	outmsg.cmd.device_change_state.bus_no = bus_no;
-	outmsg.cmd.device_change_state.dev_no = dev_no;
+	outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no;
+	outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no;
 	outmsg.cmd.device_change_state.state = response_state;
 
 	if (!visorchannel_signalinsert(controlvm_channel,
@@ -1021,19 +997,11 @@ device_changestate_responder(enum controlvm_id cmd_id,
 }
 
 static void
-device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
+device_responder(enum controlvm_id cmd_id, struct visor_device *p, int response)
 {
-	struct visorchipset_device_info *p;
-	bool need_clear = false;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
 	if (response >= 0) {
 		if (cmd_id == CONTROLVM_DEVICE_CREATE)
 			p->state.created = 1;
-		if (cmd_id == CONTROLVM_DEVICE_DESTROY)
-			need_clear = true;
 	}
 
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
@@ -1044,8 +1012,6 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 
 	controlvm_respond(&p->pending_msg_hdr, response);
 	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear)
-		dev_info_clear(p);
 }
 
 static void
@@ -1176,7 +1142,7 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 		 */
 		;
 	else
-		device_responder(cmd, bus_no, dev_no, response);
+		device_responder(cmd, dev_info, response);
 	up(&notifier_lock);
 }
 
@@ -2107,42 +2073,42 @@ cleanup:
 }
 
 static void
-bus_create_response(u32 bus_no, int response)
+bus_create_response(struct visor_device *dev, int response)
 {
-	bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+	bus_responder(CONTROLVM_BUS_CREATE, dev, response);
 }
 
 static void
-bus_destroy_response(u32 bus_no, int response)
+bus_destroy_response(struct visor_device *dev, int response)
 {
-	bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+	bus_responder(CONTROLVM_BUS_DESTROY, dev, response);
 }
 
 static void
-device_create_response(u32 bus_no, u32 dev_no, int response)
+device_create_response(struct visor_device *dev, int response)
 {
-	device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
+	device_responder(CONTROLVM_DEVICE_CREATE, dev, response);
 }
 
 static void
-device_destroy_response(u32 bus_no, u32 dev_no, int response)
+device_destroy_response(struct visor_device *dev, int response)
 {
-	device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
+	device_responder(CONTROLVM_DEVICE_DESTROY, dev, response);
 }
 
 static void
-visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
+visorchipset_device_pause_response(struct visor_device *dev, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
+				     dev, response,
 				     segment_state_standby);
 }
 
 static void
-device_resume_response(u32 bus_no, u32 dev_no, int response)
+device_resume_response(struct visor_device *dev, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
+				     dev, response,
 				     segment_state_running);
 }
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 130/141] staging: unisys: Convert the device attributes to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (128 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 129/141] staging: unisys: Convert the responders " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 131/141] staging: unisys: Convert init/exit routines " Benjamin Romer
                   ` (13 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Convert the device attribute files to properly use visor_device.
This removes a whole bunch of checks and assumptions and simplifies
the code.  Everything is straightforward.

No testing down as I can't mimic channel info correctl.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 80 +++++++++----------------
 1 file changed, 28 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 1a46788..7b585d8 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -543,78 +543,54 @@ static const struct attribute_group *visorbus_dev_groups[] = {
 static ssize_t partition_handle_show(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
-	int len = 0;
+	struct visor_device *vdev = to_visor_device(dev);
+	u64 handle = visorchannel_get_clientpartition(vdev->visorchannel);
 
-	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
-		len = snprintf(buf, PAGE_SIZE,
-			       "0x%Lx\n",
-			       (unsigned long long)bus_info.partition_handle);
-	return len;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n", handle);
 }
 
 static ssize_t partition_guid_show(struct device *dev,
 				   struct device_attribute *attr,
 				   char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
-	int len = 0;
+	struct visor_device *vdev = to_visor_device(dev);
 
-	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
-		len = snprintf(buf, PAGE_SIZE, "{%pUb}\n",
-			       &bus_info.partition_uuid);
-	return len;
+	return snprintf(buf, PAGE_SIZE, "{%pUb}\n", &vdev->partition_uuid);
 }
 
 static ssize_t partition_name_show(struct device *dev,
 				   struct device_attribute *attr,
 				   char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
-	int len = 0;
+	struct visor_device *vdev = to_visor_device(dev);
 
-	if (businst &&
-	    visorchipset_get_bus_info(businst->devno, &bus_info) &&
-	    bus_info.name)
-		len = snprintf(buf, PAGE_SIZE, "%s\n", bus_info.name);
-	return len;
+	return snprintf(buf, PAGE_SIZE, "%s\n", vdev->name);
 }
 
 static ssize_t channel_addr_show(struct device *dev,
 				 struct device_attribute *attr,
 				 char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
-	int len = 0;
+	struct visor_device *vdev = to_visor_device(dev);
+	u64 addr = visorchannel_get_physaddr(vdev->visorchannel);
 
-	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
-		len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
-			       bus_info.chan_info.channel_addr);
-	return len;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n", addr);
 }
 
 static ssize_t channel_bytes_show(struct device *dev,
 				  struct device_attribute *attr,
 				  char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
-	int len = 0;
+	struct visor_device *vdev = to_visor_device(dev);
+	u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel);
 
-	if (businst && visorchipset_get_bus_info(businst->devno, &bus_info))
-		len = snprintf(buf, PAGE_SIZE, "0x%Lx\n", (unsigned long long)
-			       bus_info.chan_info.n_channel_bytes);
-	return len;
+	return snprintf(buf, PAGE_SIZE, "0x%Lx\n", nbytes);
 }
 
 static ssize_t channel_id_show(struct device *dev,
 			       struct device_attribute *attr,
 			       char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
+	struct visor_device *vdev = to_visor_device(dev);
 	int len = 0;
 
-	if (businst && businst->chan) {
-		visorchannel_id(businst->chan, buf);
+	if (vdev->visorchannel) {
+		visorchannel_id(vdev->visorchannel, buf);
 		len = strlen(buf);
 		buf[len++] = '\n';
 	}
@@ -624,8 +600,9 @@ static ssize_t channel_id_show(struct device *dev,
 static ssize_t client_bus_info_show(struct device *dev,
 				    struct device_attribute *attr,
 				    char *buf) {
-	struct visorbus_devdata *businst = to_visorbus_devdata(dev);
-	struct visorchipset_bus_info bus_info;
+	struct visor_device *vdev = to_visor_device(dev);
+	struct visorchannel *channel = vdev->visorchannel;
+
 	int i, x, remain = PAGE_SIZE;
 	unsigned long off;
 	char *p = buf;
@@ -633,16 +610,15 @@ static ssize_t client_bus_info_show(struct device *dev,
 	struct ultra_vbus_deviceinfo dev_info;
 
 	partition_name = "";
-	if (businst && businst->chan) {
-		if (visorchipset_get_bus_info(businst->devno, &bus_info) &&
-		    bus_info.name)
-			partition_name = bus_info.name;
+	if (channel) {
+		if (vdev->name)
+			partition_name = vdev->name;
 		x = snprintf(p, remain,
-			     "Client device / client driver info for %s partition (vbus #%d):\n",
-			     partition_name, businst->devno);
+			     "Client device / client driver info for %s partition (vbus #%ld):\n",
+			     partition_name, vdev->chipset_dev_no);
 		p += x;
 		remain -= x;
-		x = visorchannel_read(businst->chan,
+		x = visorchannel_read(channel,
 				      offsetof(struct
 					       spar_vbus_channel_protocol,
 					       chp_info),
@@ -653,7 +629,7 @@ static ssize_t client_bus_info_show(struct device *dev,
 			p += x;
 			remain -= x;
 		}
-		x = visorchannel_read(businst->chan,
+		x = visorchannel_read(channel,
 				      offsetof(struct
 					       spar_vbus_channel_protocol,
 					       bus_info),
@@ -667,8 +643,8 @@ static ssize_t client_bus_info_show(struct device *dev,
 		off = offsetof(struct spar_vbus_channel_protocol, dev_info);
 		i = 0;
 		while (off + sizeof(dev_info) <=
-		       visorchannel_get_nbytes(businst->chan)) {
-			x = visorchannel_read(businst->chan,
+		       visorchannel_get_nbytes(channel)) {
+			x = visorchannel_read(channel,
 					      off, &dev_info, sizeof(dev_info));
 			if (x >= 0) {
 				x = vbuschannel_devinfo_to_string
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 131/141] staging: unisys: Convert init/exit routines to visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (129 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 130/141] staging: unisys: Convert the device attributes " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 132/141] staging: unisys: Remove dead code leftover from conversion Benjamin Romer
                   ` (12 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Another conversion of the init/exit routines with various other
functions used during init thrown in here.

Most of the conversion is mechanical.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 36 ++++++++-----------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 7b585d8..cc2ed58 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -197,11 +197,10 @@ away:
 static void
 visorbus_release_busdevice(struct device *xdev)
 {
-	struct visorbus_devdata *devdata = dev_get_drvdata(xdev);
+	struct visor_device *dev = dev_get_drvdata(xdev);
 
 	dev_set_drvdata(xdev, NULL);
-	kfree(devdata);
-	kfree(xdev);
+	kfree(dev);
 }
 
 /** This is called when device_unregister() is called for each child
@@ -1237,11 +1236,9 @@ static void
 fix_vbus_dev_info(struct visor_device *visordev)
 {
 	int i;
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata = NULL;
 	struct visor_driver *visordrv;
-	int bus_no = visordev->chipset_bus_no;
 	int dev_no = visordev->chipset_dev_no;
+	struct visorchannel *channel = visordev->visorchannel;
 	struct ultra_vbus_deviceinfo dev_info;
 	const char *chan_type_name = NULL;
 
@@ -1249,15 +1246,6 @@ fix_vbus_dev_info(struct visor_device *visordev)
 			return;
 
 	visordrv = to_visor_driver(visordev->device.driver);
-	if (!visorchipset_get_bus_info(bus_no, &bus_info))
-			return;
-
-	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
-	if (!devdata)
-			return;
-
-	if (!devdata->vbus_valid)
-			return;
 
 	/* Within the list of device types (by GUID) that the driver
 	 * says it supports, find out which one of those types matches
@@ -1276,15 +1264,15 @@ fix_vbus_dev_info(struct visor_device *visordev)
 	bus_device_info_init(&dev_info, chan_type_name,
 			     visordrv->name, visordrv->version,
 			     visordrv->vertag);
-	write_vbus_dev_info(devdata->chan,
-			    &devdata->vbus_hdr_info, &dev_info, dev_no);
+	write_vbus_dev_info(channel,
+			    &visordev->vbus_hdr_info, &dev_info, dev_no);
 
 	/* Re-write bus+chipset info, because it is possible that this
 	* was previously written by our evil counterpart, virtpci.
 	*/
-	write_vbus_chp_info(devdata->chan, &devdata->vbus_hdr_info,
+	write_vbus_chp_info(channel, &visordev->vbus_hdr_info,
 			    &chipset_driverinfo);
-	write_vbus_bus_info(devdata->chan, &devdata->vbus_hdr_info,
+	write_vbus_bus_info(channel, &visordev->vbus_hdr_info,
 			    &clientbus_driverinfo);
 }
 
@@ -1353,7 +1341,6 @@ create_bus_type(void)
 {
 	int rc = 0;
 
-	visorbus_type.dev_attrs = visor_device_attrs;
 	rc = bus_register(&visorbus_type);
 	return rc;
 }
@@ -1624,11 +1611,10 @@ visorbus_exit(void)
 	}
 
 	list_for_each_safe(listentry, listtmp, &list_all_bus_instances) {
-		struct visorbus_devdata *devdata = list_entry(listentry,
-							      struct
-							      visorbus_devdata,
-							      list_all);
-		remove_bus_instance(devdata);
+		struct visor_device *dev = list_entry(listentry,
+						      struct visor_device,
+						      list_all);
+		remove_bus_instance(dev);
 	}
 	remove_bus_type();
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 132/141] staging: unisys: Remove dead code leftover from conversion
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (130 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 131/141] staging: unisys: Convert init/exit routines " Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 133/141] staging: unisys: Remove unused intr Benjamin Romer
                   ` (11 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

Now that the conversion to struct visor_device is complete,
remove all the cruft left behind.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    |  53 ---------
 drivers/staging/unisys/visorbus/visorbus_private.h |  79 ------------
 drivers/staging/unisys/visorbus/visorchipset.c     | 132 ---------------------
 3 files changed, 264 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index cc2ed58..a79996a 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -37,18 +37,6 @@ int visorbus_devicetest;
 int visorbus_debugref;
 #define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
 
-/** This is the private data that we store for each bus device instance.
- */
-struct visorbus_devdata {
-	int devno;		/* this is the chipset busNo */
-	struct list_head list_all;
-	struct device dev;
-	struct kobject kobj;
-	struct visorchannel *chan;	/* channel area for bus itself */
-	bool vbus_valid;
-	struct spar_vbus_headerinfo vbus_hdr_info;
-};
-
 #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
 #define POLLJIFFIES_TESTWORK         100
 #define POLLJIFFIES_NORMALCHANNEL     10
@@ -475,33 +463,12 @@ static ssize_t typename_show(struct device *dev, struct device_attribute *attr,
 	return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
 }
 
-static ssize_t dump_show(struct device *dev, struct device_attribute *attr,
-			 char *buf)
-{
-	struct visor_device *vdev = to_visor_device(dev);
-	int count = 0;
-/* TODO: replace this with debugfs code
-	struct seq_file *m = NULL;
-	if (vdev->visorchannel == NULL)
-		return 0;
-	m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
-	if (m == NULL)
-		return 0;
-	visorchannel_debug(vdev->visorchannel, 1, m, 0);
-	count = m->count;
-	visor_seq_file_done_buffer(m);
-	m = NULL;
-*/
-	return count;
-}
-
 static DEVICE_ATTR_RO(physaddr);
 static DEVICE_ATTR_RO(nbytes);
 static DEVICE_ATTR_RO(clientpartition);
 static DEVICE_ATTR_RO(typeguid);
 static DEVICE_ATTR_RO(zoneguid);
 static DEVICE_ATTR_RO(typename);
-static DEVICE_ATTR_RO(dump);
 
 static struct attribute *channel_attrs[] = {
 		&dev_attr_physaddr.attr,
@@ -510,7 +477,6 @@ static struct attribute *channel_attrs[] = {
 		&dev_attr_typeguid.attr,
 		&dev_attr_zoneguid.attr,
 		&dev_attr_typename.attr,
-		&dev_attr_dump.attr,
 };
 
 static struct attribute_group channel_attr_grp = {
@@ -718,25 +684,6 @@ unregister_driver_attributes(struct visor_driver *drv)
 	driver_remove_file(&drv->driver, &drv->version_attr);
 }
 
-/*  DEVICE attributes
- *
- *  define & implement display of device attributes under
- *  /sys/bus/visorbus/devices/<devicename>.
- *
- */
-
-#define DEVATTR(nam, func) { \
-	.attr = { .name = __stringify(nam), \
-		  .mode = 0444, \
-		  .owner = THIS_MODULE },	\
-	.show = func, \
-}
-
-static struct device_attribute visor_device_attrs[] = {
-	/* DEVATTR(channel_nbytes, DEVICE_ATTR_channel_nbytes), */
-	__ATTR_NULL
-};
-
 static void
 dev_periodic_work(void *xdev)
 {
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 5b3c0cd..4422d42 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -25,80 +25,6 @@
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
-struct visorchannel;
-
-enum visorchipset_addresstype {
-	/** address is guest physical, but outside of the physical memory
-	 *  region that is controlled by the running OS (this is the normal
-	 *  address type for Supervisor channels)
-	 */
-	ADDRTYPE_LOCALPHYSICAL,
-
-	/** address is guest physical, and withIN the confines of the
-	 *  physical memory controlled by the running OS.
-	 */
-	ADDRTYPE_LOCALTEST,
-};
-
-/** Attributes for a particular Supervisor channel.
- */
-struct visorchipset_channel_info {
-	enum visorchipset_addresstype addr_type;
-	u64 channel_addr;
-	struct irq_info intr;
-	u64 n_channel_bytes;
-	uuid_le channel_type_uuid;
-	uuid_le channel_inst_uuid;
-};
-
-/** Attributes for a particular Supervisor device.
- *  Any visorchipset client can query these attributes using
- *  visorchipset_get_client_device_info() or
- *  visorchipset_get_server_device_info().
- */
-struct visorchipset_device_info {
-	struct list_head entry;
-	u32 bus_no;
-	u32 dev_no;
-	uuid_le dev_inst_uuid;
-	struct visorchipset_state state;
-	struct visorchipset_channel_info chan_info;
-	u32 reserved1;		/* control_vm_id */
-	u64 reserved2;
-	u32 switch_no;		/* when devState.attached==1 */
-	u32 internal_port_no;	/* when devState.attached==1 */
-	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
-	/** For private use by the bus driver */
-	void *bus_driver_context;
-};
-
-/** Attributes for a particular Supervisor bus.
- *  (For a service partition acting as the server for buses/devices, there
- *  is a 1-to-1 relationship between busses and guest partitions.)
- *  Any visorchipset client can query these attributes using
- *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
- */
-struct visorchipset_bus_info {
-	struct list_head entry;
-	u32 bus_no;
-	struct visorchipset_state state;
-	struct visorchipset_channel_info chan_info;
-	uuid_le partition_uuid;
-	u64 partition_handle;
-	u8 *name;		/* UTF8 */
-	u8 *description;	/* UTF8 */
-	u64 reserved1;
-	u32 reserved2;
-	struct {
-		u32 server:1;
-		/* Add new fields above. */
-		/* Remaining bits in this 32-bit word are unused. */
-	} flags;
-	struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
-	/** For private use by the bus driver */
-	void *bus_driver_context;
-};
-
 /*  These functions will be called from within visorchipset when certain
  *  events happen.  (The implementation of these functions is outside of
  *  visorchipset.)
@@ -138,11 +64,6 @@ visorchipset_register_busdev(
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info);
 
-bool visorchipset_get_bus_info(u32 bus_no,
-			       struct visorchipset_bus_info *bus_info);
-bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-				  struct visorchipset_device_info *dev_info);
-bool visorchipset_set_bus_context(u32 bus_no, void *context);
 
 /* visorbus init and exit functions */
 int visorbus_init(void);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 84b47a1..3d6e471 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -692,25 +692,6 @@ static ssize_t remaining_steps_store(struct device *dev,
 	return count;
 }
 
-static void
-bus_info_clear(void *v)
-{
-	struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
-
-	kfree(p->name);
-	kfree(p->description);
-	memset(p, 0, sizeof(struct visorchipset_bus_info));
-}
-
-static void
-dev_info_clear(void *v)
-{
-	struct visorchipset_device_info *p =
-		(struct visorchipset_device_info *) v;
-
-	memset(p, 0, sizeof(struct visorchipset_device_info));
-}
-
 struct visor_busdev {
 	u32 bus_no;
 	u32 dev_no;
@@ -750,44 +731,6 @@ struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
 }
 EXPORT_SYMBOL(visorbus_get_device_by_id);
 
-static struct visorchipset_bus_info *
-bus_find(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_bus_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no)
-			return p;
-	}
-
-	return NULL;
-}
-
-static struct visorchipset_device_info *
-device_find(struct list_head *list, u32 bus_no, u32 dev_no)
-{
-	struct visorchipset_device_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no && p->dev_no == dev_no)
-			return p;
-	}
-
-	return NULL;
-}
-
-static void busdevices_del(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_device_info *p, *tmp;
-
-	list_for_each_entry_safe(p, tmp, list, entry) {
-		if (p->bus_no == bus_no) {
-			list_del(&p->entry);
-			kfree(p);
-		}
-	}
-}
-
 static u8
 check_chipset_events(void)
 {
@@ -834,25 +777,6 @@ visorchipset_register_busdev(
 EXPORT_SYMBOL_GPL(visorchipset_register_busdev);
 
 static void
-cleanup_controlvm_structures(void)
-{
-	struct visorchipset_bus_info *bi, *tmp_bi;
-	struct visorchipset_device_info *di, *tmp_di;
-
-	list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
-		bus_info_clear(bi);
-		list_del(&bi->entry);
-		kfree(bi);
-	}
-
-	list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
-		dev_info_clear(di);
-		list_del(&di->entry);
-		kfree(di);
-	}
-}
-
-static void
 chipset_init(struct controlvm_message *inmsg)
 {
 	static int chipset_inited;
@@ -878,8 +802,6 @@ chipset_init(struct controlvm_message *inmsg)
 	features |= ULTRA_CHIPSET_FEATURE_REPLY;
 
 cleanup:
-	if (rc < 0)
-		cleanup_controlvm_structures();
 	if (inmsg->hdr.flags.response_expected)
 		controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
 }
@@ -2111,58 +2033,6 @@ device_resume_response(struct visor_device *dev, int response)
 				     dev, response,
 				     segment_state_running);
 }
-
-bool
-visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
-{
-	void *p = bus_find(&bus_info_list, bus_no);
-
-	if (!p)
-		return false;
-	memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
-
-bool
-visorchipset_set_bus_context(u32 bus_no, void *context)
-{
-	struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
-
-	if (!p)
-		return false;
-	p->bus_driver_context = context;
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
-
-bool
-visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-			     struct visorchipset_device_info *dev_info)
-{
-	void *p = device_find(&dev_info_list, bus_no, dev_no);
-
-	if (!p)
-		return false;
-	memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
-
-bool
-visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
-{
-	struct visorchipset_device_info *p;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-
-	if (!p)
-		return false;
-	p->bus_driver_context = context;
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
-
 static ssize_t chipsetready_store(struct device *dev,
 				  struct device_attribute *attr,
 				  const char *buf, size_t count)
@@ -2436,8 +2306,6 @@ visorchipset_exit(struct acpi_device *acpi_device)
 	periodic_controlvm_workqueue = NULL;
 	destroy_controlvm_payload_info(&controlvm_payload_info);
 
-	cleanup_controlvm_structures();
-
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
 	visorchannel_destroy(controlvm_channel);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 133/141] staging: unisys: Remove unused intr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (131 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 132/141] staging: unisys: Remove dead code leftover from conversion Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device Benjamin Romer
                   ` (10 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The conversion to visor_device caused some compile issues.The main
problem was the new fields in 'struct visor_device' were not public.
Remove one that wasn't being used for now.

struct irq_info intr

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      | 1 -
 drivers/staging/unisys/visorbus/visorchannel.c | 1 -
 drivers/staging/unisys/visorbus/visorchipset.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index 32de5aa..dc5de471 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -162,7 +162,6 @@ struct visor_device {
 	u32 switch_no;
 	u32 internal_port_no;
 	uuid_le partition_uuid;
-	struct irq_info intr;
 };
 
 #define to_visor_device(x) container_of(x, struct visor_device, device)
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 6e7675e..e0dfaa9 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -45,7 +45,6 @@ struct visorchannel {
 		struct signal_queue_header event_queue;
 		struct signal_queue_header ack_queue;
 	} safe_uis_queue;
-	struct irq_info intr;
 	uuid_le type;
 	uuid_le inst;
 };
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 3d6e471..b1e059a 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1232,7 +1232,6 @@ my_device_create(struct controlvm_message *inmsg)
 	dev_info->visorchannel = visorchannel;
 	dev_info->type = cmd->create_device.data_type_uuid;
 	dev_info->inst = cmd->create_device.dev_inst_uuid;
-	dev_info->intr = cmd->create_device.intr;
 
 	/* not sure where the best place to set the 'parent' */
 	dev_info->device.parent = &bus_info->device;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (132 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 133/141] staging: unisys: Remove unused intr Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-08  8:34   ` Dan Carpenter
  2015-05-05 22:37 ` [PATCH 135/141] staging: unisys: Include missing headers Benjamin Romer
                   ` (9 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Don Zickus, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The vbus_hdr_info is a private struct that is used to communicate
bus info over the channel.  Currently it is public in visorbus.h
and causes compile problems (missing header).

Fix this by allocating memory and turn the public element into
a pointer.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h       |  3 +--
 drivers/staging/unisys/visorbus/visorbus_main.c | 28 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index dc5de471..d60421c 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -38,7 +38,6 @@
 #include "periodic_work.h"
 #include "channel.h"
 #include "controlvmchannel.h"
-#include "vbuschannel.h"
 
 struct visor_driver;
 struct visor_device;
@@ -158,7 +157,7 @@ struct visor_device {
 	u8 *name;
 	u8 *description;
 	struct controlvm_message_header pending_msg_hdr;
-	struct spar_vbus_headerinfo vbus_hdr_info;
+	void *vbus_hdr_info;
 	u32 switch_no;
 	u32 internal_port_no;
 	uuid_le partition_uuid;
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index a79996a..59cf220 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -24,6 +24,7 @@
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
 #include "vbusdeviceinfo.h"
+#include "vbuschannel.h"
 #include "controlvmchannel.h"
 
 #define MYDRVNAME "visorbus"
@@ -1188,10 +1189,13 @@ fix_vbus_dev_info(struct visor_device *visordev)
 	struct visorchannel *channel = visordev->visorchannel;
 	struct ultra_vbus_deviceinfo dev_info;
 	const char *chan_type_name = NULL;
+	struct spar_vbus_headerinfo *hdr_info;
 
 	if (!visordev->device.driver)
 			return;
 
+	hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info;
+
 	visordrv = to_visor_driver(visordev->device.driver);
 
 	/* Within the list of device types (by GUID) that the driver
@@ -1211,16 +1215,13 @@ fix_vbus_dev_info(struct visor_device *visordev)
 	bus_device_info_init(&dev_info, chan_type_name,
 			     visordrv->name, visordrv->version,
 			     visordrv->vertag);
-	write_vbus_dev_info(channel,
-			    &visordev->vbus_hdr_info, &dev_info, dev_no);
+	write_vbus_dev_info(channel, hdr_info, &dev_info, dev_no);
 
 	/* Re-write bus+chipset info, because it is possible that this
 	* was previously written by our evil counterpart, virtpci.
 	*/
-	write_vbus_chp_info(channel, &visordev->vbus_hdr_info,
-			    &chipset_driverinfo);
-	write_vbus_bus_info(channel, &visordev->vbus_hdr_info,
-			    &clientbus_driverinfo);
+	write_vbus_chp_info(channel, hdr_info, &chipset_driverinfo);
+	write_vbus_bus_info(channel, hdr_info, &clientbus_driverinfo);
 }
 
 /** Create a device instance for the visor bus itself.
@@ -1230,8 +1231,16 @@ create_bus_instance(struct visor_device *vdev)
 {
 	int rc;
 	u32 id = vdev->chipset_bus_no;
+	struct spar_vbus_headerinfo *hdr_info;
 
 	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
+
+	hdr_info = kzalloc(sizeof(struct spar_vbus_headerinfo), GFP_KERNEL);
+	if (!hdr_info) {
+		rc = -ENOMEM;
+		goto away;
+	}
+	vdev->vbus_hdr_info = (void *)hdr_info;
 	dev_set_name(&vdev->device, "visorbus%d", id);
 	vdev->device.bus = &visorbus_type;
 	vdev->device.groups = visorbus_groups;
@@ -1245,10 +1254,10 @@ create_bus_instance(struct visor_device *vdev)
 	if (vdev->visorchannel) {
 		struct visorchannel *channel = vdev->visorchannel;
 
-		if (get_vbus_header_info(channel, &vdev->vbus_hdr_info) >= 0) {
-			write_vbus_chp_info(channel, &vdev->vbus_hdr_info,
+		if (get_vbus_header_info(channel, hdr_info) >= 0) {
+			write_vbus_chp_info(channel, hdr_info,
 					    &chipset_driverinfo);
-			write_vbus_bus_info(channel, &vdev->vbus_hdr_info,
+			write_vbus_bus_info(channel, hdr_info,
 					    &clientbus_driverinfo);
 		}
 	}
@@ -1276,6 +1285,7 @@ remove_bus_instance(struct visor_device *dev)
 		visorchannel_destroy(dev->visorchannel);
 		dev->visorchannel = NULL;
 	}
+	kfree(dev->vbus_hdr_info);
 	list_del(&dev->list_all);
 	device_unregister(&dev->device);
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 135/141] staging: unisys: Include missing headers
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (133 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 136/141] staging: unisys: Removed unused entries from struct visor_channeltype_descriptor Benjamin Romer
                   ` (8 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This fixes the build breakage caused by recent removal of -I flags in
the Makefiles

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/guestlinuxdebug.h | 1 -
 drivers/staging/unisys/include/vbushelper.h      | 2 --
 drivers/staging/unisys/visorbus/visorbus_main.c  | 2 +-
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h
index 957a627..cc15bf8 100644
--- a/drivers/staging/unisys/include/guestlinuxdebug.h
+++ b/drivers/staging/unisys/include/guestlinuxdebug.h
@@ -22,7 +22,6 @@
 * ISSUE_IO_VMCALL_POSTCODE_SEVERITY */
 
 /******* INFO ON ISSUE_POSTCODE_LINUX() BELOW *******/
-#include "vmcallinterface.h"
 enum driver_pc {		/* POSTCODE driver identifier tuples */
 	/* visorchipset driver files */
 	VISOR_CHIPSET_PC = 0xA0,
diff --git a/drivers/staging/unisys/include/vbushelper.h b/drivers/staging/unisys/include/vbushelper.h
index 84abe5f..f272975 100644
--- a/drivers/staging/unisys/include/vbushelper.h
+++ b/drivers/staging/unisys/include/vbushelper.h
@@ -18,8 +18,6 @@
 #ifndef __VBUSHELPER_H__
 #define __VBUSHELPER_H__
 
-#include "vbusdeviceinfo.h"
-
 /* TARGET_HOSTNAME specified as -DTARGET_HOSTNAME=\"thename\" on the
  * command line */
 
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 59cf220..83cf920 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -23,7 +23,7 @@
 #include "periodic_work.h"
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
-#include "vbusdeviceinfo.h"
+#include "vmcallinterface.h"
 #include "vbuschannel.h"
 #include "controlvmchannel.h"
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 136/141] staging: unisys: Removed unused entries from struct visor_channeltype_descriptor
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (134 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 135/141] staging: unisys: Include missing headers Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 137/141] staging: unisys: Hide contents of pending_msg_hdr Benjamin Romer
                   ` (7 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: jkc, driverdev-devel, sparmaintainer, Jes Sorensen, Benjamin Romer

From: Jes Sorensen <Jes.Sorensen@redhat.com>

min_size/max_size aren't used anywhere, and they were just causing
headaches in the drivers being ported over to the new interfaces.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index d60421c..cc0724a 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -60,8 +60,6 @@ struct visorchipset_state {
 struct visor_channeltype_descriptor {
 	const uuid_le guid;
 	const char *name;
-	unsigned long min_size;
-	unsigned long max_size;
 };
 
 /** Information provided by each visor driver when it registers with the
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 137/141] staging: unisys: Hide contents of pending_msg_hdr
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (135 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 136/141] staging: unisys: Removed unused entries from struct visor_channeltype_descriptor Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 138/141] staging: unisys: Update diag serverity enum Benjamin Romer
                   ` (6 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: Don Zickus, driverdev-devel, sparmaintainer, Benjamin Romer

From: Don Zickus <dzickus@redhat.com>

The pending_msg_hdr element of struct visor_device should really be
private and not public.  Currently there is no easy way to do that
without allocating memory and passing it along from the command
notifier all the way to the command responder.

I tried to minimize the change and use NULL as the equivalent to
INVALID.  I also added a check for when the pending_msg_hdr is not
NULL during the call to _epilog.  This indicates a previous command
is inflight for the device/bus.  Not good.

I also guessed on an appropriate memory failure response to return
in case the kzalloc failed to allocate memory for the message header.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/visorbus.h      |  5 +-
 drivers/staging/unisys/visorbus/visorchipset.c | 67 +++++++++++++++++---------
 2 files changed, 48 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index cc0724a..17c15f5 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -37,7 +37,6 @@
 
 #include "periodic_work.h"
 #include "channel.h"
-#include "controlvmchannel.h"
 
 struct visor_driver;
 struct visor_device;
@@ -118,6 +117,8 @@ struct visor_driver {
 
 /** A device type for things "plugged" into the visorbus bus */
 
+struct controlvm_message_header;
+
 struct visor_device {
 	/** visor driver can use the visorchannel member with the functions
 	 *  defined in visorchannel.h to access the channel
@@ -154,7 +155,7 @@ struct visor_device {
 	uuid_le inst;
 	u8 *name;
 	u8 *description;
-	struct controlvm_message_header pending_msg_hdr;
+	struct controlvm_message_header *pending_msg_hdr;
 	void *vbus_hdr_info;
 	u32 switch_no;
 	u32 internal_port_no;
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index b1e059a..4a895e8 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -885,12 +885,13 @@ bus_responder(enum controlvm_id cmd_id, struct visor_device *p, int response)
 	if (cmd_id == CONTROLVM_BUS_CREATE)
 			p->state.created = 1;
 
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+	if (p->pending_msg_hdr == NULL)
 		return;		/* no controlvm response needed */
-	if (p->pending_msg_hdr.id != (u32)cmd_id)
+	if (p->pending_msg_hdr->id != (u32)cmd_id)
 		return;
-	controlvm_respond(&p->pending_msg_hdr, response);
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+	controlvm_respond(p->pending_msg_hdr, response);
+	kfree(p->pending_msg_hdr);
+	p->pending_msg_hdr = NULL;
 }
 
 static void
@@ -900,12 +901,12 @@ device_changestate_responder(enum controlvm_id cmd_id,
 {
 	struct controlvm_message outmsg;
 
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+	if (p->pending_msg_hdr == NULL)
 		return;		/* no controlvm response needed */
-	if (p->pending_msg_hdr.id != cmd_id)
+	if (p->pending_msg_hdr->id != cmd_id)
 		return;
 
-	controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
+	controlvm_init_response(&outmsg, p->pending_msg_hdr, response);
 
 	outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no;
 	outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no;
@@ -915,7 +916,8 @@ device_changestate_responder(enum controlvm_id cmd_id,
 				       CONTROLVM_QUEUE_REQUEST, &outmsg))
 		return;
 
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+	kfree(p->pending_msg_hdr);
+	p->pending_msg_hdr = NULL;
 }
 
 static void
@@ -926,14 +928,15 @@ device_responder(enum controlvm_id cmd_id, struct visor_device *p, int response)
 			p->state.created = 1;
 	}
 
-	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+	if (p->pending_msg_hdr == NULL)
 		return;		/* no controlvm response needed */
 
-	if (p->pending_msg_hdr.id != (u32)cmd_id)
+	if (p->pending_msg_hdr->id != (u32)cmd_id)
 		return;
 
-	controlvm_respond(&p->pending_msg_hdr, response);
-	p->pending_msg_hdr.id = CONTROLVM_INVALID;
+	controlvm_respond(p->pending_msg_hdr, response);
+	kfree(p->pending_msg_hdr);
+	p->pending_msg_hdr = NULL;
 }
 
 static void
@@ -942,12 +945,21 @@ bus_epilog(struct visor_device *bus_info,
 	   int response, bool need_response)
 {
 	bool notified = false;
-
-	if (need_response) {
-		memcpy(&bus_info->pending_msg_hdr, msg_hdr,
+	struct controlvm_message_header *pmsg_hdr;
+
+	if (bus_info->pending_msg_hdr) {
+		/* only non-NULL if bus is still waiting on a response */
+		response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
+		goto away;
+	} else if (need_response) {
+		pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
+		if (!pmsg_hdr) {
+			response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+			goto away;
+		}
+		memcpy(pmsg_hdr, msg_hdr,
 		       sizeof(struct controlvm_message_header));
-	} else {
-		bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+		bus_info->pending_msg_hdr = pmsg_hdr;
 	}
 
 	down(&notifier_lock);
@@ -967,6 +979,7 @@ bus_epilog(struct visor_device *bus_info,
 			break;
 		}
 	}
+away:
 	if (notified)
 		/* The callback function just called above is responsible
 		 * for calling the appropriate visorchipset_busdev_responders
@@ -987,6 +1000,7 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 	bool notified = false;
 	u32 bus_no = dev_info->chipset_bus_no;
 	u32 dev_no = dev_info->chipset_dev_no;
+	struct controlvm_message_header *pmsg_hdr;
 
 	char *envp[] = {
 		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
@@ -995,11 +1009,19 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 
 	notifiers = &busdev_notifiers;
 
-	if (need_response) {
-		memcpy(&dev_info->pending_msg_hdr, msg_hdr,
+	if (dev_info->pending_msg_hdr) {
+		/* only non-NULL if dev is still waiting on a response */
+		response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
+		goto away;
+	} else if (need_response) {
+		pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
+		if (!pmsg_hdr) {
+			response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+			goto away;
+		}
+		memcpy(pmsg_hdr, msg_hdr,
 		       sizeof(struct controlvm_message_header));
-	} else {
-		dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+		dev_info->pending_msg_hdr = pmsg_hdr;
 	}
 
 	down(&notifier_lock);
@@ -1057,6 +1079,7 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 			break;
 		}
 	}
+away:
 	if (notified)
 		/* The callback function just called above is responsible
 		 * for calling the appropriate visorchipset_busdev_responders
@@ -1156,7 +1179,7 @@ bus_configure(struct controlvm_message *inmsg,
 		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
 		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-	} else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
+	} else if (bus_info->pending_msg_hdr != NULL) {
 		POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
 		rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 138/141] staging: unisys: Update diag serverity enum
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (136 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 137/141] staging: unisys: Hide contents of pending_msg_hdr Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h Benjamin Romer
                   ` (5 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Give the enum the correct values instead of based on other values.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/diagchannel.h | 34 ++++++++--------------------
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h
index e8fb867..c1e74e8 100644
--- a/drivers/staging/unisys/include/diagchannel.h
+++ b/drivers/staging/unisys/include/diagchannel.h
@@ -58,20 +58,6 @@ static const uuid_le spar_diag_channel_protocol_uuid =
 * increment this. */
 #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
 
-#define SPAR_DIAG_CHANNEL_OK_CLIENT(ch)\
-	(spar_check_channel_client(ch,\
-				   spar_diag_channel_protocol_uuid,\
-				   "diag",\
-				   sizeof(struct spar_diag_channel_protocol),\
-				   ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID,\
-				   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
-
-#define SPAR_DIAG_CHANNEL_OK_SERVER(bytes)\
-	(spar_check_channel_server(spar_diag_channel_protocol_uuid,\
-				   "diag",\
-				   sizeof(struct spar_diag_channel_protocol),\
-				   bytes))
-
 #define MAX_MODULE_NAME_SIZE 128	/* Maximum length of module name... */
 #define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional info
 					 * accompanying event... */
@@ -204,16 +190,16 @@ struct diag_channel_event {
 * change is made to this enum, they should also be reflected in that file.  */
 enum diag_severity {
 		DIAG_SEVERITY_ENUM_BEGIN = 0,
-		DIAG_SEVERITY_OVERRIDE = DIAG_SEVERITY_ENUM_BEGIN,
-		DIAG_SEVERITY_VERBOSE = DIAG_SEVERITY_OVERRIDE,	/* 0 */
-		DIAG_SEVERITY_INFO = DIAG_SEVERITY_VERBOSE + 1,	/* 1 */
-		DIAG_SEVERITY_WARNING = DIAG_SEVERITY_INFO + 1,	/* 2 */
-		DIAG_SEVERITY_ERR = DIAG_SEVERITY_WARNING + 1,	/* 3 */
-		DIAG_SEVERITY_PRINT = DIAG_SEVERITY_ERR + 1,	/* 4 */
-		DIAG_SEVERITY_SHUTOFF = DIAG_SEVERITY_PRINT + 1, /* 5 */
-		DIAG_SEVERITY_ENUM_END = DIAG_SEVERITY_SHUTOFF,	/* 5 */
-		DIAG_SEVERITY_NONFATAL_ERR = DIAG_SEVERITY_ERR,
-		DIAG_SEVERITY_FATAL_ERR = DIAG_SEVERITY_PRINT
+		DIAG_SEVERITY_OVERRIDE = 0,
+		DIAG_SEVERITY_VERBOSE = 0,
+		DIAG_SEVERITY_INFO = 1,
+		DIAG_SEVERITY_WARNING = 2,
+		DIAG_SEVERITY_ERR = 3,
+		DIAG_SEVERITY_NONFATAL_ERR = 3,
+		DIAG_SEVERITY_PRINT = 4,
+		DIAG_SEVERITY_FATAL_ERR = 4,
+		DIAG_SEVERITY_SHUTOFF = 5,
+		DIAG_SEVERITY_ENUM_END = 5
 };
 
 /* Event Cause enums
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (137 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 138/141] staging: unisys: Update diag serverity enum Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-08  8:46   ` Dan Carpenter
  2015-05-05 22:37 ` [PATCH 140/141] staging: unisys: Clean up diag_serverity enum Benjamin Romer
                   ` (4 subsequent siblings)
  143 siblings, 1 reply; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Diagchannel.h is used primarily for the diagnostics channel. The
diagnostics channel is not being used by linux guests currently, so
the majority of the file is not needed. What is left is what is
needed to perform postcode vmcalls. Those postcodes will eventually
end up in the diag channel.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/diagchannel.h    | 366 +-----------------------
 drivers/staging/unisys/visorbus/visorbus_main.c |  48 ----
 drivers/staging/unisys/visorbus/visorchipset.c  |  45 ---
 3 files changed, 2 insertions(+), 457 deletions(-)

diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h
index c1e74e8..82932c5 100644
--- a/drivers/staging/unisys/include/diagchannel.h
+++ b/drivers/staging/unisys/include/diagchannel.h
@@ -13,169 +13,15 @@
  * details.
  */
 
-/*++
- *
- * Module Name:
- *
- * diagchannel.h
- *
- * Abstract:
- *
- * This file defines the DiagChannel protocol.  This protocol is used to aid in
- * preserving event data sent by external applications.  This protocol provides
- * a region for event data to reside in.  This data will eventually be sent to
- * the Boot Partition where it will be committed to memory and/or disk.  This
- * file contains platform-independent data that can be built using any
- * Supervisor build environment (Windows, Linux, EFI).
- *
-*/
-
 #ifndef _DIAG_CHANNEL_H_
 #define _DIAG_CHANNEL_H_
 
 #include <linux/uuid.h>
-#include "channel.h"
-
-/* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */
-#define SPAR_DIAG_CHANNEL_PROTOCOL_UUID \
-		UUID_LE(0xeea7a573, 0xdb82, 0x447c, \
-				0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58)
-
-static const uuid_le spar_diag_channel_protocol_uuid =
-	SPAR_DIAG_CHANNEL_PROTOCOL_UUID;
-
-/* {E850F968-3263-4484-8CA5-2A35D087A5A8} */
-#define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \
-		UUID_LE(0xe850f968, 0x3263, 0x4484, \
-				0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8)
-
-#define ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE  ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-
-/* Must increment this whenever you insert or delete fields within this channel
-* struct.  Also increment whenever you change the meaning of fields within this
-* channel struct so as to break pre-existing software.  Note that you can
-* usually add fields to the END of the channel struct withOUT needing to
-* increment this. */
-#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
 
 #define MAX_MODULE_NAME_SIZE 128	/* Maximum length of module name... */
 #define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional info
-					 * accompanying event... */
-#define MAX_SUBSYSTEMS 64	/* Maximum number of subsystems allowed in
-				 * DiagChannel... */
-#define LOW_SUBSYSTEMS 32	/* Half of MAX_SUBSYSTEMS to allow 64-bit
-				 * math */
-#define SUBSYSTEM_DEBUG 0	/* Standard subsystem for debug events */
-#define SUBSYSTEM_DEFAULT 1	/* Default subsystem for legacy calls to
-				 * ReportEvent */
-
-/* few useful subsystem mask values */
-#define SUBSYSTEM_MASK_DEBUG	0x01	/* Standard subsystem for debug
-					 * events */
-#define SUBSYSTEM_MASK_DEFAULT  0x02	/* Default subsystem for legacy calls to
-					 * ReportEvents */
-
-/* Event parameter "Severity" is overloaded with Cause in byte 2 and Severity in
- * byte 0, bytes 1 and 3 are reserved */
-#define SEVERITY_MASK 0x0FF	/* mask out all but the Severity in byte 0 */
-#define CAUSE_MASK 0x0FF0000	/* mask out all but the cause in byte 2 */
-#define CAUSE_SHIFT_AMT 16	/* shift 2 bytes to place it in byte 2 */
-
-/* SubsystemSeverityFilter */
-#define SEVERITY_FILTER_MASK 0x0F /* mask out the Cause half, SeverityFilter is
-				   * in the lower nibble */
-#define CAUSE_FILTER_MASK 0xF0	/* mask out the Severity half, CauseFilter is in
-				 * the upper nibble */
-#define CAUSE_FILTER_SHIFT_AMT	4 /* shift amount to place it in lower or upper
-				   * nibble */
-
-/* Copied from EFI's EFI_TIME struct in efidef.h.  EFI headers are not allowed
-* in some of the Supervisor areas, such as Monitor, so it has been "ported" here
-* for use in diagnostic event timestamps... */
-struct diag_efi_time  {
-	u16 year;		/* 1998 - 20XX */
-	u8 month;		/* 1 - 12 */
-	u8 day;			/* 1 - 31 */
-	u8 hour;		/* 0 - 23 */
-	u8 minute;		/* 0 - 59 */
-	u8 second;		/* 0 - 59 */
-	u8 pad1;
-	u32 nanosecond;	/* 0 - 999, 999, 999 */
-	s16 timezone;		/* -1440 to 1440 or 2047 */
-	u8 daylight;
-	u8 pad2;
-};
-
-enum spar_component_types  {
-	 ULTRA_COMPONENT_GUEST = 0,
-	 ULTRA_COMPONENT_MONITOR = 0x01,
-	 ULTRA_COMPONENT_CCM = 0x02,	/* Common Control module */
-	 /* RESERVED 0x03 - 0x7 */
-
-	 /* Ultravisor Components */
-	 ULTRA_COMPONENT_BOOT = 0x08,
-	 ULTRA_COMPONENT_IDLE = 0x09,
-	 ULTRA_COMPONENT_CONTROL = 0x0A,
-	 ULTRA_COMPONENT_LOGGER = 0x0B,
-	 ULTRA_COMPONENT_ACPI = 0X0C,
-	 /* RESERVED 0x0D - 0x0F */
-
-	 /* sPAR Components */
-	 ULTRA_COMPONENT_COMMAND = 0x10,
-	 ULTRA_COMPONENT_IODRIVER = 0x11,
-	 ULTRA_COMPONENT_CONSOLE = 0x12,
-	 ULTRA_COMPONENT_OPERATIONS = 0x13,
-	 ULTRA_COMPONENT_MANAGEMENT = 0x14,
-	 ULTRA_COMPONENT_DIAG = 0x15,
-	 ULTRA_COMPONENT_HWDIAG = 0x16,
-	 ULTRA_COMPONENT_PSERVICES = 0x17,
-	 ULTRA_COMPONENT_PDIAG = 0x18
-	 /* RESERVED 0x18 - 0x1F */
-};
-
-/* Structure: diag_channel_event Purpose: Contains attributes that make up an
- * event to be written to the DIAG_CHANNEL memory.  Attributes: EventId: Id of
- * the diagnostic event to write to memory.  Severity: Severity of the event
- * (Error, Info, etc).  ModuleName: Module/file name where event originated.
- * LineNumber: Line number in module name where event originated.  Timestamp:
- * Date/time when event was received by ReportEvent, and written to DiagChannel.
- * Reserved: Padding to align structure on a 64-byte cache line boundary.
- * AdditionalInfo: Array of characters for additional event info (may be
- * empty).  */
-struct diag_channel_event {
-	u32 event_id;
-	u32 severity;
-	u8 module_name[MAX_MODULE_NAME_SIZE];
-	u32 line_number;
-	struct diag_efi_time timestamp;	/* Size = 16 bytes */
-	u32 partition_number;	/* Filled in by Diag Switch as pool blocks are
-				 * filled */
-	u16 vcpu_number;
-	u16 lcpu_number;
-	u8 component_type;	/* ULTRA_COMPONENT_TYPES */
-	u8 subsystem;
-	u16 reserved0;		/* pad to u64 alignment */
-	u32 block_no;		/* filled in by DiagSwitch as pool blocks are
-				 * filled */
-	u32 block_no_high;
-	u32 event_no;		/* filled in by DiagSwitch as pool blocks are
-				 * filled */
-	u32 event_no_high;
-
-	/* The block_no and event_no fields are set only by DiagSwitch
-	 * and referenced only by WinDiagDisplay formatting tool as
-	 * additional diagnostic information.  Other tools including
-	 * WinDiagDisplay currently ignore these 'Reserved' bytes. */
-	u8 reserved[8];
-	u8 additional_info[MAX_ADDITIONAL_INFO_SIZE];
-
-	/* NOTE: Changes to diag_channel_event generally need to be reflected in
-	 * existing copies *
-	 * - for AppOS at
-	 * GuestLinux/visordiag_early/supervisor_diagchannel.h *
-	 * - for WinDiagDisplay at
-	 * EFI/Ultra/Tools/WinDiagDisplay/WinDiagDisplay/diagstruct.h */
-};
+					 * accompanying event...
+					 */
 
 /* Levels of severity for diagnostic events, in order from lowest severity to
 * highest (i.e. fatal errors are the most severe, and should always be logged,
@@ -202,212 +48,4 @@ enum diag_severity {
 		DIAG_SEVERITY_ENUM_END = 5
 };
 
-/* Event Cause enums
-*
-* Levels of cause for diagnostic events, in order from least to greatest cause
-* Internal errors are most urgent since ideally they should never exist
-* Invalid requests are preventable by avoiding invalid inputs
-* Operations errors depend on environmental factors which may impact which
-* requests are possible
-* Manifest provides intermediate value to capture firmware and configuration
-* version information
-* Trace provides suplimental debug information in release firmware
-* Unknown Log captures unclasified LogEvent calls.
-* Debug is the least urgent since it provides suplimental debug information only
-* in debug firmware
-* Unknown Debug captures unclassified DebugEvent calls.
-* This enum is also defined in
-* DotNet\sParFramework\ControlFramework\ControlFramework.cs.
-* If a change is made to this enum, they should also be reflected in that
-* file.  */
-
-/* A cause value "DIAG_CAUSE_FILE_XFER" together with a severity value of
-* "DIAG_SEVERITY_PRINT" (=4), is used for transferring text or binary file to
-* the Diag partition. This cause-severity combination will be used by Logger
-* DiagSwitch to segregate events into block types. The files are transferred in
-* 256 byte chunks maximum, in the AdditionalInfo field of the diag_channel_event
-* structure. In the file transfer mode, some event fields will have different
-* meaning: EventId specifies the file offset, severity specifies the block type,
-* ModuleName specifies the filename, LineNumber specifies the number of valid
-* data bytes in an event and AdditionalInfo contains up to 256 bytes of data. */
-
-/* The Diag DiagWriter appends event blocks to events.raw as today, and for data
- * blocks uses diag_channel_event
- * PartitionNumber to extract and append 'AdditionalInfo' to filename (specified
- * by ModuleName). */
-
-/* The Dell PDiag uses this new mechanism to stash DSET .zip onto the
- * 'diagnostic' virtual disk.  */
-enum diag_cause {
-	DIAG_CAUSE_UNKNOWN = 0,
-	DIAG_CAUSE_UNKNOWN_DEBUG = DIAG_CAUSE_UNKNOWN + 1,	/* 1 */
-	DIAG_CAUSE_DEBUG = DIAG_CAUSE_UNKNOWN_DEBUG + 1,	/* 2 */
-	DIAG_CAUSE_UNKNOWN_LOG = DIAG_CAUSE_DEBUG + 1,	/* 3 */
-	DIAG_CAUSE_TRACE = DIAG_CAUSE_UNKNOWN_LOG + 1,	/* 4 */
-	DIAG_CAUSE_MANIFEST = DIAG_CAUSE_TRACE + 1,	/* 5 */
-	DIAG_CAUSE_OPERATIONS_ERROR = DIAG_CAUSE_MANIFEST + 1,	/* 6 */
-	DIAG_CAUSE_INVALID_REQUEST = DIAG_CAUSE_OPERATIONS_ERROR + 1,	/* 7 */
-	DIAG_CAUSE_INTERNAL_ERROR = DIAG_CAUSE_INVALID_REQUEST + 1, /* 8 */
-	DIAG_CAUSE_FILE_XFER = DIAG_CAUSE_INTERNAL_ERROR + 1,	/* 9 */
-	DIAG_CAUSE_ENUM_END = DIAG_CAUSE_FILE_XFER	/* 9 */
-};
-
-/* Event Cause category defined into the byte 2 of Severity */
-#define CAUSE_DEBUG (DIAG_CAUSE_DEBUG << CAUSE_SHIFT_AMT)
-#define CAUSE_TRACE (DIAG_CAUSE_TRACE << CAUSE_SHIFT_AMT)
-#define CAUSE_MANIFEST (DIAG_CAUSE_MANIFEST << CAUSE_SHIFT_AMT)
-#define CAUSE_OPERATIONS_ERROR (DIAG_CAUSE_OPERATIONS_ERROR << CAUSE_SHIFT_AMT)
-#define CAUSE_INVALID_REQUEST (DIAG_CAUSE_INVALID_REQUEST << CAUSE_SHIFT_AMT)
-#define CAUSE_INTERNAL_ERROR (DIAG_CAUSE_INTERNAL_ERROR << CAUSE_SHIFT_AMT)
-#define CAUSE_FILE_XFER (DIAG_CAUSE_FILE_XFER << CAUSE_SHIFT_AMT)
-#define CAUSE_ENUM_END CAUSE_FILE_XFER
-
-/* Combine Cause and Severity categories into one */
-#define CAUSE_DEBUG_SEVERITY_VERBOSE \
-	(CAUSE_DEBUG | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_TRACE_SEVERITY_VERBOSE \
-	(CAUSE_TRACE | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_MANIFEST_SEVERITY_VERBOSE\
-	(CAUSE_MANIFEST | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_OPERATIONS_SEVERITY_VERBOSE \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_INVALID_SEVERITY_VERBOSE \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_VERBOSE)
-#define CAUSE_INTERNAL_SEVERITY_VERBOSE \
-	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_VERBOSE)
-
-#define CAUSE_DEBUG_SEVERITY_INFO \
-	(CAUSE_DEBUG | DIAG_SEVERITY_INFO)
-#define CAUSE_TRACE_SEVERITY_INFO \
-	(CAUSE_TRACE | DIAG_SEVERITY_INFO)
-#define CAUSE_MANIFEST_SEVERITY_INFO \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_INFO)
-#define CAUSE_OPERATIONS_SEVERITY_INFO \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_INFO)
-#define CAUSE_INVALID_SEVERITY_INFO \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_INFO)
-#define CAUSE_INTERNAL_SEVERITY_INFO \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_INFO)
-
-#define CAUSE_DEBUG_SEVERITY_WARN \
-	(CAUSE_DEBUG | DIAG_SEVERITY_WARNING)
-#define CAUSE_TRACE_SEVERITY_WARN \
-	(CAUSE_TRACE | DIAG_SEVERITY_WARNING)
-#define CAUSE_MANIFEST_SEVERITY_WARN \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_WARNING)
-#define CAUSE_OPERATIONS_SEVERITY_WARN \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_WARNING)
-#define CAUSE_INVALID_SEVERITY_WARN \
-	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_WARNING)
-#define CAUSE_INTERNAL_SEVERITY_WARN \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_WARNING)
-
-#define CAUSE_DEBUG_SEVERITY_ERR \
-	(CAUSE_DEBUG | DIAG_SEVERITY_ERR)
-#define CAUSE_TRACE_SEVERITY_ERR \
-	(CAUSE_TRACE | DIAG_SEVERITY_ERR)
-#define CAUSE_MANIFEST_SEVERITY_ERR \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_ERR)
-#define CAUSE_OPERATIONS_SEVERITY_ERR \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_ERR)
-#define CAUSE_INVALID_SEVERITY_ERR \
-	(CAUSE_INVALID_REQUEST  | DIAG_SEVERITY_ERR)
-#define CAUSE_INTERNAL_SEVERITY_ERR \
-	(CAUSE_INTERNAL_ERROR   | DIAG_SEVERITY_ERR)
-
-#define CAUSE_DEBUG_SEVERITY_PRINT \
-	(CAUSE_DEBUG | DIAG_SEVERITY_PRINT)
-#define CAUSE_TRACE_SEVERITY_PRINT \
-	(CAUSE_TRACE | DIAG_SEVERITY_PRINT)
-#define CAUSE_MANIFEST_SEVERITY_PRINT \
-	(CAUSE_MANIFEST | DIAG_SEVERITY_PRINT)
-#define CAUSE_OPERATIONS_SEVERITY_PRINT \
-	(CAUSE_OPERATIONS_ERROR | DIAG_SEVERITY_PRINT)
-#define CAUSE_INVALID_SEVERITY_PRINT \
-	(CAUSE_INVALID_REQUEST | DIAG_SEVERITY_PRINT)
-#define CAUSE_INTERNAL_SEVERITY_PRINT \
-	(CAUSE_INTERNAL_ERROR | DIAG_SEVERITY_PRINT)
-#define CAUSE_FILE_XFER_SEVERITY_PRINT \
-	(CAUSE_FILE_XFER | DIAG_SEVERITY_PRINT)
-
-/* Structure: diag_channel_protocol_header
- *
- * Purpose: Contains attributes that make up the header specific to the
- * DIAG_CHANNEL area.
- *
- * Attributes:
- *
- * DiagLock: Diag Channel spinlock.
- *
- *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise
- *			0, and assume the channel is not ready for use yet.
- *
- * Reserved: Padding to align the fields in this structure.
- *
- *SubsystemSeverityFilter: Level of severity on a subsystem basis that controls
- *			whether events are logged.  Any event's severity for a
- *			particular subsystem below this level will be discarded.
- */
-struct diag_channel_protocol_header {
-	u32 diag_lock;
-	u8 channel_initialized;
-	u8 reserved[3];
-	u8 subsystem_severity_filter[64];
-};
-
-/* The Diagram for the Diagnostic Channel: */
-/* ----------------------- */
-/* | Channel Header        |	Defined by ULTRA_CHANNEL_PROTOCOL */
-/* ----------------------- */
-/* | Signal Queue Header   |	Defined by SIGNAL_QUEUE_HEADER */
-/* ----------------------- */
-/* | DiagChannel Header    |	Defined by diag_channel_protocol_header */
-/* ----------------------- */
-/* | Channel Event Info    |	Defined by diag_channel_event*MAX_EVENTS */
-/* ----------------------- */
-/* | Reserved              |	Reserved (pad out to 4MB) */
-/* ----------------------- */
-
-/* Offsets/sizes for diagnostic channel attributes... */
-#define DIAG_CH_QUEUE_HEADER_OFFSET (sizeof(struct channel_header))
-#define DIAG_CH_QUEUE_HEADER_SIZE (sizeof(struct signal_queue_header))
-#define DIAG_CH_PROTOCOL_HEADER_OFFSET \
-	(DIAG_CH_QUEUE_HEADER_OFFSET + DIAG_CH_QUEUE_HEADER_SIZE)
-#define DIAG_CH_PROTOCOL_HEADER_SIZE \
-	(sizeof(struct diag_channel_protocol_header))
-#define DIAG_CH_EVENT_OFFSET \
-	(DIAG_CH_PROTOCOL_HEADER_OFFSET + DIAG_CH_PROTOCOL_HEADER_SIZE)
-#define DIAG_CH_SIZE (4096 * 1024)
-
-/* For Control and Idle Partitions with larger (8 MB) diagnostic(root)
- * channels */
-#define DIAG_CH_LRG_SIZE (2 * DIAG_CH_SIZE)	/* 8 MB */
-
-/*
- * Structure: spar_diag_channel_protocol
- *
- * Purpose: Contains attributes that make up the DIAG_CHANNEL memory.
- *
- * Attributes:
- *
- * CommonChannelHeader:	Header info common to all channels.
- *
- * QueueHeader: Queue header common to all channels - used to determine where to
- * store event.
- *
- * DiagChannelHeader: Diagnostic channel header info (see
- * diag_channel_protocol_header comments).
- *
- * Events: Area where diagnostic events (up to MAX_EVENTS) are written.
- *
- *Reserved: Reserved area to allow for correct channel size padding.
-*/
-struct spar_diag_channel_protocol  {
-	struct channel_header common_channel_header;
-	struct signal_queue_header queue_header;
-	struct diag_channel_protocol_header diag_channel_header;
-	struct diag_channel_event events[(DIAG_CH_SIZE - DIAG_CH_EVENT_OFFSET) /
-				   sizeof(struct diag_channel_event)];
-};
-
 #endif
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 83cf920..8971b61 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1049,54 +1049,6 @@ find_visor_device_by_channel(u64 channel_physaddr)
 }
 
 static int
-init_vbus_channel(struct visorchannel *chan)
-{
-	int rc = -1;
-	unsigned long allocated_bytes = visorchannel_get_nbytes(chan);
-	struct spar_vbus_channel_protocol *x =
-		kmalloc(sizeof(struct spar_vbus_channel_protocol),
-			GFP_KERNEL);
-
-	POSTCODE_LINUX_3(VBUS_CHANNEL_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
-
-	if (x) {
-		POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
-		goto away;
-	}
-	if (visorchannel_clear(chan, 0, 0, allocated_bytes) < 0) {
-		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		goto away;
-	}
-	if (visorchannel_read
-	    (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
-		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		goto away;
-	}
-	if (!SPAR_VBUS_CHANNEL_OK_SERVER(allocated_bytes)) {
-		POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
-				 POSTCODE_SEVERITY_ERR);
-		goto away;
-	}
-
-	if (visorchannel_write
-	    (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
-		POSTCODE_LINUX_3(VBUS_CHANNEL_FAILURE_PC, chan,
-				 POSTCODE_SEVERITY_ERR);
-		goto away;
-	}
-
-	POSTCODE_LINUX_3(VBUS_CHANNEL_EXIT_PC, chan, POSTCODE_SEVERITY_INFO);
-	rc = 0;
-
-away:
-	kfree(x);
-	x = NULL;
-	return rc;
-}
-
-static int
 get_vbus_header_info(struct visorchannel *chan,
 		     struct spar_vbus_headerinfo *hdr_info)
 {
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 4a895e8..2b93b4b 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -110,17 +110,8 @@ static DEFINE_SEMAPHORE(notifier_lock);
 static struct cdev file_cdev;
 static struct visorchannel **file_controlvm_channel;
 static struct controlvm_message_header g_chipset_msg_hdr;
-static const uuid_le spar_diag_pool_channel_protocol_uuid =
-	SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
-/* 0xffffff is an invalid Bus/Device number */
-static u32 g_diagpool_bus_no = 0xffffff;
-static u32 g_diagpool_dev_no = 0xffffff;
 static struct controlvm_message_packet g_devicechangestate_packet;
 
-#define is_diagpool_channel(channel_type_guid) \
-	(uuid_le_cmp(channel_type_guid,\
-		     spar_diag_pool_channel_protocol_uuid) == 0)
-
 static LIST_HEAD(bus_info_list);
 static LIST_HEAD(dev_info_list);
 
@@ -827,14 +818,6 @@ controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
 	struct controlvm_message outmsg;
 
 	controlvm_init_response(&outmsg, msg_hdr, response);
-	/* For DiagPool channel DEVICE_CHANGESTATE, we need to send
-	* back the deviceChangeState structure in the packet. */
-	if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
-	    g_devicechangestate_packet.device_change_state.bus_no ==
-	    g_diagpool_bus_no &&
-	    g_devicechangestate_packet.device_change_state.dev_no ==
-	    g_diagpool_dev_no)
-		outmsg.cmd = g_devicechangestate_packet;
 	if (outmsg.hdr.flags.test_message == 1)
 		return;
 
@@ -998,15 +981,8 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 {
 	struct visorchipset_busdev_notifiers *notifiers;
 	bool notified = false;
-	u32 bus_no = dev_info->chipset_bus_no;
-	u32 dev_no = dev_info->chipset_dev_no;
 	struct controlvm_message_header *pmsg_hdr;
 
-	char *envp[] = {
-		"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
-		NULL
-	};
-
 	notifiers = &busdev_notifiers;
 
 	if (dev_info->pending_msg_hdr) {
@@ -1054,21 +1030,6 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 					(*notifiers->device_pause) (dev_info);
 					notified = true;
 				}
-			} else if (state.alive == segment_state_paused.alive &&
-				   state.operating ==
-				   segment_state_paused.operating) {
-				/* this is lite pause where channel is
-				 * still valid just 'pause' of it
-				 */
-				if (bus_no == g_diagpool_bus_no &&
-				    dev_no == g_diagpool_dev_no) {
-					/* this will trigger the
-					 * diag_shutdown.sh script in
-					 * the visorchipset hotplug */
-					kobject_uevent_env
-					    (&visorchipset_platform_device.dev.
-					     kobj, KOBJ_ONLINE, envp);
-				}
 			}
 			break;
 		case CONTROLVM_DEVICE_DESTROY:
@@ -1261,12 +1222,6 @@ my_device_create(struct controlvm_message *inmsg)
 	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 cleanup:
-	/* get the bus and devNo for DiagPool channel */
-	if (dev_info &&
-	    is_diagpool_channel(cmd->create_device.data_type_uuid)) {
-		g_diagpool_bus_no = bus_no;
-		g_diagpool_dev_no = dev_no;
-	}
 	device_epilog(dev_info, segment_state_running,
 		      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
 		      inmsg->hdr.flags.response_expected == 1, 1);
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 140/141] staging: unisys: Clean up diag_serverity enum
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (138 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-05 22:37 ` [PATCH 141/141] staging: unisys: Get rid of unused function Benjamin Romer
                   ` (3 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh
  Cc: jkc, driverdev-devel, sparmaintainer, David Kershner, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

Get rid of unused values in the enum.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/include/diagchannel.h | 32 +++++++++++-----------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/unisys/include/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h
index 82932c5..d2d3568 100644
--- a/drivers/staging/unisys/include/diagchannel.h
+++ b/drivers/staging/unisys/include/diagchannel.h
@@ -16,36 +16,28 @@
 #ifndef _DIAG_CHANNEL_H_
 #define _DIAG_CHANNEL_H_
 
-#include <linux/uuid.h>
-
 #define MAX_MODULE_NAME_SIZE 128	/* Maximum length of module name... */
-#define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional info
-					 * accompanying event...
+#define MAX_ADDITIONAL_INFO_SIZE 256	/* Maximum length of any additional
+					 * info accompanying event...
 					 */
 
 /* Levels of severity for diagnostic events, in order from lowest severity to
-* highest (i.e. fatal errors are the most severe, and should always be logged,
-* but info events rarely need to be logged except during debugging).  The values
-* DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid severity
-* values.  They exist merely to dilineate the list, so that future additions
-* won't require changes to the driver (i.e. when checking for out-of-range
-* severities in SetSeverity).  The values DIAG_SEVERITY_OVERRIDE and
-* DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events but
-* they are valid for controlling the amount of event data.  This enum is also
-* defined in DotNet\sParFramework\ControlFramework\ControlFramework.cs.  If a
-* change is made to this enum, they should also be reflected in that file.  */
+ * highest (i.e. fatal errors are the most severe, and should always be logged,
+ * but info events rarely need to be logged except during debugging). The
+ * values DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid
+ * severity values.  They exist merely to dilineate the list, so that future
+ * additions won't require changes to the driver (i.e. when checking for
+ * out-of-range severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE
+ * and DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events
+ * but they are valid for controlling the amount of event data. Changes made
+ * to the enum, need to be reflected in s-Par.
+ */
 enum diag_severity {
-		DIAG_SEVERITY_ENUM_BEGIN = 0,
-		DIAG_SEVERITY_OVERRIDE = 0,
 		DIAG_SEVERITY_VERBOSE = 0,
 		DIAG_SEVERITY_INFO = 1,
 		DIAG_SEVERITY_WARNING = 2,
 		DIAG_SEVERITY_ERR = 3,
-		DIAG_SEVERITY_NONFATAL_ERR = 3,
 		DIAG_SEVERITY_PRINT = 4,
-		DIAG_SEVERITY_FATAL_ERR = 4,
-		DIAG_SEVERITY_SHUTOFF = 5,
-		DIAG_SEVERITY_ENUM_END = 5
 };
 
 #endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* [PATCH 141/141] staging: unisys: Get rid of unused function
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (139 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 140/141] staging: unisys: Clean up diag_serverity enum Benjamin Romer
@ 2015-05-05 22:37 ` Benjamin Romer
  2015-05-08  8:52 ` [PATCH 000/141] staging: unisys: s-Par driver rebuild series Dan Carpenter
                   ` (2 subsequent siblings)
  143 siblings, 0 replies; 173+ messages in thread
From: Benjamin Romer @ 2015-05-05 22:37 UTC (permalink / raw)
  To: gregkh; +Cc: driverdev-devel, sparmaintainer, Benjamin Romer

From: David Kershner <david.kershner@unisys.com>

The function find_visor_device_by_channel was not used, get rid of it.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index 8971b61..c39f981 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1032,22 +1032,6 @@ remove_visor_device(struct visor_device *dev)
 	device_unregister(&dev->device);
 }
 
-static struct visor_device *
-find_visor_device_by_channel(u64 channel_physaddr)
-{
-	struct list_head *listentry, *listtmp;
-
-	list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
-		struct visor_device *dev = list_entry(listentry,
-						      struct visor_device,
-						      list_all);
-		if (visorchannel_get_physaddr(dev->visorchannel) ==
-		    channel_physaddr)
-			return dev;
-	}
-	return NULL;
-}
-
 static int
 get_vbus_header_info(struct visorchannel *chan,
 		     struct spar_vbus_headerinfo *hdr_info)
-- 
2.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 173+ messages in thread

* Re: [PATCH 023/141] staging: unisys: add visorbus driver
  2015-05-05 22:36 ` [PATCH 023/141] staging: unisys: add visorbus driver Benjamin Romer
@ 2015-05-06  9:41   ` Dan Carpenter
  2015-05-09  8:59   ` Dan Carpenter
  1 sibling, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06  9:41 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, sparmaintainer, driverdev-devel, Erik Arfvidson

On Tue, May 05, 2015 at 06:36:00PM -0400, Benjamin Romer wrote:
> +int
> +devmajorminor_create_file(struct visor_device *dev, const char *name,
> +			  int major, int minor)
> +{
> +	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Nope.  Also don't use a variable for this.  Just use ARRAY_SIZE()
directly in the code.


> +	struct devmajorminor_attribute *myattr = NULL;
> +	int x = -1, rc = 0, slot = -1;
            ^

Why do we have an X coordinate without a Y coordinate?

Don't initialize variables for no reason.

> +
> +	register_devmajorminor_attributes(dev);
> +	for (slot = 0; slot < maxdevnodes; slot++)
> +		if (!dev->devnodes[slot].attr)
> +			break;
> +	if (slot == maxdevnodes) {
> +		rc = -ENOMEM;
> +		goto away;
> +	}
> +	myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
> +	if (!myattr) {
> +		rc = -ENOMEM;
> +		goto away;
> +	}
> +	memset(myattr, 0, sizeof(struct devmajorminor_attribute));
> +	myattr->show = DEVMAJORMINOR_ATTR;
> +	myattr->store = NULL;
> +	myattr->slot = slot;
> +	myattr->attr.name = name;
> +	myattr->attr.mode = S_IRUGO;
> +	dev->devnodes[slot].attr = myattr;
> +	dev->devnodes[slot].major = major;
> +	dev->devnodes[slot].minor = minor;
> +	x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr);
> +	if (x < 0) {
> +		rc = x;
> +		goto away;
> +	}
> +	kobject_uevent(&dev->device.kobj, KOBJ_ONLINE);
> +away:
> +	if (rc < 0) {
> +		kfree(myattr);
> +		myattr = NULL;
> +		dev->devnodes[slot].attr = NULL;
> +	}
> +	return rc;
> +}

When you only have one error label it causes One Err Bugs.  These are
one of the most common type of error handling bugs in the linux kernel.

Some people don't like using direct returns because they think it means
that in the future people will forget to add error handling.  I have
studied this a bit.  If you look through the kernel git log for
bug where we return with a lock held bugs, then many of those functions
had an out: label already but people still just added a return.  My
conclusion is that the kind of people who forget to add error handling
will mostly forget regardless of if there is an away: label or not.

The problem with jumbling all the error paths together into one label is
that it's a pile of spaghetti.  But if you think about error handling
closer to where the error happens, it's easier to get it right.

Anyway, the bug here is that:

		dev->devnodes[slot].attr = NULL;

is corrupting beyond the end of the array.

Also remove the "myattr = NULL;" since that is a pointless thing.

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 024/141] staging: unisys: Move visorchannel into visorbus
  2015-05-05 22:36 ` [PATCH 024/141] staging: unisys: Move visorchannel into visorbus Benjamin Romer
@ 2015-05-06 10:00   ` Dan Carpenter
  2015-05-06 10:05     ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 10:00 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:36:01PM -0400, Benjamin Romer wrote:
> From: Don Zickus <dzickus@redhat.com>
> +	rc = p;
> +cleanup:
> +
> +	if (!rc) {
> +		if (!p) {
> +			visorchannel_destroy(p);
> +			p = NULL;
> +		}
> +	}
> +	return rc;
> +}

Ho ho ho.  More one err bugs.  In this case there was no reason to mix
the error and the success path.

	return p;

err_destroy:
	visorchannel_destroy(p);
	return NULL;

No confusing nested if statements.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 024/141] staging: unisys: Move visorchannel into visorbus
  2015-05-06 10:00   ` Dan Carpenter
@ 2015-05-06 10:05     ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 10:05 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

Oh.  Don didn't introduce this bug, he was just moving files around.
It's better to not modify things when you move them so Don's patch is
correct.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts()
  2015-05-05 22:36 ` [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts() Benjamin Romer
@ 2015-05-06 12:15   ` Dan Carpenter
  2015-05-06 16:25     ` Ben Romer
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 12:15 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Prarit Bhargava, gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:36:17PM -0400, Benjamin Romer wrote:
> From: Prarit Bhargava <prarit@redhat.com>
> diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
> index 33a4360..ff14a0d 100644
> --- a/drivers/staging/unisys/visorbus/visorchannel.c
> +++ b/drivers/staging/unisys/visorbus/visorchannel.c
> @@ -55,60 +55,52 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
>  			 struct visorchannel *parent, ulong off, uuid_le guid,
>  			 BOOL needs_lock)

> -	void *rc = NULL;
> +	struct visorchannel *channel;
> +	int err;
> +	size_t size = sizeof(struct channel_header);

This patch is fine and I was going to ignore some minor nits but then
they became a habbit in later patches.  Don't make "size" a variable
for no reason (I guess the reason is that the original code didn't fit
into the 80 character limit but that doesn't count as a valid reason).
It just means we have to scroll up to find what "size" is.  "size" is a
generic meaningless name.  This patch doesn't even use it consistently.

> +	err = visor_memregion_read(channel->memregion, 0, &channel->chan_hdr,
> +				   sizeof(struct channel_header));
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See?  This one wasn't updated.

Also there were some unrelated changes.  Benjamin, you should have
complained about those when the patch was first sent.  That's like the
most obvious thing to check when you're reviewing patches.  Now it's an
awkward thing because there are 101 more patches on top of it.

Anyway, let's merge this because it's a very minor thing.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 041/141] staging: unisys: visorchannel some general function cleanups
  2015-05-05 22:36 ` [PATCH 041/141] staging: unisys: visorchannel some general function cleanups Benjamin Romer
@ 2015-05-06 12:56   ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 12:56 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Prarit Bhargava, gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:36:18PM -0400, Benjamin Romer wrote:
> From: Prarit Bhargava <prarit@redhat.com>
> 
> Just some cleanups for visorchannel.c, and removal of
> safe_sig_queue_validate() which is dead code.
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
> ---
>  drivers/staging/unisys/visorbus/visorchannel.c | 110 +++++++++----------------
>  1 file changed, 41 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
> index ff14a0d..30bedcc 100644
> --- a/drivers/staging/unisys/visorbus/visorchannel.c
> +++ b/drivers/staging/unisys/visorbus/visorchannel.c
> @@ -211,13 +211,12 @@ int
>  visorchannel_read(struct visorchannel *channel, ulong offset,
>  		  void *local, ulong nbytes)
>  {
> -	int rc = visor_memregion_read(channel->memregion, offset,
> -				      local, nbytes);
> -	if ((rc >= 0) && (offset == 0) &&
> -	    (nbytes >= sizeof(struct channel_header))) {
> -		memcpy(&channel->chan_hdr, local,
> -		       sizeof(struct channel_header));
> -	}
> +	int rc;
> +	size_t size = sizeof(struct channel_header);
> +
> +	rc = visor_memregion_read(channel->memregion, offset, local, nbytes);
> +	if (rc && !offset && (nbytes >= size))
> +		memcpy(&channel->chan_hdr, local, size);
>  	return rc;
>  }

This function is decidedly odd.

So if visor_memregion_read() fails (which can only happy if we try to
read too much data) and offset is zero and nbytes is too large then we
corrupt memory and return failure.  Woohoo!

Fortunately the only place which can call this with invalid nbytes is
visorchannel_dump_section() and that seems to be dead code.

visorchannel_write() has the same issues but there are no callers which
pass invalid "nbytes".

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes
  2015-05-05 22:36 ` [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes Benjamin Romer
@ 2015-05-06 13:46   ` Dan Carpenter
  2015-05-06 14:23     ` Jes Sorensen
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 13:46 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, driverdev-devel, sparmaintainer, Jes Sorensen

On Tue, May 05, 2015 at 06:36:56PM -0400, Benjamin Romer wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
> ---
>  drivers/staging/unisys/visorbus/visorchannel.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
> index cae62fed..da7bd9c 100644
> --- a/drivers/staging/unisys/visorbus/visorchannel.c
> +++ b/drivers/staging/unisys/visorbus/visorchannel.c
> @@ -213,13 +213,16 @@ int
>  visorchannel_write(struct visorchannel *channel, ulong offset,
>  		   void *local, ulong nbytes)
>  {
> -	size_t size = sizeof(struct channel_header);
> +	size_t chdr_size = sizeof(struct channel_header);
> +	size_t copy_size;
>  
>  	if (offset + nbytes > channel->memregion.nbytes)
>  		return -EIO;
>  
> -	if (!offset && nbytes >= size)
> -		memcpy(&channel->chan_hdr, local, size);
> +	if (offset < chdr_size) {
> +		copy_size = min(chdr_size, nbytes) - offset;
> +		memcpy(&channel->chan_hdr + offset, local, copy_size);

You get memory corrution if nbytes is less than offset and chdr_size.

My reading was that in the original code this memcpy() was dead code but
I could have been wrong.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes
  2015-05-06 13:46   ` Dan Carpenter
@ 2015-05-06 14:23     ` Jes Sorensen
  2015-05-06 14:28       ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Jes Sorensen @ 2015-05-06 14:23 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Benjamin Romer, gregkh, driverdev-devel, sparmaintainer

Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Tue, May 05, 2015 at 06:36:56PM -0400, Benjamin Romer wrote:
>> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>> 
>> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
>> ---
>>  drivers/staging/unisys/visorbus/visorchannel.c | 9 ++++++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
>> index cae62fed..da7bd9c 100644
>> --- a/drivers/staging/unisys/visorbus/visorchannel.c
>> +++ b/drivers/staging/unisys/visorbus/visorchannel.c
>> @@ -213,13 +213,16 @@ int
>>  visorchannel_write(struct visorchannel *channel, ulong offset,
>>  		   void *local, ulong nbytes)
>>  {
>> -	size_t size = sizeof(struct channel_header);
>> +	size_t chdr_size = sizeof(struct channel_header);
>> +	size_t copy_size;
>>  
>>  	if (offset + nbytes > channel->memregion.nbytes)
>>  		return -EIO;
>>  
>> -	if (!offset && nbytes >= size)
>> -		memcpy(&channel->chan_hdr, local, size);
>> +	if (offset < chdr_size) {
>> +		copy_size = min(chdr_size, nbytes) - offset;
>> +		memcpy(&channel->chan_hdr + offset, local, copy_size);
>
> You get memory corrution if nbytes is less than offset and chdr_size.
>
> My reading was that in the original code this memcpy() was dead code but
> I could have been wrong.

Good point - the call path is not currently used, but we should fix the
check.

I'd prefer to add this in a follow-on patch, if you have no objection?

Cheers,
Jes

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes
  2015-05-06 14:23     ` Jes Sorensen
@ 2015-05-06 14:28       ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 14:28 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: gregkh, Benjamin Romer, driverdev-devel, sparmaintainer

Changing it later is fine.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts()
  2015-05-06 12:15   ` Dan Carpenter
@ 2015-05-06 16:25     ` Ben Romer
  2015-05-06 17:01       ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Ben Romer @ 2015-05-06 16:25 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, Prarit Bhargava, driverdev-devel, sparmaintainer

On 05/06/2015 08:15 AM, Dan Carpenter wrote:
> Also there were some unrelated changes.  Benjamin, you should have
> complained about those when the patch was first sent.  That's like the
> most obvious thing to check when you're reviewing patches.

I'm sorry, I don't understand what part of this is unrelated? To me it 
looked like Prarit was refactoring the function and its subroutines, 
mostly the error handling but also cleanup. I've sent similar patches in 
the past that were refactoring patches, and the patch does what it says 
in the description, so I thought it was okay.

-- Ben

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts()
  2015-05-06 16:25     ` Ben Romer
@ 2015-05-06 17:01       ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-06 17:01 UTC (permalink / raw)
  To: Ben Romer; +Cc: Prarit Bhargava, gregkh, sparmaintainer, driverdev-devel

On Wed, May 06, 2015 at 12:25:43PM -0400, Ben Romer wrote:
> On 05/06/2015 08:15 AM, Dan Carpenter wrote:
> >Also there were some unrelated changes.  Benjamin, you should have
> >complained about those when the patch was first sent.  That's like the
> >most obvious thing to check when you're reviewing patches.
> 
> I'm sorry, I don't understand what part of this is unrelated? To me
> it looked like Prarit was refactoring the function and its
> subroutines, mostly the error handling but also cleanup. I've sent
> similar patches in the past that were refactoring patches, and the
> patch does what it says in the description, so I thought it was
> okay.

Fine fine.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-05 22:37 ` [PATCH 126/141] staging: unisys: Convert the epilog " Benjamin Romer
@ 2015-05-08  8:00   ` Dan Carpenter
  2015-05-08 13:56     ` Don Zickus
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-08  8:00 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, Don Zickus, driverdev-devel, sparmaintainer

On Tue, May 05, 2015 at 06:37:43PM -0400, Benjamin Romer wrote:
> From: Don Zickus <dzickus@redhat.com>
> @@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
>  		switch (cmd) {
>  		case CONTROLVM_DEVICE_CREATE:
>  			if (notifiers->device_create) {
> -				(*notifiers->device_create) (bus_no, dev_no);
> +				(*notifiers->device_create) (dev_info);
>  				notified = true;
>  			}
>  			break;

This doesn't work.  We don't change the (*notifiers->device_create)
function pointer until the next patch.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-05 22:37 ` [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device Benjamin Romer
@ 2015-05-08  8:34   ` Dan Carpenter
  2015-05-08 13:07     ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-08  8:34 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:37:51PM -0400, Benjamin Romer wrote:
> From: Don Zickus <dzickus@redhat.com>
> @@ -1230,8 +1231,16 @@ create_bus_instance(struct visor_device *vdev)
>  {
>  	int rc;
>  	u32 id = vdev->chipset_bus_no;
> +	struct spar_vbus_headerinfo *hdr_info;
>  
>  	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
> +
> +	hdr_info = kzalloc(sizeof(struct spar_vbus_headerinfo), GFP_KERNEL);
> +	if (!hdr_info) {
> +		rc = -ENOMEM;
> +		goto away;
> +	}
> +	vdev->vbus_hdr_info = (void *)hdr_info;
>  	dev_set_name(&vdev->device, "visorbus%d", id);
>  	vdev->device.bus = &visorbus_type;
>  	vdev->device.groups = visorbus_groups;

This function leaks hdr_info on later error paths.

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h
  2015-05-05 22:37 ` [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h Benjamin Romer
@ 2015-05-08  8:46   ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-08  8:46 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:37:56PM -0400, Benjamin Romer wrote:
> @@ -827,14 +818,6 @@ controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
>  	struct controlvm_message outmsg;
>  
>  	controlvm_init_response(&outmsg, msg_hdr, response);
> -	/* For DiagPool channel DEVICE_CHANGESTATE, we need to send
> -	* back the deviceChangeState structure in the packet. */
> -	if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
> -	    g_devicechangestate_packet.device_change_state.bus_no ==
> -	    g_diagpool_bus_no &&
> -	    g_devicechangestate_packet.device_change_state.dev_no ==
> -	    g_diagpool_dev_no)
> -		outmsg.cmd = g_devicechangestate_packet;
>  	if (outmsg.hdr.flags.test_message == 1)
>  		return;
>  

This is a puzzling chunk it doesn't seem to have anything to do with the
commit message.  The previous had an incomplete commit message as well.

Anyway, g_devicechangestate_packet is a write only variable now so we
can remove it?

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 000/141] staging: unisys: s-Par driver rebuild series
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (140 preceding siblings ...)
  2015-05-05 22:37 ` [PATCH 141/141] staging: unisys: Get rid of unused function Benjamin Romer
@ 2015-05-08  8:52 ` Dan Carpenter
  2015-05-08 13:32   ` Ben Romer
  2015-05-08 13:32 ` Greg KH
  2015-05-09  9:09 ` Dan Carpenter
  143 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-08  8:52 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, driverdev-devel, sparmaintainer

I'm finished going through these patches.  Pretty decent over all.

My only comment was that there were three? places where we introduced a
bug and then fixed it in a later patch.  I kind of wish the fix were
folded into the original patch.  I don't know how awkward that is.  If
it's too difficult then don't worry about it.

I also missed all three of those bugs so my review obviously wasn't
perfect.  :P

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-08  8:34   ` Dan Carpenter
@ 2015-05-08 13:07     ` Dan Carpenter
  2015-05-09  9:19       ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-08 13:07 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Fri, May 08, 2015 at 11:34:57AM +0300, Dan Carpenter wrote:
> On Tue, May 05, 2015 at 06:37:51PM -0400, Benjamin Romer wrote:
> > From: Don Zickus <dzickus@redhat.com>
> > @@ -1230,8 +1231,16 @@ create_bus_instance(struct visor_device *vdev)
> >  {
> >  	int rc;
> >  	u32 id = vdev->chipset_bus_no;
> > +	struct spar_vbus_headerinfo *hdr_info;
> >  
> >  	POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
> > +
> > +	hdr_info = kzalloc(sizeof(struct spar_vbus_headerinfo), GFP_KERNEL);
> > +	if (!hdr_info) {
> > +		rc = -ENOMEM;
> > +		goto away;
> > +	}
> > +	vdev->vbus_hdr_info = (void *)hdr_info;
> >  	dev_set_name(&vdev->device, "visorbus%d", id);
> >  	vdev->device.bus = &visorbus_type;
> >  	vdev->device.groups = visorbus_groups;
> 
> This function leaks hdr_info on later error paths.

Never mind.  I'm wrong.  Sorry for the noise.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 000/141] staging: unisys: s-Par driver rebuild series
  2015-05-08  8:52 ` [PATCH 000/141] staging: unisys: s-Par driver rebuild series Dan Carpenter
@ 2015-05-08 13:32   ` Ben Romer
  0 siblings, 0 replies; 173+ messages in thread
From: Ben Romer @ 2015-05-08 13:32 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, driverdev-devel, sparmaintainer

On 05/08/2015 04:52 AM, Dan Carpenter wrote:
> I'm finished going through these patches.  Pretty decent over all.
>
> My only comment was that there were three? places where we introduced a
> bug and then fixed it in a later patch.  I kind of wish the fix were
> folded into the original patch.  I don't know how awkward that is.  If
> it's too difficult then don't worry about it.

It seems that Greg is merging most (if not all) of the patchset into 
staging-testing now, so it'd be more trouble to generate a v2 than it's 
worth, but we are going to make sure we take care of all of the flaws 
you've pointed out. :)

> I also missed all three of those bugs so my review obviously wasn't
> perfect.  :P

The feedback was very valuable to us! :) Thanks for taking the time to 
go over everything. I'm hoping that we'll have patches sent in by next 
week, for each of the mistakes of ours that you found. :)

Thanks again! :)

-- Ben

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 000/141] staging: unisys: s-Par driver rebuild series
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (141 preceding siblings ...)
  2015-05-08  8:52 ` [PATCH 000/141] staging: unisys: s-Par driver rebuild series Dan Carpenter
@ 2015-05-08 13:32 ` Greg KH
  2015-05-09  9:09 ` Dan Carpenter
  143 siblings, 0 replies; 173+ messages in thread
From: Greg KH @ 2015-05-08 13:32 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: jkc, driverdev-devel, sparmaintainer

On Tue, May 05, 2015 at 06:35:37PM -0400, Benjamin Romer wrote:
> This series of patches contains a complete overhaul of the s-Par driver tree,
> introducing a new (and significantly improved) driver called visorbus.
> This new module consolidates the support code from the many other
> modules that existed in our tree, allowing us to remove those, and makes
> much better use of built in kernel functionality. The driver tree is
> flattened out and large amounts of old code are pruned away, and the ability
> to automatically load the driver based on ACPI table data is added.

I took the first 100 patches here, but there's a build breakage in the
remaining patches, and I didn't want to take the time to bisect to find
it (different from the one that Dan found).

Please always test build each patch, you can not add warnings (like you
all do in some patches) or break the build (like you do in some patches)
at any point in the series.  You all know better than this.

greg k-h

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-08  8:00   ` Dan Carpenter
@ 2015-05-08 13:56     ` Don Zickus
  2015-05-08 14:02       ` Greg KH
  0 siblings, 1 reply; 173+ messages in thread
From: Don Zickus @ 2015-05-08 13:56 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Benjamin Romer, gregkh, driverdev-devel, sparmaintainer

On Fri, May 08, 2015 at 11:00:18AM +0300, Dan Carpenter wrote:
> On Tue, May 05, 2015 at 06:37:43PM -0400, Benjamin Romer wrote:
> > From: Don Zickus <dzickus@redhat.com>
> > @@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
> >  		switch (cmd) {
> >  		case CONTROLVM_DEVICE_CREATE:
> >  			if (notifiers->device_create) {
> > -				(*notifiers->device_create) (bus_no, dev_no);
> > +				(*notifiers->device_create) (dev_info);
> >  				notified = true;
> >  			}
> >  			break;
> 
> This doesn't work.  We don't change the (*notifiers->device_create)
> function pointer until the next patch.

Correct.  The changes were so intertwined that I could either post a giant
monolithic patch and maintain bisectability or break things into smaller
chunks for review purpose but lose the ability to bisect.

I chose the later.  The weak argument we used is that no one will enable
this driver (except unisys) so it normally won't break bisecting by others.

This patch was part of a 5-6 part patch series that changed things in waves
as I went through the driver stack.  The first wave was the direct interface
with the S-PAR.  The second wave (this patch) modified the functions called
by the first wave, etc, etc.

Let me know what a better way to present this would be.

Cheers,
Don

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-08 13:56     ` Don Zickus
@ 2015-05-08 14:02       ` Greg KH
  2015-05-08 16:06         ` Don Zickus
  0 siblings, 1 reply; 173+ messages in thread
From: Greg KH @ 2015-05-08 14:02 UTC (permalink / raw)
  To: Don Zickus; +Cc: Dan Carpenter, Benjamin Romer, driverdev-devel, sparmaintainer

On Fri, May 08, 2015 at 09:56:41AM -0400, Don Zickus wrote:
> On Fri, May 08, 2015 at 11:00:18AM +0300, Dan Carpenter wrote:
> > On Tue, May 05, 2015 at 06:37:43PM -0400, Benjamin Romer wrote:
> > > From: Don Zickus <dzickus@redhat.com>
> > > @@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
> > >  		switch (cmd) {
> > >  		case CONTROLVM_DEVICE_CREATE:
> > >  			if (notifiers->device_create) {
> > > -				(*notifiers->device_create) (bus_no, dev_no);
> > > +				(*notifiers->device_create) (dev_info);
> > >  				notified = true;
> > >  			}
> > >  			break;
> > 
> > This doesn't work.  We don't change the (*notifiers->device_create)
> > function pointer until the next patch.
> 
> Correct.  The changes were so intertwined that I could either post a giant
> monolithic patch and maintain bisectability or break things into smaller
> chunks for review purpose but lose the ability to bisect.
> 
> I chose the later.  The weak argument we used is that no one will enable
> this driver (except unisys) so it normally won't break bisecting by others.

Sorry, but no, you can't break the build at any point in any patch.

greg k-h

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-08 14:02       ` Greg KH
@ 2015-05-08 16:06         ` Don Zickus
  2015-05-08 16:44           ` Greg KH
  0 siblings, 1 reply; 173+ messages in thread
From: Don Zickus @ 2015-05-08 16:06 UTC (permalink / raw)
  To: Greg KH; +Cc: Dan Carpenter, Benjamin Romer, driverdev-devel, sparmaintainer

On Fri, May 08, 2015 at 04:02:06PM +0200, Greg KH wrote:
> On Fri, May 08, 2015 at 09:56:41AM -0400, Don Zickus wrote:
> > On Fri, May 08, 2015 at 11:00:18AM +0300, Dan Carpenter wrote:
> > > On Tue, May 05, 2015 at 06:37:43PM -0400, Benjamin Romer wrote:
> > > > From: Don Zickus <dzickus@redhat.com>
> > > > @@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
> > > >  		switch (cmd) {
> > > >  		case CONTROLVM_DEVICE_CREATE:
> > > >  			if (notifiers->device_create) {
> > > > -				(*notifiers->device_create) (bus_no, dev_no);
> > > > +				(*notifiers->device_create) (dev_info);
> > > >  				notified = true;
> > > >  			}
> > > >  			break;
> > > 
> > > This doesn't work.  We don't change the (*notifiers->device_create)
> > > function pointer until the next patch.
> > 
> > Correct.  The changes were so intertwined that I could either post a giant
> > monolithic patch and maintain bisectability or break things into smaller
> > chunks for review purpose but lose the ability to bisect.
> > 
> > I chose the later.  The weak argument we used is that no one will enable
> > this driver (except unisys) so it normally won't break bisecting by others.
> 
> Sorry, but no, you can't break the build at any point in any patch.

Alright, then I will ask Ben to fold the 5 patches together. :-(

Cheers,
Don

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 126/141] staging: unisys: Convert the epilog functions to visor_device
  2015-05-08 16:06         ` Don Zickus
@ 2015-05-08 16:44           ` Greg KH
  0 siblings, 0 replies; 173+ messages in thread
From: Greg KH @ 2015-05-08 16:44 UTC (permalink / raw)
  To: Don Zickus; +Cc: Dan Carpenter, Benjamin Romer, driverdev-devel, sparmaintainer

On Fri, May 08, 2015 at 12:06:37PM -0400, Don Zickus wrote:
> On Fri, May 08, 2015 at 04:02:06PM +0200, Greg KH wrote:
> > On Fri, May 08, 2015 at 09:56:41AM -0400, Don Zickus wrote:
> > > On Fri, May 08, 2015 at 11:00:18AM +0300, Dan Carpenter wrote:
> > > > On Tue, May 05, 2015 at 06:37:43PM -0400, Benjamin Romer wrote:
> > > > > From: Don Zickus <dzickus@redhat.com>
> > > > > @@ -1128,7 +1119,7 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
> > > > >  		switch (cmd) {
> > > > >  		case CONTROLVM_DEVICE_CREATE:
> > > > >  			if (notifiers->device_create) {
> > > > > -				(*notifiers->device_create) (bus_no, dev_no);
> > > > > +				(*notifiers->device_create) (dev_info);
> > > > >  				notified = true;
> > > > >  			}
> > > > >  			break;
> > > > 
> > > > This doesn't work.  We don't change the (*notifiers->device_create)
> > > > function pointer until the next patch.
> > > 
> > > Correct.  The changes were so intertwined that I could either post a giant
> > > monolithic patch and maintain bisectability or break things into smaller
> > > chunks for review purpose but lose the ability to bisect.
> > > 
> > > I chose the later.  The weak argument we used is that no one will enable
> > > this driver (except unisys) so it normally won't break bisecting by others.
> > 
> > Sorry, but no, you can't break the build at any point in any patch.
> 
> Alright, then I will ask Ben to fold the 5 patches together. :-(

How about reworking them in a different way?  There's lots of ways to
evolve code that doesn't require folding things all together.

Yes, it takes more work, but it makes reviewing stuff easier, which is
the most important thing here.

greg k-h

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 030/141] staging: unisys: unify devmajorminor attributes into visorbus_main.c
  2015-05-05 22:36 ` [PATCH 030/141] staging: unisys: unify devmajorminor " Benjamin Romer
@ 2015-05-09  8:37   ` Dan Carpenter
  0 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  8:37 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Prarit Bhargava, gregkh, sparmaintainer, driverdev-devel

On Tue, May 05, 2015 at 06:36:07PM -0400, Benjamin Romer wrote:
> -void
> -devmajorminor_remove_file(struct visor_device *dev, int slot)
> -{
> -	int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
> -	struct devmajorminor_attribute *myattr = NULL;
> -
> -	if (slot < 0 || slot >= maxdevnodes)
> -		return;
> -	myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
> -	if (myattr)
> -		return;

You didn't introduce it, but this condition seems reversed.

> -	sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
> -	kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
> -	dev->devnodes[slot].attr = NULL;
> -	kfree(myattr);
> -}


regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 023/141] staging: unisys: add visorbus driver
  2015-05-05 22:36 ` [PATCH 023/141] staging: unisys: add visorbus driver Benjamin Romer
  2015-05-06  9:41   ` Dan Carpenter
@ 2015-05-09  8:59   ` Dan Carpenter
  1 sibling, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  8:59 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, sparmaintainer, driverdev-devel, Erik Arfvidson

On Tue, May 05, 2015 at 06:36:00PM -0400, Benjamin Romer wrote:
> +/** This is called automatically upon adding a visor_device (device_add), or
> + *  adding a visor_driver (visorbus_register_visor_driver), but only after
> + *  visorbus_match has returned 1 to indicate a successful match between
> + *  driver and device.
> + */
> +static int
> +visordriver_probe_device(struct device *xdev)
> +{
> +	int rc;
> +	struct visor_driver *drv;
> +	struct visor_device *dev;
> +
> +	drv = to_visor_driver(xdev->driver);
> +	dev = to_visor_device(xdev);
> +	down(&dev->visordriver_callback_lock);
> +	dev->being_removed = FALSE;
> +	/*
> +	 * ensure that the dev->being_removed flag is cleared before
> +	 * we start the probe
> +	 */
> +	wmb();
> +	get_device(&dev->device);
> +	if (!drv->probe) {
> +		up(&dev->visordriver_callback_lock);
> +		rc = -1;
> +		goto away;
> +	}
> +	rc = drv->probe(dev);
> +	if (rc < 0)
> +		goto away;
> +
> +	fix_vbus_dev_info(dev);
> +	up(&dev->visordriver_callback_lock);
> +	rc = 0;
> +away:
> +	if (rc != 0)
> +		put_device(&dev->device);
> +	/*  We could get here more than once if the child driver module is
> +	 *  unloaded and re-loaded while devices are present.  That's why we
> +	 *  need a flag to be sure that we only respond to the device_create
> +	 *  once.  We cannot respond to the device_create prior to here,
> +	 *  because until we call drv->probe() above, the channel has not been
> +	 *  initialized.
> +	 */
> +	if (!dev->responded_to_device_create) {
> +		dev->responded_to_device_create = TRUE;
> +		if (chipset_responders.device_create)
> +			(*chipset_responders.device_create)(dev->chipset_bus_no,
> +							    dev->chipset_dev_no,
> +							    rc);
> +	}
> +	return rc;
> +}

The error handling in this function looks kind of weird.  Also if
drv->probe() fails then we need to unlock.  One err bug.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device
  2015-05-05 22:37 ` [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device Benjamin Romer
@ 2015-05-09  9:01   ` Dan Carpenter
  2015-05-09  9:05     ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:01 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, Don Zickus, driverdev-devel, sparmaintainer

On Tue, May 05, 2015 at 06:37:42PM -0400, Benjamin Romer wrote:
> From: Don Zickus <dzickus@redhat.com>
>  
>  cleanup:
> -	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> +	bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
>  		   rc, inmsg->hdr.flags.response_expected == 1);
>  }

On some error paths "bus_info" is NULL.  One err bug.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device
  2015-05-09  9:01   ` Dan Carpenter
@ 2015-05-09  9:05     ` Dan Carpenter
  2015-05-09  9:06       ` Dan Carpenter
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:05 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Sat, May 09, 2015 at 12:01:54PM +0300, Dan Carpenter wrote:
> On Tue, May 05, 2015 at 06:37:42PM -0400, Benjamin Romer wrote:
> > From: Don Zickus <dzickus@redhat.com>
> >  
> >  cleanup:
> > -	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> > +	bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> >  		   rc, inmsg->hdr.flags.response_expected == 1);
> >  }
> 
> On some error paths "bus_info" is NULL.  One err bug.

Ugh...  Basically ever place that calls bus_epilog() is buggy.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device
  2015-05-09  9:05     ` Dan Carpenter
@ 2015-05-09  9:06       ` Dan Carpenter
  2015-05-11 14:07         ` Don Zickus
  0 siblings, 1 reply; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:06 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Sat, May 09, 2015 at 12:05:19PM +0300, Dan Carpenter wrote:
> On Sat, May 09, 2015 at 12:01:54PM +0300, Dan Carpenter wrote:
> > On Tue, May 05, 2015 at 06:37:42PM -0400, Benjamin Romer wrote:
> > > From: Don Zickus <dzickus@redhat.com>
> > >  
> > >  cleanup:
> > > -	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> > > +	bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> > >  		   rc, inmsg->hdr.flags.response_expected == 1);
> > >  }
> > 
> > On some error paths "bus_info" is NULL.  One err bug.
> 
> Ugh...  Basically ever place that calls bus_epilog() is buggy.

Or device_epilog().

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 000/141] staging: unisys: s-Par driver rebuild series
  2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
                   ` (142 preceding siblings ...)
  2015-05-08 13:32 ` Greg KH
@ 2015-05-09  9:09 ` Dan Carpenter
  143 siblings, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:09 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: gregkh, driverdev-devel, sparmaintainer

You should send your git tree to Fengguang Wu so he can add it to
kbuild.  It would have found the compile warnings and most of the static
checker issues.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-08 13:07     ` Dan Carpenter
@ 2015-05-09  9:19       ` Dan Carpenter
  2015-05-09  9:24         ` Dan Carpenter
  2015-05-11 14:27         ` Don Zickus
  0 siblings, 2 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:19 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Fri, May 08, 2015 at 04:07:03PM +0300, Dan Carpenter wrote:
> > 
> > This function leaks hdr_info on later error paths.
> 
> Never mind.  I'm wrong.  Sorry for the noise.
> 

To be honest, I think I was right originally, but the code is such a
twisty call path that it's hard to tell.

Of course, what I would prefer is to never return half allocated
structs.  Just leave the "vdev->vbus_hdr_info = (void *)hdr_info;" until
we are ready to return success and kfree() it on the error paths.

That way the question "does this leak" is easy to answer.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-09  9:19       ` Dan Carpenter
@ 2015-05-09  9:24         ` Dan Carpenter
  2015-05-11 14:27         ` Don Zickus
  1 sibling, 0 replies; 173+ messages in thread
From: Dan Carpenter @ 2015-05-09  9:24 UTC (permalink / raw)
  To: Benjamin Romer; +Cc: Don Zickus, gregkh, sparmaintainer, driverdev-devel

On Sat, May 09, 2015 at 12:19:28PM +0300, Dan Carpenter wrote:
> On Fri, May 08, 2015 at 04:07:03PM +0300, Dan Carpenter wrote:
> > > 
> > > This function leaks hdr_info on later error paths.
> > 
> > Never mind.  I'm wrong.  Sorry for the noise.
> > 
> 
> To be honest, I think I was right originally, but the code is such a
> twisty call path that it's hard to tell.

How the error handling work is that the lower levels calls:

POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_SEVERITY_ERR);

POSTCODE_LINUX_3() has no documentation to speak of...

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device
  2015-05-09  9:06       ` Dan Carpenter
@ 2015-05-11 14:07         ` Don Zickus
  0 siblings, 0 replies; 173+ messages in thread
From: Don Zickus @ 2015-05-11 14:07 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Benjamin Romer, gregkh, driverdev-devel, sparmaintainer

On Sat, May 09, 2015 at 12:06:32PM +0300, Dan Carpenter wrote:
> On Sat, May 09, 2015 at 12:05:19PM +0300, Dan Carpenter wrote:
> > On Sat, May 09, 2015 at 12:01:54PM +0300, Dan Carpenter wrote:
> > > On Tue, May 05, 2015 at 06:37:42PM -0400, Benjamin Romer wrote:
> > > > From: Don Zickus <dzickus@redhat.com>
> > > >  
> > > >  cleanup:
> > > > -	bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> > > > +	bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
> > > >  		   rc, inmsg->hdr.flags.response_expected == 1);
> > > >  }
> > > 
> > > On some error paths "bus_info" is NULL.  One err bug.
> > 
> > Ugh...  Basically ever place that calls bus_epilog() is buggy.
> 
> Or device_epilog().

Agree 100%. :-)  I have a patch in Ben's queue to re-work the failure paths.

I have to rework my patches anyway to address Greg's request.  I will see if
I can get Ben to include those patches too to address this when we repost.

Cheers,
Don

^ permalink raw reply	[flat|nested] 173+ messages in thread

* Re: [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device
  2015-05-09  9:19       ` Dan Carpenter
  2015-05-09  9:24         ` Dan Carpenter
@ 2015-05-11 14:27         ` Don Zickus
  1 sibling, 0 replies; 173+ messages in thread
From: Don Zickus @ 2015-05-11 14:27 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Benjamin Romer, gregkh, sparmaintainer, driverdev-devel

On Sat, May 09, 2015 at 12:19:28PM +0300, Dan Carpenter wrote:
> On Fri, May 08, 2015 at 04:07:03PM +0300, Dan Carpenter wrote:
> > > 
> > > This function leaks hdr_info on later error paths.
> > 
> > Never mind.  I'm wrong.  Sorry for the noise.
> > 
> 
> To be honest, I think I was right originally, but the code is such a
> twisty call path that it's hard to tell.
> 
> Of course, what I would prefer is to never return half allocated
> structs.  Just leave the "vdev->vbus_hdr_info = (void *)hdr_info;" until
> we are ready to return success and kfree() it on the error paths.

I agree.  My patches caused a lot of churn in the code.  This patch was to
address one of those fallout problems when trying to get things working
again.  The error paths are still twisty and we haven't quite unraveled them
yet.

My initial thoughts were that all failures still sent a response to the
S-PAR.  This means the kfree happened in bus_responder or device_responder.

However, looking through the code again, it doesn't always happen that way.

I have to check with Unisys to understand why some responses are dropped
while others are reported back to the S-PAR.


There is still some simplification that needs to happen to make this code
easier to read. :-(

Thanks for the review.

Cheers,
Don

^ permalink raw reply	[flat|nested] 173+ messages in thread

end of thread, other threads:[~2015-05-11 14:27 UTC | newest]

Thread overview: 173+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05 22:35 [PATCH 000/141] staging: unisys: s-Par driver rebuild series Benjamin Romer
2015-05-05 22:35 ` [PATCH 001/141] staging: unisys: Move module parameters around and mark static Benjamin Romer
2015-05-05 22:35 ` [PATCH 002/141] staging: unisys: Move MYDRVNAME to visorchipset.h Benjamin Romer
2015-05-05 22:35 ` [PATCH 003/141] staging: unisys: Eliminate globals.h Benjamin Romer
2015-05-05 22:35 ` [PATCH 004/141] staging: unisys: Fix up a few cases of bad formatting Benjamin Romer
2015-05-05 22:35 ` [PATCH 005/141] staging: unisys: Remove some unnecessary parenthesis Benjamin Romer
2015-05-05 22:35 ` [PATCH 006/141] staging: unisys: Remove unncessary parenthesis Benjamin Romer
2015-05-05 22:35 ` [PATCH 007/141] staging: unisys: Don't zero struct elements which will be memset away Benjamin Romer
2015-05-05 22:35 ` [PATCH 008/141] staging: unisys: Do not initialize variables unnecessarily Benjamin Romer
2015-05-05 22:35 ` [PATCH 009/141] staging: unisys: Get rid of uint usage Benjamin Romer
2015-05-05 22:35 ` [PATCH 010/141] staging: unisys: Remove unused cache object counter Benjamin Romer
2015-05-05 22:35 ` [PATCH 011/141] staging: unisys: Don't include timskmod.h Benjamin Romer
2015-05-05 22:35 ` [PATCH 012/141] staging: unisys: Remove a couple of unnecessary blank lines Benjamin Romer
2015-05-05 22:35 ` [PATCH 013/141] staging: unisys: buffer_list_pool isn't used for anything Benjamin Romer
2015-05-05 22:35 ` [PATCH 014/141] staging: unisys: Remove write-only visorchipset_bus_info.dev_no Benjamin Romer
2015-05-05 22:35 ` [PATCH 015/141] staging: unisys: findbus() doesn't need to be inline Benjamin Romer
2015-05-05 22:35 ` [PATCH 016/141] staging: unisys: Remove unused typedef SPARREPORTEVENT_COMPLETE_FUNC Benjamin Romer
2015-05-05 22:35 ` [PATCH 017/141] staging: unisys: finddevice() doesn't need to be inline Benjamin Romer
2015-05-05 22:35 ` [PATCH 018/141] staging: unisys: delbusdevices() " Benjamin Romer
2015-05-05 22:35 ` [PATCH 019/141] staging: unisys: Avoid some == 0 checks Benjamin Romer
2015-05-05 22:35 ` [PATCH 020/141] staging: unisys: No point in checking != 0 Benjamin Romer
2015-05-05 22:35 ` [PATCH 021/141] staging: unisys: Remove write-only variable g_diag_msg_hdr Benjamin Romer
2015-05-05 22:35 ` [PATCH 022/141] staging: unisys: Remove write-only variable g_del_dump_msg_hdr Benjamin Romer
2015-05-05 22:36 ` [PATCH 023/141] staging: unisys: add visorbus driver Benjamin Romer
2015-05-06  9:41   ` Dan Carpenter
2015-05-09  8:59   ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 024/141] staging: unisys: Move visorchannel into visorbus Benjamin Romer
2015-05-06 10:00   ` Dan Carpenter
2015-05-06 10:05     ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 025/141] staging: unisys: Dissolve visorchannel.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 026/141] staging: unisys: Move visorbus.h to public namespace Benjamin Romer
2015-05-05 22:36 ` [PATCH 027/141] staging: unisys: Remove unused driver Benjamin Romer
2015-05-05 22:36 ` [PATCH 028/141] staging: unisys: unify businst attributes into visorbus_main.c Benjamin Romer
2015-05-05 22:36 ` [PATCH 029/141] staging: unisys: unify channel " Benjamin Romer
2015-05-05 22:36 ` [PATCH 030/141] staging: unisys: unify devmajorminor " Benjamin Romer
2015-05-09  8:37   ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 031/141] staging: unisys: rename visorchannel_funcs.c to visorchannel.c Benjamin Romer
2015-05-05 22:36 ` [PATCH 032/141] staging: unisys: remove globals.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 033/141] staging: unisys: remove visorbus_private.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 034/141] staging: unisys: remove visorchipset_umode.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 035/141] staging: unisys: moving file.h functionality to visorchipset.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 036/141] staging: unisys: remove file.c and pass functionality to visorchipset Benjamin Romer
2015-05-05 22:36 ` [PATCH 037/141] staging: unisys: move parser.[ch] functionality into visorchipset Benjamin Romer
2015-05-05 22:36 ` [PATCH 038/141] staging: unisys: move visorchipset files to visorbus Benjamin Romer
2015-05-05 22:36 ` [PATCH 039/141] staging: unisys: cleanup visorbus_private.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 040/141] staging: unisys: visorchannel cleanup visorchannel_create_guts() Benjamin Romer
2015-05-06 12:15   ` Dan Carpenter
2015-05-06 16:25     ` Ben Romer
2015-05-06 17:01       ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 041/141] staging: unisys: visorchannel some general function cleanups Benjamin Romer
2015-05-06 12:56   ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 042/141] staging: unisys: fix sig_read_data and sig_read_data functions Benjamin Romer
2015-05-05 22:36 ` [PATCH 043/141] staging: unisys: visorchannel: visorchannel_create_overlap() is never used Benjamin Romer
2015-05-05 22:36 ` [PATCH 044/141] staging: unisys: visorbus: visorchannel_create_guts() always has parent == NULL Benjamin Romer
2015-05-05 22:36 ` [PATCH 045/141] staging: unisys: memregion: Nothing uses overlap allocations, so nuke it Benjamin Romer
2015-05-05 22:36 ` [PATCH 046/141] staging: unisys: memregion: Use proper errno for mapit() Benjamin Romer
2015-05-05 22:36 ` [PATCH 047/141] staging: unisys: memregion: Eliminate unnecessary 'requested' flag Benjamin Romer
2015-05-05 22:36 ` [PATCH 048/141] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage Benjamin Romer
2015-05-05 22:36 ` [PATCH 049/141] staging: unisys: visorchipset: Use ioremap direction rather than heavy visor_memregion Benjamin Romer
2015-05-05 22:36 ` [PATCH 050/141] staging: unisys: visorchipset.c: No need to include memregion.h anymore Benjamin Romer
2015-05-05 22:36 ` [PATCH 051/141] staging: unisys: visorchannel_clear(): Avoid 64KB memory leak Benjamin Romer
2015-05-05 22:36 ` [PATCH 052/141] staging: unisys: visorchannel_clear(): No need to use vmalloc here Benjamin Romer
2015-05-05 22:36 ` [PATCH 053/141] staging: unisys: decouple visor_memregion_{read, write}() Benjamin Romer
2015-05-05 22:36 ` [PATCH 054/141] staging: unisys: memregion: move struct memregion to memregion.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 055/141] staging: unisys: memregion: Embed memregion in struct channel Benjamin Romer
2015-05-05 22:36 ` [PATCH 056/141] staging: unisys: visorchannel_get_memregion() isn't used Benjamin Romer
2015-05-05 22:36 ` [PATCH 057/141] staging: unisys: Eliminate unused visorchannel_dump_section() Benjamin Romer
2015-05-05 22:36 ` [PATCH 058/141] staging: unisys: remove typedef GUEST_PHYSICAL_ADDRESS to u64 Benjamin Romer
2015-05-05 22:36 ` [PATCH 059/141] staging: unisys: remove unused enum from controlvmchannel.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 060/141] staging: unisys: remove unused #define in controlvmchannel Benjamin Romer
2015-05-05 22:36 ` [PATCH 061/141] staging: unisys: remove unused #define MAX_SERIAL_NUM Benjamin Romer
2015-05-05 22:36 ` [PATCH 062/141] staging: unisys: remove server crust from visorchipset Benjamin Romer
2015-05-05 22:36 ` [PATCH 063/141] staging: unisys: remove unused CONTROL_VM messages from enum Benjamin Romer
2015-05-05 22:36 ` [PATCH 064/141] staging: unisys: rename variable to reserverd since it is unused Benjamin Romer
2015-05-05 22:36 ` [PATCH 065/141] staging: unisys: controlvmchannel.h comment aligment and cleanup Benjamin Romer
2015-05-05 22:36 ` [PATCH 066/141] staging: unisys: remove unused device_map and guest_devices struct Benjamin Romer
2015-05-05 22:36 ` [PATCH 067/141] staging: unisys: remove unused CONTROLVM_CHIPSET_SHUTDOWN Benjamin Romer
2015-05-05 22:36 ` [PATCH 068/141] staging: unisys: remove unused chipset feature PCIVBUS Benjamin Romer
2015-05-05 22:36 ` [PATCH 069/141] staging: unisys: remove unused #define in iochannel.h Benjamin Romer
2015-05-05 22:36 ` [PATCH 070/141] staging: unisys: cleanup and align iochannel.h comments Benjamin Romer
2015-05-05 22:36 ` [PATCH 071/141] staging: unisys: get rid of serialloopbacktest Benjamin Romer
2015-05-05 22:36 ` [PATCH 072/141] staging: unisys: Eliminate visor_memregion_create() Benjamin Romer
2015-05-05 22:36 ` [PATCH 073/141] staging: unisys: memregion: Eliminate visor_memregion_destroy() Benjamin Romer
2015-05-05 22:36 ` [PATCH 074/141] staging: unisys: memregion: Eliminate visor_memregion_resize() Benjamin Romer
2015-05-05 22:36 ` [PATCH 075/141] staging: unisys: memregion: Eliminate visor_memregion_get_*() functions Benjamin Romer
2015-05-05 22:36 ` [PATCH 076/141] staging: unisys: memregion: {un, }mapit() are no longer used Benjamin Romer
2015-05-05 22:36 ` [PATCH 077/141] staging: unisys: visorchannel_write(): Use memcpy_toio() directly Benjamin Romer
2015-05-05 22:36 ` [PATCH 078/141] staging: unisys: visorchannel_read(): Use memcpy_fromio() directly Benjamin Romer
2015-05-05 22:36 ` [PATCH 079/141] staging: unisys: visorchannel_write(): Handle partial channel_header writes Benjamin Romer
2015-05-06 13:46   ` Dan Carpenter
2015-05-06 14:23     ` Jes Sorensen
2015-05-06 14:28       ` Dan Carpenter
2015-05-05 22:36 ` [PATCH 080/141] staging: unisys: visorchannel_create_guts(): Use visorchannel_read() Benjamin Romer
2015-05-05 22:36 ` [PATCH 081/141] staging: unisys: Eliminate visor_memregion_read() Benjamin Romer
2015-05-05 22:36 ` [PATCH 082/141] staging: unisys: Eliminate visor_memregion_write() Benjamin Romer
2015-05-05 22:37 ` [PATCH 083/141] staging: unisys: Finally remove the last remnants of memregion Benjamin Romer
2015-05-05 22:37 ` [PATCH 084/141] staging: unisys: remove BOOL,TRUE,FALSE definitions Benjamin Romer
2015-05-05 22:37 ` [PATCH 085/141] staging: unisys: add acpi pnp driver Benjamin Romer
2015-05-05 22:37 ` [PATCH 086/141] staging: unisys: add ACPI and PCI requirement to Kconfig Benjamin Romer
2015-05-05 22:37 ` [PATCH 087/141] staging: unisys: move timskmod.h functionality Benjamin Romer
2015-05-05 22:37 ` [PATCH 088/141] staging: unisys: remove charqueue.c Benjamin Romer
2015-05-05 22:37 ` [PATCH 089/141] staging: unisys: remove timskmod.h and procobjecttree.h Benjamin Romer
2015-05-05 22:37 ` [PATCH 090/141] staging: unisys: move periodic_work.c into the visorbus directory Benjamin Romer
2015-05-05 22:37 ` [PATCH 091/141] staging: unisys: fix visorbus Kconfig Benjamin Romer
2015-05-05 22:37 ` [PATCH 092/141] staging: unisys: remove visorutil from top level Makefile Benjamin Romer
2015-05-05 22:37 ` [PATCH 093/141] staging: unisys: visorchannel: Make visorchannel_create take a gfp_t Benjamin Romer
2015-05-05 22:37 ` [PATCH 094/141] staging: unisys: visorchipset: Declare parser_init_byte_stream() static Benjamin Romer
2015-05-05 22:37 ` [PATCH 095/141] staging: unisys: parser: Remove unused functions and mark others static Benjamin Romer
2015-05-05 22:37 ` [PATCH 096/141] staging: unisys: parser_init_guts(): standard_payload_header is always false Benjamin Romer
2015-05-05 22:37 ` [PATCH 097/141] staging: unisys: Remove wrapper around parser_init_guts() Benjamin Romer
2015-05-05 22:37 ` [PATCH 098/141] staging: unisys: visorchipset: Remove unused cache allocator Benjamin Romer
2015-05-05 22:37 ` [PATCH 099/141] staging: unisys: uislib.h: Remove unused cache allocation prototypes Benjamin Romer
2015-05-05 22:37 ` [PATCH 100/141] staging: unisys: visorchipset_file_{init, cleanup}(): mark static Benjamin Romer
2015-05-05 22:37 ` [PATCH 101/141] staging: unisys: Remove unused visorchipset_save_message() Benjamin Romer
2015-05-05 22:37 ` [PATCH 102/141] staging: unisys: visorchipset_init(): Simplify initial checks Benjamin Romer
2015-05-05 22:37 ` [PATCH 103/141] staging: unisys: Remove unused livedump_info Benjamin Romer
2015-05-05 22:37 ` [PATCH 104/141] staging: unisys: Remove appos_subsystems.h Benjamin Romer
2015-05-05 22:37 ` [PATCH 105/141] staging: unisys: move hypervisor calls into visorbus Benjamin Romer
2015-05-05 22:37 ` [PATCH 106/141] staging: unisys: Move controlframework into controlvmchannel.h Benjamin Romer
2015-05-05 22:37 ` [PATCH 107/141] staging: unisys: Move channel.h to include. Controvlm to visorbus Benjamin Romer
2015-05-05 22:37 ` [PATCH 108/141] staging: unisys: vbuschannel belonsg " Benjamin Romer
2015-05-05 22:37 ` [PATCH 109/141] staging: unisys: Move diagchannel to include Benjamin Romer
2015-05-05 22:37 ` [PATCH 110/141] staging: unisys: Move files out of common-spar Benjamin Romer
2015-05-05 22:37 ` [PATCH 111/141] staging: unisys: Get rid of references to common-spar Benjamin Romer
2015-05-05 22:37 ` [PATCH 112/141] staging: unisys: get rid of sparstop Benjamin Romer
2015-05-05 22:37 ` [PATCH 113/141] staging: unisys: remove remaining utility headers Benjamin Romer
2015-05-05 22:37 ` [PATCH 114/141] staging: unisys: Embed struct device for easier handling of attr Benjamin Romer
2015-05-05 22:37 ` [PATCH 115/141] staging: unisys: Wire up proper device attr for bus Benjamin Romer
2015-05-05 22:37 ` [PATCH 116/141] staging: unisys: Move the visorbus device underneath devices Benjamin Romer
2015-05-05 22:37 ` [PATCH 117/141] staging: unisys: remove unused bus attribute code Benjamin Romer
2015-05-05 22:37 ` [PATCH 118/141] staging: unisys: Properly move version file into bus attr Benjamin Romer
2015-05-05 22:37 ` [PATCH 119/141] staging: unisys: Remove dead kobj structs Benjamin Romer
2015-05-05 22:37 ` [PATCH 120/141] staging: unisys: Clean up device sysfs attributes Benjamin Romer
2015-05-05 22:37 ` [PATCH 121/141] staging: unisys: Prep for removing 'info' structs Benjamin Romer
2015-05-05 22:37 ` [PATCH 122/141] staging: unisys: Add visor device find routine Benjamin Romer
2015-05-05 22:37 ` [PATCH 123/141] staging: unisys: Add a function to set the clientpartition Benjamin Romer
2015-05-05 22:37 ` [PATCH 124/141] staging: unisys: Add checks for creation Benjamin Romer
2015-05-05 22:37 ` [PATCH 125/141] staging: unisys: Convert cmd functions to visor_device Benjamin Romer
2015-05-09  9:01   ` Dan Carpenter
2015-05-09  9:05     ` Dan Carpenter
2015-05-09  9:06       ` Dan Carpenter
2015-05-11 14:07         ` Don Zickus
2015-05-05 22:37 ` [PATCH 126/141] staging: unisys: Convert the epilog " Benjamin Romer
2015-05-08  8:00   ` Dan Carpenter
2015-05-08 13:56     ` Don Zickus
2015-05-08 14:02       ` Greg KH
2015-05-08 16:06         ` Don Zickus
2015-05-08 16:44           ` Greg KH
2015-05-05 22:37 ` [PATCH 127/141] staging: unisys: Convert the notifier " Benjamin Romer
2015-05-05 22:37 ` [PATCH 128/141] staging: unisys: Convert the bus/device creation " Benjamin Romer
2015-05-05 22:37 ` [PATCH 129/141] staging: unisys: Convert the responders " Benjamin Romer
2015-05-05 22:37 ` [PATCH 130/141] staging: unisys: Convert the device attributes " Benjamin Romer
2015-05-05 22:37 ` [PATCH 131/141] staging: unisys: Convert init/exit routines " Benjamin Romer
2015-05-05 22:37 ` [PATCH 132/141] staging: unisys: Remove dead code leftover from conversion Benjamin Romer
2015-05-05 22:37 ` [PATCH 133/141] staging: unisys: Remove unused intr Benjamin Romer
2015-05-05 22:37 ` [PATCH 134/141] staging: unisys: Hide vbus_hdr_info from public visor_device Benjamin Romer
2015-05-08  8:34   ` Dan Carpenter
2015-05-08 13:07     ` Dan Carpenter
2015-05-09  9:19       ` Dan Carpenter
2015-05-09  9:24         ` Dan Carpenter
2015-05-11 14:27         ` Don Zickus
2015-05-05 22:37 ` [PATCH 135/141] staging: unisys: Include missing headers Benjamin Romer
2015-05-05 22:37 ` [PATCH 136/141] staging: unisys: Removed unused entries from struct visor_channeltype_descriptor Benjamin Romer
2015-05-05 22:37 ` [PATCH 137/141] staging: unisys: Hide contents of pending_msg_hdr Benjamin Romer
2015-05-05 22:37 ` [PATCH 138/141] staging: unisys: Update diag serverity enum Benjamin Romer
2015-05-05 22:37 ` [PATCH 139/141] staging: unisys: Remove unneeded fields in diagchannel.h Benjamin Romer
2015-05-08  8:46   ` Dan Carpenter
2015-05-05 22:37 ` [PATCH 140/141] staging: unisys: Clean up diag_serverity enum Benjamin Romer
2015-05-05 22:37 ` [PATCH 141/141] staging: unisys: Get rid of unused function Benjamin Romer
2015-05-08  8:52 ` [PATCH 000/141] staging: unisys: s-Par driver rebuild series Dan Carpenter
2015-05-08 13:32   ` Ben Romer
2015-05-08 13:32 ` Greg KH
2015-05-09  9:09 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.