linux_spi.c: Separate shutdown from failed init cleanup

Shutdown function was covering two different jobs here:
1) the actual shutdown which is run at the end of the driver's
lifecycle and 2) cleanup in cases when initialisation failed.
Now, shutdown is only doing its main job (#1), and the driver
itself is doing cleanup when init fails (#2).

The good thing is that now resources are released/closed immediately
in cases when init fails (vs shutdown function which was run at some
point later), and the driver leaves clean space after itself if init fails.

And very importantly this unlocks API change which plans to move
register_shutdown inside register master API, see this


Change-Id: I1c8da2878cd0e85a1e43ba9b4b8e6f3d9f38ae5c
Signed-off-by: Anastasia Klimchuk <>
Tested-by: build bot (Jenkins) <>
Reviewed-by: Edward O'Callaghan <>
1 file changed