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/mmc_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/mmc_ops.c')
-rw-r--r-- | drivers/mmc/core/mmc_ops.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index e6ea8503f40c..fe80f26d6971 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -57,7 +57,7 @@ static const u8 tuning_blk_pattern_8bit[] = { | |||
57 | int mmc_send_status(struct mmc_card *card, u32 *status) | 57 | int mmc_send_status(struct mmc_card *card, u32 *status) |
58 | { | 58 | { |
59 | int err; | 59 | int err; |
60 | struct mmc_command cmd = {0}; | 60 | struct mmc_command cmd = {}; |
61 | 61 | ||
62 | cmd.opcode = MMC_SEND_STATUS; | 62 | cmd.opcode = MMC_SEND_STATUS; |
63 | if (!mmc_host_is_spi(card->host)) | 63 | if (!mmc_host_is_spi(card->host)) |
@@ -79,7 +79,7 @@ int mmc_send_status(struct mmc_card *card, u32 *status) | |||
79 | 79 | ||
80 | static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) | 80 | static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) |
81 | { | 81 | { |
82 | struct mmc_command cmd = {0}; | 82 | struct mmc_command cmd = {}; |
83 | 83 | ||
84 | cmd.opcode = MMC_SELECT_CARD; | 84 | cmd.opcode = MMC_SELECT_CARD; |
85 | 85 | ||
@@ -115,7 +115,7 @@ int mmc_deselect_cards(struct mmc_host *host) | |||
115 | */ | 115 | */ |
116 | int mmc_set_dsr(struct mmc_host *host) | 116 | int mmc_set_dsr(struct mmc_host *host) |
117 | { | 117 | { |
118 | struct mmc_command cmd = {0}; | 118 | struct mmc_command cmd = {}; |
119 | 119 | ||
120 | cmd.opcode = MMC_SET_DSR; | 120 | cmd.opcode = MMC_SET_DSR; |
121 | 121 | ||
@@ -128,7 +128,7 @@ int mmc_set_dsr(struct mmc_host *host) | |||
128 | int mmc_go_idle(struct mmc_host *host) | 128 | int mmc_go_idle(struct mmc_host *host) |
129 | { | 129 | { |
130 | int err; | 130 | int err; |
131 | struct mmc_command cmd = {0}; | 131 | struct mmc_command cmd = {}; |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * Non-SPI hosts need to prevent chipselect going active during | 134 | * Non-SPI hosts need to prevent chipselect going active during |
@@ -164,7 +164,7 @@ int mmc_go_idle(struct mmc_host *host) | |||
164 | 164 | ||
165 | int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 165 | int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
166 | { | 166 | { |
167 | struct mmc_command cmd = {0}; | 167 | struct mmc_command cmd = {}; |
168 | int i, err = 0; | 168 | int i, err = 0; |
169 | 169 | ||
170 | cmd.opcode = MMC_SEND_OP_COND; | 170 | cmd.opcode = MMC_SEND_OP_COND; |
@@ -203,7 +203,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
203 | int mmc_all_send_cid(struct mmc_host *host, u32 *cid) | 203 | int mmc_all_send_cid(struct mmc_host *host, u32 *cid) |
204 | { | 204 | { |
205 | int err; | 205 | int err; |
206 | struct mmc_command cmd = {0}; | 206 | struct mmc_command cmd = {}; |
207 | 207 | ||
208 | cmd.opcode = MMC_ALL_SEND_CID; | 208 | cmd.opcode = MMC_ALL_SEND_CID; |
209 | cmd.arg = 0; | 209 | cmd.arg = 0; |
@@ -220,7 +220,7 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid) | |||
220 | 220 | ||
221 | int mmc_set_relative_addr(struct mmc_card *card) | 221 | int mmc_set_relative_addr(struct mmc_card *card) |
222 | { | 222 | { |
223 | struct mmc_command cmd = {0}; | 223 | struct mmc_command cmd = {}; |
224 | 224 | ||
225 | cmd.opcode = MMC_SET_RELATIVE_ADDR; | 225 | cmd.opcode = MMC_SET_RELATIVE_ADDR; |
226 | cmd.arg = card->rca << 16; | 226 | cmd.arg = card->rca << 16; |
@@ -233,7 +233,7 @@ static int | |||
233 | mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode) | 233 | mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode) |
234 | { | 234 | { |
235 | int err; | 235 | int err; |
236 | struct mmc_command cmd = {0}; | 236 | struct mmc_command cmd = {}; |
237 | 237 | ||
238 | cmd.opcode = opcode; | 238 | cmd.opcode = opcode; |
239 | cmd.arg = arg; | 239 | cmd.arg = arg; |
@@ -256,9 +256,9 @@ static int | |||
256 | mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, | 256 | mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, |
257 | u32 opcode, void *buf, unsigned len) | 257 | u32 opcode, void *buf, unsigned len) |
258 | { | 258 | { |
259 | struct mmc_request mrq = {NULL}; | 259 | struct mmc_request mrq = {}; |
260 | struct mmc_command cmd = {0}; | 260 | struct mmc_command cmd = {}; |
261 | struct mmc_data data = {0}; | 261 | struct mmc_data data = {}; |
262 | struct scatterlist sg; | 262 | struct scatterlist sg; |
263 | 263 | ||
264 | mrq.cmd = &cmd; | 264 | mrq.cmd = &cmd; |
@@ -387,7 +387,7 @@ EXPORT_SYMBOL_GPL(mmc_get_ext_csd); | |||
387 | 387 | ||
388 | int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp) | 388 | int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp) |
389 | { | 389 | { |
390 | struct mmc_command cmd = {0}; | 390 | struct mmc_command cmd = {}; |
391 | int err; | 391 | int err; |
392 | 392 | ||
393 | cmd.opcode = MMC_SPI_READ_OCR; | 393 | cmd.opcode = MMC_SPI_READ_OCR; |
@@ -402,7 +402,7 @@ int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp) | |||
402 | 402 | ||
403 | int mmc_spi_set_crc(struct mmc_host *host, int use_crc) | 403 | int mmc_spi_set_crc(struct mmc_host *host, int use_crc) |
404 | { | 404 | { |
405 | struct mmc_command cmd = {0}; | 405 | struct mmc_command cmd = {}; |
406 | int err; | 406 | int err; |
407 | 407 | ||
408 | cmd.opcode = MMC_SPI_CRC_ON_OFF; | 408 | cmd.opcode = MMC_SPI_CRC_ON_OFF; |
@@ -530,7 +530,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
530 | { | 530 | { |
531 | struct mmc_host *host = card->host; | 531 | struct mmc_host *host = card->host; |
532 | int err; | 532 | int err; |
533 | struct mmc_command cmd = {0}; | 533 | struct mmc_command cmd = {}; |
534 | bool use_r1b_resp = use_busy_signal; | 534 | bool use_r1b_resp = use_busy_signal; |
535 | unsigned char old_timing = host->ios.timing; | 535 | unsigned char old_timing = host->ios.timing; |
536 | 536 | ||
@@ -610,9 +610,9 @@ EXPORT_SYMBOL_GPL(mmc_switch); | |||
610 | 610 | ||
611 | int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error) | 611 | int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error) |
612 | { | 612 | { |
613 | struct mmc_request mrq = {NULL}; | 613 | struct mmc_request mrq = {}; |
614 | struct mmc_command cmd = {0}; | 614 | struct mmc_command cmd = {}; |
615 | struct mmc_data data = {0}; | 615 | struct mmc_data data = {}; |
616 | struct scatterlist sg; | 616 | struct scatterlist sg; |
617 | struct mmc_ios *ios = &host->ios; | 617 | struct mmc_ios *ios = &host->ios; |
618 | const u8 *tuning_block_pattern; | 618 | const u8 *tuning_block_pattern; |
@@ -679,7 +679,7 @@ EXPORT_SYMBOL_GPL(mmc_send_tuning); | |||
679 | 679 | ||
680 | int mmc_abort_tuning(struct mmc_host *host, u32 opcode) | 680 | int mmc_abort_tuning(struct mmc_host *host, u32 opcode) |
681 | { | 681 | { |
682 | struct mmc_command cmd = {0}; | 682 | struct mmc_command cmd = {}; |
683 | 683 | ||
684 | /* | 684 | /* |
685 | * eMMC specification specifies that CMD12 can be used to stop a tuning | 685 | * eMMC specification specifies that CMD12 can be used to stop a tuning |
@@ -706,9 +706,9 @@ static int | |||
706 | mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, | 706 | mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, |
707 | u8 len) | 707 | u8 len) |
708 | { | 708 | { |
709 | struct mmc_request mrq = {NULL}; | 709 | struct mmc_request mrq = {}; |
710 | struct mmc_command cmd = {0}; | 710 | struct mmc_command cmd = {}; |
711 | struct mmc_data data = {0}; | 711 | struct mmc_data data = {}; |
712 | struct scatterlist sg; | 712 | struct scatterlist sg; |
713 | u8 *data_buf; | 713 | u8 *data_buf; |
714 | u8 *test_buf; | 714 | u8 *test_buf; |
@@ -802,7 +802,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width) | |||
802 | 802 | ||
803 | int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) | 803 | int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) |
804 | { | 804 | { |
805 | struct mmc_command cmd = {0}; | 805 | struct mmc_command cmd = {}; |
806 | unsigned int opcode; | 806 | unsigned int opcode; |
807 | int err; | 807 | int err; |
808 | 808 | ||