UBI: prepare debugging stuff to further debugfs conversion

    We'll need the 'struct ubi_device *ubi' pointer in every debugging function (to
    access the ->dbg field), so add this pointer to all the functions implementing
    UBI debugging test modes like 'ubi_dbg_is_bitflip()' etc.

    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
UBI: make it possible to use struct ubi_device in debug.h

    Current layout does not allow us to add inline functions to debug.h which use
    the 'struct ubi_device' object, because it is undefined there. Move
    '#include "debug.h"' in "ubi.h" down so to make 'struct ubi_device" be defined.
    Additionally, this makes it possible to remove a bunch of forward declarations
    in "debug.h". This is a preparation to the next patch.

    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
UBI: switch debugging tests knobs to debugfs

    Kill the UBI 'debug_tsts' module parameter and switch to debugfs. Create
    per-test mode files there. E.g., to enable bit-flips emulation you may just do:

    echo 1 > /sys/kernel/debug/ubi/ubi0/tst_emulate_bitflips

    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
UBI: fix oops in error path

    This patch fixes an oops in the error path of 'ubi_attach_mtd_dev()'. If
    anything after 'uif_init()' fails, we get an oops in 'cancel_pending()'. The
    reason is that 'uif_close()' drops the last reference count for 'ubi->dev' and
    whole 'struct ubi_device' is freed. And then
    'ubi_wl_close()'->'cancel_pending()' tries to access the 'ubi' pointer and
    problems begin.

    Note, in 'ubi_detach_mtd_dev()' function we get a device reference to
    work-around this issue. Do the same in the error path of
    'ubi_attach_mtd_dev()'.

    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
UBI: dump stack when switching to R/O mode

    If we have debugging enabled and switching to R/O mode because of an error -
    dump the stack to improve UBI error reporting and make the further diagnostics
    easier to do.

    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>