opal-gard: Account for ECC size when clearing partition
opal-gard: Account for ECC size when clearing partition

When 'opal-gard clear all' is run, it works by erasing the GUARD then
using blockevel_smart_write() to write nothing to the partition. This
second write call is needed because we rely on libflash to set the ECC
bits appropriately when the partition contained ECCed data.

The API for this is a little odd with the caller specifying how much
actual data to write, and libflash writing size + size/8 bytes
since there is one additional ECC byte for every eight bytes of data.

We currently do not account for the extra space consumed by the ECC data
in reset_partition() which is used to handle the 'clear all' command.
Which results in the paritition following the GUARD partition being
partially overwritten when the command is used. This patch fixes the
problem by reducing the length we would normally write by the number
of ECC bytes required.

Signed-off-by: Oliver O'Halloran <3dfaff8fa6ae977f042064a112a6aac576279b9b@gmail.com>
Tested-by: Joel Stanley <4816dabf8db1bc6cac35b3a24cab2ff844b5b0c7@jms.id.au>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.ibm.com>

stewart-ibm/skiboot,stewart-ibm/skiboot,open-power/skiboot,legoater/skiboot,legoater/skiboot,open-power/skiboot,qemu/skiboot,stewart-ibm/skiboot,qemu/skiboot,shenki/skiboot,shenki/skiboot,shenki/skiboot,open-power/skiboot,legoater/skiboot,shenki/skiboot,open-power/skiboot,open-power/skiboot,legoater/skiboot,qemu/skiboot,shenki/skiboot,legoater/skiboot,qemu/skiboot,qemu/skiboot