@@ -1146,14 +1146,8 @@ static struct ipmi_smi_watcher smi_watcher = {
1146
1146
.smi_gone = ipmi_smi_gone
1147
1147
};
1148
1148
1149
- static int action_op (const char * inval , char * outval )
1149
+ static int action_op_set_val (const char * inval )
1150
1150
{
1151
- if (outval )
1152
- strcpy (outval , action );
1153
-
1154
- if (!inval )
1155
- return 0 ;
1156
-
1157
1151
if (strcmp (inval , "reset" ) == 0 )
1158
1152
action_val = WDOG_TIMEOUT_RESET ;
1159
1153
else if (strcmp (inval , "none" ) == 0 )
@@ -1164,18 +1158,26 @@ static int action_op(const char *inval, char *outval)
1164
1158
action_val = WDOG_TIMEOUT_POWER_DOWN ;
1165
1159
else
1166
1160
return - EINVAL ;
1167
- strcpy (action , inval );
1168
1161
return 0 ;
1169
1162
}
1170
1163
1171
- static int preaction_op (const char * inval , char * outval )
1164
+ static int action_op (const char * inval , char * outval )
1172
1165
{
1166
+ int rv ;
1167
+
1173
1168
if (outval )
1174
- strcpy (outval , preaction );
1169
+ strcpy (outval , action );
1175
1170
1176
1171
if (!inval )
1177
1172
return 0 ;
1173
+ rv = action_op_set_val (inval );
1174
+ if (!rv )
1175
+ strcpy (action , inval );
1176
+ return rv ;
1177
+ }
1178
1178
1179
+ static int preaction_op_set_val (const char * inval )
1180
+ {
1179
1181
if (strcmp (inval , "pre_none" ) == 0 )
1180
1182
preaction_val = WDOG_PRETIMEOUT_NONE ;
1181
1183
else if (strcmp (inval , "pre_smi" ) == 0 )
@@ -1188,18 +1190,26 @@ static int preaction_op(const char *inval, char *outval)
1188
1190
preaction_val = WDOG_PRETIMEOUT_MSG_INT ;
1189
1191
else
1190
1192
return - EINVAL ;
1191
- strcpy (preaction , inval );
1192
1193
return 0 ;
1193
1194
}
1194
1195
1195
- static int preop_op (const char * inval , char * outval )
1196
+ static int preaction_op (const char * inval , char * outval )
1196
1197
{
1198
+ int rv ;
1199
+
1197
1200
if (outval )
1198
- strcpy (outval , preop );
1201
+ strcpy (outval , preaction );
1199
1202
1200
1203
if (!inval )
1201
1204
return 0 ;
1205
+ rv = preaction_op_set_val (inval );
1206
+ if (!rv )
1207
+ strcpy (preaction , inval );
1208
+ return 0 ;
1209
+ }
1202
1210
1211
+ static int preop_op_set_val (const char * inval )
1212
+ {
1203
1213
if (strcmp (inval , "preop_none" ) == 0 )
1204
1214
preop_val = WDOG_PREOP_NONE ;
1205
1215
else if (strcmp (inval , "preop_panic" ) == 0 )
@@ -1208,7 +1218,22 @@ static int preop_op(const char *inval, char *outval)
1208
1218
preop_val = WDOG_PREOP_GIVE_DATA ;
1209
1219
else
1210
1220
return - EINVAL ;
1211
- strcpy (preop , inval );
1221
+ return 0 ;
1222
+ }
1223
+
1224
+ static int preop_op (const char * inval , char * outval )
1225
+ {
1226
+ int rv ;
1227
+
1228
+ if (outval )
1229
+ strcpy (outval , preop );
1230
+
1231
+ if (!inval )
1232
+ return 0 ;
1233
+
1234
+ rv = preop_op_set_val (inval );
1235
+ if (!rv )
1236
+ strcpy (preop , inval );
1212
1237
return 0 ;
1213
1238
}
1214
1239
@@ -1245,18 +1270,18 @@ static int __init ipmi_wdog_init(void)
1245
1270
{
1246
1271
int rv ;
1247
1272
1248
- if (action_op (action , NULL )) {
1273
+ if (action_op_set_val (action )) {
1249
1274
action_op ("reset" , NULL );
1250
1275
pr_info ("Unknown action '%s', defaulting to reset\n" , action );
1251
1276
}
1252
1277
1253
- if (preaction_op (preaction , NULL )) {
1278
+ if (preaction_op_set_val (preaction )) {
1254
1279
preaction_op ("pre_none" , NULL );
1255
1280
pr_info ("Unknown preaction '%s', defaulting to none\n" ,
1256
1281
preaction );
1257
1282
}
1258
1283
1259
- if (preop_op (preop , NULL )) {
1284
+ if (preop_op_set_val (preop )) {
1260
1285
preop_op ("preop_none" , NULL );
1261
1286
pr_info ("Unknown preop '%s', defaulting to none\n" , preop );
1262
1287
}
0 commit comments