Skip to content

Commit 93ef12d

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Initialize struct uic_command once
Instead of first zero-initializing struct uic_command and next initializing it memberwise, initialize all members at once. Reviewed-by: Daejun Park <[email protected]> Reviewed-by: Avri Altman <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Peter Wang <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d502dac commit 93ef12d

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3993,11 +3993,11 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba)
39933993
*/
39943994
static int ufshcd_dme_link_startup(struct ufs_hba *hba)
39953995
{
3996-
struct uic_command uic_cmd = {0};
3996+
struct uic_command uic_cmd = {
3997+
.command = UIC_CMD_DME_LINK_STARTUP,
3998+
};
39973999
int ret;
39984000

3999-
uic_cmd.command = UIC_CMD_DME_LINK_STARTUP;
4000-
40014001
ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
40024002
if (ret)
40034003
dev_dbg(hba->dev,
@@ -4015,11 +4015,11 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
40154015
*/
40164016
static int ufshcd_dme_reset(struct ufs_hba *hba)
40174017
{
4018-
struct uic_command uic_cmd = {0};
4018+
struct uic_command uic_cmd = {
4019+
.command = UIC_CMD_DME_RESET,
4020+
};
40194021
int ret;
40204022

4021-
uic_cmd.command = UIC_CMD_DME_RESET;
4022-
40234023
ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
40244024
if (ret)
40254025
dev_err(hba->dev,
@@ -4054,11 +4054,11 @@ EXPORT_SYMBOL_GPL(ufshcd_dme_configure_adapt);
40544054
*/
40554055
static int ufshcd_dme_enable(struct ufs_hba *hba)
40564056
{
4057-
struct uic_command uic_cmd = {0};
4057+
struct uic_command uic_cmd = {
4058+
.command = UIC_CMD_DME_ENABLE,
4059+
};
40584060
int ret;
40594061

4060-
uic_cmd.command = UIC_CMD_DME_ENABLE;
4061-
40624062
ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
40634063
if (ret)
40644064
dev_err(hba->dev,
@@ -4111,7 +4111,12 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
41114111
int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
41124112
u8 attr_set, u32 mib_val, u8 peer)
41134113
{
4114-
struct uic_command uic_cmd = {0};
4114+
struct uic_command uic_cmd = {
4115+
.command = peer ? UIC_CMD_DME_PEER_SET : UIC_CMD_DME_SET,
4116+
.argument1 = attr_sel,
4117+
.argument2 = UIC_ARG_ATTR_TYPE(attr_set),
4118+
.argument3 = mib_val,
4119+
};
41154120
static const char *const action[] = {
41164121
"dme-set",
41174122
"dme-peer-set"
@@ -4120,12 +4125,6 @@ int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
41204125
int ret;
41214126
int retries = UFS_UIC_COMMAND_RETRIES;
41224127

4123-
uic_cmd.command = peer ?
4124-
UIC_CMD_DME_PEER_SET : UIC_CMD_DME_SET;
4125-
uic_cmd.argument1 = attr_sel;
4126-
uic_cmd.argument2 = UIC_ARG_ATTR_TYPE(attr_set);
4127-
uic_cmd.argument3 = mib_val;
4128-
41294128
do {
41304129
/* for peer attributes we retry upon failure */
41314130
ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
@@ -4155,7 +4154,10 @@ EXPORT_SYMBOL_GPL(ufshcd_dme_set_attr);
41554154
int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
41564155
u32 *mib_val, u8 peer)
41574156
{
4158-
struct uic_command uic_cmd = {0};
4157+
struct uic_command uic_cmd = {
4158+
.command = peer ? UIC_CMD_DME_PEER_GET : UIC_CMD_DME_GET,
4159+
.argument1 = attr_sel,
4160+
};
41594161
static const char *const action[] = {
41604162
"dme-get",
41614163
"dme-peer-get"
@@ -4189,10 +4191,6 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
41894191
}
41904192
}
41914193

4192-
uic_cmd.command = peer ?
4193-
UIC_CMD_DME_PEER_GET : UIC_CMD_DME_GET;
4194-
uic_cmd.argument1 = attr_sel;
4195-
41964194
do {
41974195
/* for peer attributes we retry upon failure */
41984196
ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
@@ -4325,7 +4323,11 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
43254323
*/
43264324
int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
43274325
{
4328-
struct uic_command uic_cmd = {0};
4326+
struct uic_command uic_cmd = {
4327+
.command = UIC_CMD_DME_SET,
4328+
.argument1 = UIC_ARG_MIB(PA_PWRMODE),
4329+
.argument3 = mode,
4330+
};
43294331
int ret;
43304332

43314333
if (hba->quirks & UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP) {
@@ -4338,9 +4340,6 @@ int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
43384340
}
43394341
}
43404342

4341-
uic_cmd.command = UIC_CMD_DME_SET;
4342-
uic_cmd.argument1 = UIC_ARG_MIB(PA_PWRMODE);
4343-
uic_cmd.argument3 = mode;
43444343
ufshcd_hold(hba);
43454344
ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
43464345
ufshcd_release(hba);
@@ -4381,13 +4380,14 @@ EXPORT_SYMBOL_GPL(ufshcd_link_recovery);
43814380

43824381
int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
43834382
{
4384-
int ret;
4385-
struct uic_command uic_cmd = {0};
4383+
struct uic_command uic_cmd = {
4384+
.command = UIC_CMD_DME_HIBER_ENTER,
4385+
};
43864386
ktime_t start = ktime_get();
4387+
int ret;
43874388

43884389
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, PRE_CHANGE);
43894390

4390-
uic_cmd.command = UIC_CMD_DME_HIBER_ENTER;
43914391
ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
43924392
trace_ufshcd_profile_hibern8(dev_name(hba->dev), "enter",
43934393
ktime_to_us(ktime_sub(ktime_get(), start)), ret);
@@ -4405,13 +4405,14 @@ EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_enter);
44054405

44064406
int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
44074407
{
4408-
struct uic_command uic_cmd = {0};
4408+
struct uic_command uic_cmd = {
4409+
.command = UIC_CMD_DME_HIBER_EXIT,
4410+
};
44094411
int ret;
44104412
ktime_t start = ktime_get();
44114413

44124414
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, PRE_CHANGE);
44134415

4414-
uic_cmd.command = UIC_CMD_DME_HIBER_EXIT;
44154416
ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
44164417
trace_ufshcd_profile_hibern8(dev_name(hba->dev), "exit",
44174418
ktime_to_us(ktime_sub(ktime_get(), start)), ret);

include/ufs/ufshcd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ enum ufs_event_type {
7373
* @done: UIC command completion
7474
*/
7575
struct uic_command {
76-
u32 command;
77-
u32 argument1;
76+
const u32 command;
77+
const u32 argument1;
7878
u32 argument2;
7979
u32 argument3;
8080
int cmd_active;

0 commit comments

Comments
 (0)