What I've found myself doing in such cases is adding a function that processes multiple commands and indicates an error if any one of the commands failed (sdio_batch could be a varargs function):
struct sdio_cmd {
enum { SDIO_SELECT, SDIO_COMMAND } cmd;
int reg; // Guesses at suitable names without
int val; // knowing anything about SDIO
}
int sdio_batch(int count, ...);
err = sdio_batch(3,
&(struct sdio_cmd){ SDIO_SELECT, .val = rca },
&(struct sdio_cmd){ SDIO_COMMAND, 55, rca << 16 },
&(struct sdio_cmd){ SDIO_COMMAND, 6, 2 },
);
I've been doing it in Ruby with network remote procedure calls, where it's not quite as ugly to use inline lists and variable argument counts as it is in C, and where branch count isn't quite as important.
The sample code I first looked at was doing Goto's to the exit code (deselect/return error) which was unacceptable :-).
What's so bad about a little goto between friends?
The sample code I first looked at was doing Goto's to the exit code (deselect/return error) which was unacceptable :-).
What's so bad about a little goto between friends?