@@ -136,27 +136,22 @@ int ishtp_hbm_start_wait(struct ishtp_device *dev)
136
136
int ishtp_hbm_start_req (struct ishtp_device * dev )
137
137
{
138
138
struct ishtp_msg_hdr hdr ;
139
- unsigned char data [128 ];
140
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
141
- struct hbm_host_version_request * start_req ;
142
- const size_t len = sizeof (struct hbm_host_version_request );
139
+ struct hbm_host_version_request start_req = { 0 };
143
140
144
- ishtp_hbm_hdr (ishtp_hdr , len );
141
+ ishtp_hbm_hdr (& hdr , sizeof ( start_req ) );
145
142
146
143
/* host start message */
147
- start_req = (struct hbm_host_version_request * )data ;
148
- memset (start_req , 0 , len );
149
- start_req -> hbm_cmd = HOST_START_REQ_CMD ;
150
- start_req -> host_version .major_version = HBM_MAJOR_VERSION ;
151
- start_req -> host_version .minor_version = HBM_MINOR_VERSION ;
144
+ start_req .hbm_cmd = HOST_START_REQ_CMD ;
145
+ start_req .host_version .major_version = HBM_MAJOR_VERSION ;
146
+ start_req .host_version .minor_version = HBM_MINOR_VERSION ;
152
147
153
148
/*
154
149
* (!) Response to HBM start may be so quick that this thread would get
155
150
* preempted BEFORE managing to set hbm_state = ISHTP_HBM_START.
156
151
* So set it at first, change back to ISHTP_HBM_IDLE upon failure
157
152
*/
158
153
dev -> hbm_state = ISHTP_HBM_START ;
159
- if (ishtp_write_message (dev , ishtp_hdr , data )) {
154
+ if (ishtp_write_message (dev , & hdr , & start_req )) {
160
155
dev_err (dev -> devc , "version message send failed\n" );
161
156
dev -> dev_state = ISHTP_DEV_RESETTING ;
162
157
dev -> hbm_state = ISHTP_HBM_IDLE ;
@@ -178,19 +173,13 @@ int ishtp_hbm_start_req(struct ishtp_device *dev)
178
173
void ishtp_hbm_enum_clients_req (struct ishtp_device * dev )
179
174
{
180
175
struct ishtp_msg_hdr hdr ;
181
- unsigned char data [128 ];
182
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
183
- struct hbm_host_enum_request * enum_req ;
184
- const size_t len = sizeof (struct hbm_host_enum_request );
176
+ struct hbm_host_enum_request enum_req = { 0 };
185
177
186
178
/* enumerate clients */
187
- ishtp_hbm_hdr (ishtp_hdr , len );
179
+ ishtp_hbm_hdr (& hdr , sizeof (enum_req ));
180
+ enum_req .hbm_cmd = HOST_ENUM_REQ_CMD ;
188
181
189
- enum_req = (struct hbm_host_enum_request * )data ;
190
- memset (enum_req , 0 , len );
191
- enum_req -> hbm_cmd = HOST_ENUM_REQ_CMD ;
192
-
193
- if (ishtp_write_message (dev , ishtp_hdr , data )) {
182
+ if (ishtp_write_message (dev , & hdr , & enum_req )) {
194
183
dev -> dev_state = ISHTP_DEV_RESETTING ;
195
184
dev_err (dev -> devc , "enumeration request send failed\n" );
196
185
ish_hw_reset (dev );
@@ -208,12 +197,8 @@ void ishtp_hbm_enum_clients_req(struct ishtp_device *dev)
208
197
*/
209
198
static int ishtp_hbm_prop_req (struct ishtp_device * dev )
210
199
{
211
-
212
200
struct ishtp_msg_hdr hdr ;
213
- unsigned char data [128 ];
214
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
215
- struct hbm_props_request * prop_req ;
216
- const size_t len = sizeof (struct hbm_props_request );
201
+ struct hbm_props_request prop_req = { 0 };
217
202
unsigned long next_client_index ;
218
203
uint8_t client_num ;
219
204
@@ -237,15 +222,12 @@ static int ishtp_hbm_prop_req(struct ishtp_device *dev)
237
222
238
223
dev -> fw_clients [client_num ].client_id = next_client_index ;
239
224
240
- ishtp_hbm_hdr (ishtp_hdr , len );
241
- prop_req = (struct hbm_props_request * )data ;
225
+ ishtp_hbm_hdr (& hdr , sizeof (prop_req ));
242
226
243
- memset (prop_req , 0 , sizeof (struct hbm_props_request ));
227
+ prop_req .hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD ;
228
+ prop_req .address = next_client_index ;
244
229
245
- prop_req -> hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD ;
246
- prop_req -> address = next_client_index ;
247
-
248
- if (ishtp_write_message (dev , ishtp_hdr , data )) {
230
+ if (ishtp_write_message (dev , & hdr , & prop_req )) {
249
231
dev -> dev_state = ISHTP_DEV_RESETTING ;
250
232
dev_err (dev -> devc , "properties request send failed\n" );
251
233
ish_hw_reset (dev );
@@ -266,19 +248,14 @@ static int ishtp_hbm_prop_req(struct ishtp_device *dev)
266
248
static void ishtp_hbm_stop_req (struct ishtp_device * dev )
267
249
{
268
250
struct ishtp_msg_hdr hdr ;
269
- unsigned char data [128 ];
270
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
271
- struct hbm_host_stop_request * req ;
272
- const size_t len = sizeof (struct hbm_host_stop_request );
251
+ struct hbm_host_stop_request stop_req = { 0 } ;
273
252
274
- ishtp_hbm_hdr (ishtp_hdr , len );
275
- req = (struct hbm_host_stop_request * )data ;
253
+ ishtp_hbm_hdr (& hdr , sizeof (stop_req ));
276
254
277
- memset (req , 0 , sizeof (struct hbm_host_stop_request ));
278
- req -> hbm_cmd = HOST_STOP_REQ_CMD ;
279
- req -> reason = DRIVER_STOP_REQUEST ;
255
+ stop_req .hbm_cmd = HOST_STOP_REQ_CMD ;
256
+ stop_req .reason = DRIVER_STOP_REQUEST ;
280
257
281
- ishtp_write_message (dev , ishtp_hdr , data );
258
+ ishtp_write_message (dev , & hdr , & stop_req );
282
259
}
283
260
284
261
/**
@@ -294,15 +271,15 @@ int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev,
294
271
struct ishtp_cl * cl )
295
272
{
296
273
struct ishtp_msg_hdr hdr ;
297
- unsigned char data [128 ];
298
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
299
- const size_t len = sizeof (struct hbm_flow_control );
274
+ struct hbm_flow_control flow_ctrl ;
275
+ const size_t len = sizeof (flow_ctrl );
300
276
int rv ;
301
277
unsigned long flags ;
302
278
303
279
spin_lock_irqsave (& cl -> fc_spinlock , flags );
304
- ishtp_hbm_hdr (ishtp_hdr , len );
305
- ishtp_hbm_cl_hdr (cl , ISHTP_FLOW_CONTROL_CMD , data , len );
280
+
281
+ ishtp_hbm_hdr (& hdr , len );
282
+ ishtp_hbm_cl_hdr (cl , ISHTP_FLOW_CONTROL_CMD , & flow_ctrl , len );
306
283
307
284
/*
308
285
* Sync possible race when RB recycle and packet receive paths
@@ -315,7 +292,7 @@ int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev,
315
292
316
293
cl -> recv_msg_num_frags = 0 ;
317
294
318
- rv = ishtp_write_message (dev , ishtp_hdr , data );
295
+ rv = ishtp_write_message (dev , & hdr , & flow_ctrl );
319
296
if (!rv ) {
320
297
++ cl -> out_flow_ctrl_creds ;
321
298
++ cl -> out_flow_ctrl_cnt ;
@@ -345,14 +322,13 @@ int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev,
345
322
int ishtp_hbm_cl_disconnect_req (struct ishtp_device * dev , struct ishtp_cl * cl )
346
323
{
347
324
struct ishtp_msg_hdr hdr ;
348
- unsigned char data [128 ];
349
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
350
- const size_t len = sizeof (struct hbm_client_connect_request );
325
+ struct hbm_client_connect_request disconn_req ;
326
+ const size_t len = sizeof (disconn_req );
351
327
352
- ishtp_hbm_hdr (ishtp_hdr , len );
353
- ishtp_hbm_cl_hdr (cl , CLIENT_DISCONNECT_REQ_CMD , data , len );
328
+ ishtp_hbm_hdr (& hdr , len );
329
+ ishtp_hbm_cl_hdr (cl , CLIENT_DISCONNECT_REQ_CMD , & disconn_req , len );
354
330
355
- return ishtp_write_message (dev , ishtp_hdr , data );
331
+ return ishtp_write_message (dev , & hdr , & disconn_req );
356
332
}
357
333
358
334
/**
@@ -391,14 +367,13 @@ static void ishtp_hbm_cl_disconnect_res(struct ishtp_device *dev,
391
367
int ishtp_hbm_cl_connect_req (struct ishtp_device * dev , struct ishtp_cl * cl )
392
368
{
393
369
struct ishtp_msg_hdr hdr ;
394
- unsigned char data [128 ];
395
- struct ishtp_msg_hdr * ishtp_hdr = & hdr ;
396
- const size_t len = sizeof (struct hbm_client_connect_request );
370
+ struct hbm_client_connect_request conn_req ;
371
+ const size_t len = sizeof (conn_req );
397
372
398
- ishtp_hbm_hdr (ishtp_hdr , len );
399
- ishtp_hbm_cl_hdr (cl , CLIENT_CONNECT_REQ_CMD , data , len );
373
+ ishtp_hbm_hdr (& hdr , len );
374
+ ishtp_hbm_cl_hdr (cl , CLIENT_CONNECT_REQ_CMD , & conn_req , len );
400
375
401
- return ishtp_write_message (dev , ishtp_hdr , data );
376
+ return ishtp_write_message (dev , & hdr , & conn_req );
402
377
}
403
378
404
379
/**
0 commit comments