diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2016-12-19 06:51:18 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2017-02-13 07:19:54 -0500 |
commit | c7836d1593b87cb813c58cf64e08b052ebbe2a78 (patch) | |
tree | e3eb7869a2b2cee2eecca2157213c896184b7630 /drivers/mmc/core/sd_ops.c | |
parent | 164b50b353908c79b551b3658e37f29182e2c0b3 (diff) |
mmc: use empty initializer list to zero-clear structures
In the MMC subsystem, we see such initializers that only clears the
first member explicitly.
For example,
struct mmc_request mrq = {NULL};
sets the first member (.sbc) to NULL explicitly. However, this is
an unstable form because we may insert a non-pointer member at the
top of the struct mmc_request in the future. (if we do so, the
compiler will spit warnings.)
So, using a designated initializer is preferred coding style. The
expression above is equivalent to:
struct mmc_request mrq = { .sbc = NULL };
Of course, this does not express our intention. We want to fill
all struct members with zeros. Please note struct members are
implicitly zero-cleared unless otherwise specified in the initializer.
After all, the most reasonable (and stable) form is:
struct mmc_request mrq = {};
Do likewise for mmc_command, mmc_data as well.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/core/sd_ops.c')
-rw-r--r-- | drivers/mmc/core/sd_ops.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index de125a41aa7a..9d5824a37586 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
@@ -25,7 +25,7 @@ | |||
25 | int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) | 25 | int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) |
26 | { | 26 | { |
27 | int err; | 27 | int err; |
28 | struct mmc_command cmd = {0}; | 28 | struct mmc_command cmd = {}; |
29 | 29 | ||
30 | if (WARN_ON(card && card->host != host)) | 30 | if (WARN_ON(card && card->host != host)) |
31 | return -EINVAL; | 31 | return -EINVAL; |
@@ -68,7 +68,7 @@ EXPORT_SYMBOL_GPL(mmc_app_cmd); | |||
68 | int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, | 68 | int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, |
69 | struct mmc_command *cmd, int retries) | 69 | struct mmc_command *cmd, int retries) |
70 | { | 70 | { |
71 | struct mmc_request mrq = {NULL}; | 71 | struct mmc_request mrq = {}; |
72 | 72 | ||
73 | int i, err; | 73 | int i, err; |
74 | 74 | ||
@@ -120,7 +120,7 @@ EXPORT_SYMBOL(mmc_wait_for_app_cmd); | |||
120 | 120 | ||
121 | int mmc_app_set_bus_width(struct mmc_card *card, int width) | 121 | int mmc_app_set_bus_width(struct mmc_card *card, int width) |
122 | { | 122 | { |
123 | struct mmc_command cmd = {0}; | 123 | struct mmc_command cmd = {}; |
124 | 124 | ||
125 | cmd.opcode = SD_APP_SET_BUS_WIDTH; | 125 | cmd.opcode = SD_APP_SET_BUS_WIDTH; |
126 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | 126 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
@@ -141,7 +141,7 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width) | |||
141 | 141 | ||
142 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 142 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
143 | { | 143 | { |
144 | struct mmc_command cmd = {0}; | 144 | struct mmc_command cmd = {}; |
145 | int i, err = 0; | 145 | int i, err = 0; |
146 | 146 | ||
147 | cmd.opcode = SD_APP_OP_COND; | 147 | cmd.opcode = SD_APP_OP_COND; |
@@ -185,7 +185,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
185 | 185 | ||
186 | int mmc_send_if_cond(struct mmc_host *host, u32 ocr) | 186 | int mmc_send_if_cond(struct mmc_host *host, u32 ocr) |
187 | { | 187 | { |
188 | struct mmc_command cmd = {0}; | 188 | struct mmc_command cmd = {}; |
189 | int err; | 189 | int err; |
190 | static const u8 test_pattern = 0xAA; | 190 | static const u8 test_pattern = 0xAA; |
191 | u8 result_pattern; | 191 | u8 result_pattern; |
@@ -217,7 +217,7 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr) | |||
217 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | 217 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) |
218 | { | 218 | { |
219 | int err; | 219 | int err; |
220 | struct mmc_command cmd = {0}; | 220 | struct mmc_command cmd = {}; |
221 | 221 | ||
222 | cmd.opcode = SD_SEND_RELATIVE_ADDR; | 222 | cmd.opcode = SD_SEND_RELATIVE_ADDR; |
223 | cmd.arg = 0; | 223 | cmd.arg = 0; |
@@ -235,9 +235,9 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | |||
235 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | 235 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) |
236 | { | 236 | { |
237 | int err; | 237 | int err; |
238 | struct mmc_request mrq = {NULL}; | 238 | struct mmc_request mrq = {}; |
239 | struct mmc_command cmd = {0}; | 239 | struct mmc_command cmd = {}; |
240 | struct mmc_data data = {0}; | 240 | struct mmc_data data = {}; |
241 | struct scatterlist sg; | 241 | struct scatterlist sg; |
242 | void *data_buf; | 242 | void *data_buf; |
243 | 243 | ||
@@ -290,9 +290,9 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
290 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, | 290 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, |
291 | u8 value, u8 *resp) | 291 | u8 value, u8 *resp) |
292 | { | 292 | { |
293 | struct mmc_request mrq = {NULL}; | 293 | struct mmc_request mrq = {}; |
294 | struct mmc_command cmd = {0}; | 294 | struct mmc_command cmd = {}; |
295 | struct mmc_data data = {0}; | 295 | struct mmc_data data = {}; |
296 | struct scatterlist sg; | 296 | struct scatterlist sg; |
297 | 297 | ||
298 | /* NOTE: caller guarantees resp is heap-allocated */ | 298 | /* NOTE: caller guarantees resp is heap-allocated */ |
@@ -332,9 +332,9 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, | |||
332 | int mmc_app_sd_status(struct mmc_card *card, void *ssr) | 332 | int mmc_app_sd_status(struct mmc_card *card, void *ssr) |
333 | { | 333 | { |
334 | int err; | 334 | int err; |
335 | struct mmc_request mrq = {NULL}; | 335 | struct mmc_request mrq = {}; |
336 | struct mmc_command cmd = {0}; | 336 | struct mmc_command cmd = {}; |
337 | struct mmc_data data = {0}; | 337 | struct mmc_data data = {}; |
338 | struct scatterlist sg; | 338 | struct scatterlist sg; |
339 | 339 | ||
340 | /* NOTE: caller guarantees ssr is heap-allocated */ | 340 | /* NOTE: caller guarantees ssr is heap-allocated */ |