3131
3232#define CEIL4 (x ) ((((x) + 3) / 4) * 4)
3333
34- struct response_type {
35- struct completion work ;
36- int type ;
37- };
38-
3934#define CEXXC_RESPONSE_TYPE_ICA 0
4035#define CEXXC_RESPONSE_TYPE_XCRB 1
4136#define CEXXC_RESPONSE_TYPE_EP11 2
@@ -856,7 +851,7 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq,
856851 .type = TYPE82_RSP_CODE ,
857852 .reply_code = REP82_ERROR_MACHINE_FAILURE ,
858853 };
859- struct response_type * resp_type = msg -> private ;
854+ struct ap_response_type * resp_type = & msg -> response ;
860855 struct type86x_reply * t86r ;
861856 int len ;
862857
@@ -920,7 +915,7 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq,
920915 .type = TYPE82_RSP_CODE ,
921916 .reply_code = REP82_ERROR_MACHINE_FAILURE ,
922917 };
923- struct response_type * resp_type = msg -> private ;
918+ struct ap_response_type * resp_type = & msg -> response ;
924919 struct type86_ep11_reply * t86r ;
925920 int len ;
926921
@@ -967,9 +962,7 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
967962 struct ica_rsa_modexpo * mex ,
968963 struct ap_message * ap_msg )
969964{
970- struct response_type resp_type = {
971- .type = CEXXC_RESPONSE_TYPE_ICA ,
972- };
965+ struct ap_response_type * resp_type = & ap_msg -> response ;
973966 int rc ;
974967
975968 ap_msg -> msg = (void * )get_zeroed_page (GFP_KERNEL );
@@ -979,15 +972,15 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
979972 ap_msg -> receive = zcrypt_msgtype6_receive ;
980973 ap_msg -> psmid = (((unsigned long )current -> pid ) << 32 ) +
981974 atomic_inc_return (& zcrypt_step );
982- ap_msg -> private = & resp_type ;
983975 rc = icamex_msg_to_type6mex_msgx (zq , ap_msg , mex );
984976 if (rc )
985977 goto out_free ;
986- init_completion (& resp_type .work );
978+ resp_type -> type = CEXXC_RESPONSE_TYPE_ICA ;
979+ init_completion (& resp_type -> work );
987980 rc = ap_queue_message (zq -> queue , ap_msg );
988981 if (rc )
989982 goto out_free ;
990- rc = wait_for_completion_interruptible (& resp_type . work );
983+ rc = wait_for_completion_interruptible (& resp_type -> work );
991984 if (rc == 0 ) {
992985 rc = ap_msg -> rc ;
993986 if (rc == 0 )
@@ -1001,7 +994,6 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
1001994
1002995out_free :
1003996 free_page ((unsigned long )ap_msg -> msg );
1004- ap_msg -> private = NULL ;
1005997 ap_msg -> msg = NULL ;
1006998 return rc ;
1007999}
@@ -1017,9 +1009,7 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
10171009 struct ica_rsa_modexpo_crt * crt ,
10181010 struct ap_message * ap_msg )
10191011{
1020- struct response_type resp_type = {
1021- .type = CEXXC_RESPONSE_TYPE_ICA ,
1022- };
1012+ struct ap_response_type * resp_type = & ap_msg -> response ;
10231013 int rc ;
10241014
10251015 ap_msg -> msg = (void * )get_zeroed_page (GFP_KERNEL );
@@ -1029,15 +1019,15 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
10291019 ap_msg -> receive = zcrypt_msgtype6_receive ;
10301020 ap_msg -> psmid = (((unsigned long )current -> pid ) << 32 ) +
10311021 atomic_inc_return (& zcrypt_step );
1032- ap_msg -> private = & resp_type ;
10331022 rc = icacrt_msg_to_type6crt_msgx (zq , ap_msg , crt );
10341023 if (rc )
10351024 goto out_free ;
1036- init_completion (& resp_type .work );
1025+ resp_type -> type = CEXXC_RESPONSE_TYPE_ICA ;
1026+ init_completion (& resp_type -> work );
10371027 rc = ap_queue_message (zq -> queue , ap_msg );
10381028 if (rc )
10391029 goto out_free ;
1040- rc = wait_for_completion_interruptible (& resp_type . work );
1030+ rc = wait_for_completion_interruptible (& resp_type -> work );
10411031 if (rc == 0 ) {
10421032 rc = ap_msg -> rc ;
10431033 if (rc == 0 )
@@ -1051,7 +1041,6 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
10511041
10521042out_free :
10531043 free_page ((unsigned long )ap_msg -> msg );
1054- ap_msg -> private = NULL ;
10551044 ap_msg -> msg = NULL ;
10561045 return rc ;
10571046}
@@ -1069,9 +1058,7 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb,
10691058 struct ap_message * ap_msg ,
10701059 unsigned int * func_code , unsigned short * * dom )
10711060{
1072- struct response_type resp_type = {
1073- .type = CEXXC_RESPONSE_TYPE_XCRB ,
1074- };
1061+ struct ap_response_type * resp_type = & ap_msg -> response ;
10751062
10761063 ap_msg -> bufsize = atomic_read (& ap_max_msg_size );
10771064 ap_msg -> msg = kmalloc (ap_msg -> bufsize , GFP_KERNEL );
@@ -1080,9 +1067,7 @@ int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb,
10801067 ap_msg -> receive = zcrypt_msgtype6_receive ;
10811068 ap_msg -> psmid = (((unsigned long )current -> pid ) << 32 ) +
10821069 atomic_inc_return (& zcrypt_step );
1083- ap_msg -> private = kmemdup (& resp_type , sizeof (resp_type ), GFP_KERNEL );
1084- if (!ap_msg -> private )
1085- return - ENOMEM ;
1070+ resp_type -> type = CEXXC_RESPONSE_TYPE_XCRB ;
10861071 return xcrb_msg_to_type6cprb_msgx (userspace , ap_msg , xcrb , func_code , dom );
10871072}
10881073
@@ -1097,7 +1082,7 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq,
10971082 struct ica_xcRB * xcrb ,
10981083 struct ap_message * ap_msg )
10991084{
1100- struct response_type * rtype = ap_msg -> private ;
1085+ struct ap_response_type * resp_type = & ap_msg -> response ;
11011086 struct {
11021087 struct type6_hdr hdr ;
11031088 struct CPRBX cprbx ;
@@ -1128,11 +1113,11 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq,
11281113 msg -> hdr .fromcardlen1 -= delta ;
11291114 }
11301115
1131- init_completion (& rtype -> work );
1116+ init_completion (& resp_type -> work );
11321117 rc = ap_queue_message (zq -> queue , ap_msg );
11331118 if (rc )
11341119 goto out ;
1135- rc = wait_for_completion_interruptible (& rtype -> work );
1120+ rc = wait_for_completion_interruptible (& resp_type -> work );
11361121 if (rc == 0 ) {
11371122 rc = ap_msg -> rc ;
11381123 if (rc == 0 )
@@ -1166,9 +1151,7 @@ int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb,
11661151 struct ap_message * ap_msg ,
11671152 unsigned int * func_code , unsigned int * domain )
11681153{
1169- struct response_type resp_type = {
1170- .type = CEXXC_RESPONSE_TYPE_EP11 ,
1171- };
1154+ struct ap_response_type * resp_type = & ap_msg -> response ;
11721155
11731156 ap_msg -> bufsize = atomic_read (& ap_max_msg_size );
11741157 ap_msg -> msg = kmalloc (ap_msg -> bufsize , GFP_KERNEL );
@@ -1177,9 +1160,7 @@ int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb,
11771160 ap_msg -> receive = zcrypt_msgtype6_receive_ep11 ;
11781161 ap_msg -> psmid = (((unsigned long )current -> pid ) << 32 ) +
11791162 atomic_inc_return (& zcrypt_step );
1180- ap_msg -> private = kmemdup (& resp_type , sizeof (resp_type ), GFP_KERNEL );
1181- if (!ap_msg -> private )
1182- return - ENOMEM ;
1163+ resp_type -> type = CEXXC_RESPONSE_TYPE_EP11 ;
11831164 return xcrb_msg_to_type6_ep11cprb_msgx (userspace , ap_msg , xcrb ,
11841165 func_code , domain );
11851166}
@@ -1197,7 +1178,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
11971178{
11981179 int rc ;
11991180 unsigned int lfmt ;
1200- struct response_type * rtype = ap_msg -> private ;
1181+ struct ap_response_type * resp_type = & ap_msg -> response ;
12011182 struct {
12021183 struct type6_hdr hdr ;
12031184 struct ep11_cprb cprbx ;
@@ -1251,11 +1232,11 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
12511232 msg -> hdr .fromcardlen1 = zq -> reply .bufsize -
12521233 sizeof (struct type86_hdr ) - sizeof (struct type86_fmt2_ext );
12531234
1254- init_completion (& rtype -> work );
1235+ init_completion (& resp_type -> work );
12551236 rc = ap_queue_message (zq -> queue , ap_msg );
12561237 if (rc )
12571238 goto out ;
1258- rc = wait_for_completion_interruptible (& rtype -> work );
1239+ rc = wait_for_completion_interruptible (& resp_type -> work );
12591240 if (rc == 0 ) {
12601241 rc = ap_msg -> rc ;
12611242 if (rc == 0 )
@@ -1279,9 +1260,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
12791260int prep_rng_ap_msg (struct ap_message * ap_msg , int * func_code ,
12801261 unsigned int * domain )
12811262{
1282- struct response_type resp_type = {
1283- .type = CEXXC_RESPONSE_TYPE_XCRB ,
1284- };
1263+ struct ap_response_type * resp_type = & ap_msg -> response ;
12851264
12861265 ap_msg -> bufsize = AP_DEFAULT_MAX_MSG_SIZE ;
12871266 ap_msg -> msg = kmalloc (ap_msg -> bufsize , GFP_KERNEL );
@@ -1290,9 +1269,8 @@ int prep_rng_ap_msg(struct ap_message *ap_msg, int *func_code,
12901269 ap_msg -> receive = zcrypt_msgtype6_receive ;
12911270 ap_msg -> psmid = (((unsigned long )current -> pid ) << 32 ) +
12921271 atomic_inc_return (& zcrypt_step );
1293- ap_msg -> private = kmemdup (& resp_type , sizeof (resp_type ), GFP_KERNEL );
1294- if (!ap_msg -> private )
1295- return - ENOMEM ;
1272+
1273+ resp_type -> type = CEXXC_RESPONSE_TYPE_XCRB ;
12961274
12971275 rng_type6cprb_msgx (ap_msg , ZCRYPT_RNG_BUFFER_SIZE , domain );
12981276
@@ -1319,16 +1297,16 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq,
13191297 short int verb_length ;
13201298 short int key_length ;
13211299 } __packed * msg = ap_msg -> msg ;
1322- struct response_type * rtype = ap_msg -> private ;
1300+ struct ap_response_type * resp_type = & ap_msg -> response ;
13231301 int rc ;
13241302
13251303 msg -> cprbx .domain = AP_QID_QUEUE (zq -> queue -> qid );
13261304
1327- init_completion (& rtype -> work );
1305+ init_completion (& resp_type -> work );
13281306 rc = ap_queue_message (zq -> queue , ap_msg );
13291307 if (rc )
13301308 goto out ;
1331- rc = wait_for_completion_interruptible (& rtype -> work );
1309+ rc = wait_for_completion_interruptible (& resp_type -> work );
13321310 if (rc == 0 ) {
13331311 rc = ap_msg -> rc ;
13341312 if (rc == 0 )
0 commit comments