By testing the hibernate and migrate sysfs attributes drmgr can determine if a
device tree update is required. If the update is done by the kernel reading
the attribute file will return 1. Otherwise, it should either return 0 or be
unreadable to indicate drmgr needs to update the device tree from userspace.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
The ibm,update-nodes rtas call returns an operation list whose first 4 bytes
are composed of a 1-byte opcode and 3-bytes denoting the number of operands
in the list. For the add nodes case each operand is actually composed of a
phandle/drc-index pair. The current code increments the count while processing
the list for each value instead of each value pair resulting in only half the
returned nodes being added.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
When trying to remove a slot by writing to the sysfs interface
we need to make sure we wait until the add/remove completes. The
write to this file will return EBUSY while the kernel is waiting
for the kernel to complete the work on the slot.

This patch updates the write to the kernel interface file to loop
on EBUSY while waiting for the operation to complete.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
This patch cleans up the naming of the routines/variables used
when writing to the kernel files (via sysfs) that are used in
adding or removing a slot. This is just to (hopefully) make
reading the code easier, there are no functional changes.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
This provides updates to drmgr's zalloc() routine to provide
additional debug information in the case of allocation failures.
The patch also gets rid of the report_alloc_error() routine
that does not really provide any information.

The zalloc() routine is moved from being a static inline in dr.h to
an actual function in common.c with a #define front-end in dr.h
to grab function and line number.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
We can have device tree nodes that do not have any drc information in them.
This patch checks for this condition and handles it appropriately.

Without this fix we get an allocation failure when trying to get the
size of a file that does not exist.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Remove useless instances of setting rc variable.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Initialize the 'state' variable to get rid of a compiler warning.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
The drmgr command incorrectly returns -1 when passed the --capabilities option.
This patch corrects drmgr to properly return zero when passed the
--capabilities flag.

The fix for this involves getting rid of parse_and_validate_options()
so that we can handle cases where we just want to display the capabilites
or usage messages properly.

This issue was introduced by this commit:
http://sourceforge.net/p/powerpc-utils/powerpc-utils/ci/b2fb611e87ebdb27a6b923cf1ac076eb364870b8

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
sys_ident: Add support to recognize Power 8 systems.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>