Skip to content

Commit 23a4757

Browse files
hfreudeVasily Gorbik
authored andcommitted
s390/zcrypt: Move inline function rng_type6cprb_msgx from header to code
Function rng_type6cprb_msgx() is only used once and thus no need to provide it in header file any more. Move it at the place within the code where it is used. Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent fa8be59 commit 23a4757

2 files changed

Lines changed: 49 additions & 49 deletions

File tree

drivers/s390/crypto/zcrypt_msgtype6.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,55 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
12501250
return rc;
12511251
}
12521252

1253+
/**
1254+
* Prepare a type6 CPRB message for random number generation
1255+
*
1256+
* @ap_dev: AP device pointer
1257+
* @ap_msg: pointer to AP message
1258+
*/
1259+
static inline void rng_type6cprb_msgx(struct ap_message *ap_msg,
1260+
unsigned int random_number_length,
1261+
unsigned int *domain)
1262+
{
1263+
struct {
1264+
struct type6_hdr hdr;
1265+
struct CPRBX cprbx;
1266+
char function_code[2];
1267+
short int rule_length;
1268+
char rule[8];
1269+
short int verb_length;
1270+
short int key_length;
1271+
} __packed * msg = ap_msg->msg;
1272+
static struct type6_hdr static_type6_hdrX = {
1273+
.type = 0x06,
1274+
.offset1 = 0x00000058,
1275+
.agent_id = {'C', 'A'},
1276+
.function_code = {'R', 'L'},
1277+
.tocardlen1 = sizeof(*msg) - sizeof(msg->hdr),
1278+
.fromcardlen1 = sizeof(*msg) - sizeof(msg->hdr),
1279+
};
1280+
static struct CPRBX local_cprbx = {
1281+
.cprb_len = 0x00dc,
1282+
.cprb_ver_id = 0x02,
1283+
.func_id = {0x54, 0x32},
1284+
.req_parml = sizeof(*msg) - sizeof(msg->hdr) -
1285+
sizeof(msg->cprbx),
1286+
.rpl_msgbl = sizeof(*msg) - sizeof(msg->hdr),
1287+
};
1288+
1289+
msg->hdr = static_type6_hdrX;
1290+
msg->hdr.fromcardlen2 = random_number_length;
1291+
msg->cprbx = local_cprbx;
1292+
msg->cprbx.rpl_datal = random_number_length;
1293+
memcpy(msg->function_code, msg->hdr.function_code, 0x02);
1294+
msg->rule_length = 0x0a;
1295+
memcpy(msg->rule, "RANDOM ", 8);
1296+
msg->verb_length = 0x02;
1297+
msg->key_length = 0x02;
1298+
ap_msg->len = sizeof(*msg);
1299+
*domain = (unsigned short)msg->cprbx.domain;
1300+
}
1301+
12531302
/*
12541303
* Prepare a CEXXC get random request ap message.
12551304
* This function assumes that ap_msg has been initialized with

drivers/s390/crypto/zcrypt_msgtype6.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -110,55 +110,6 @@ int prep_rng_ap_msg(struct ap_message *ap_msg,
110110
int speed_idx_cca(int);
111111
int speed_idx_ep11(int);
112112

113-
/**
114-
* Prepare a type6 CPRB message for random number generation
115-
*
116-
* @ap_dev: AP device pointer
117-
* @ap_msg: pointer to AP message
118-
*/
119-
static inline void rng_type6cprb_msgx(struct ap_message *ap_msg,
120-
unsigned int random_number_length,
121-
unsigned int *domain)
122-
{
123-
struct {
124-
struct type6_hdr hdr;
125-
struct CPRBX cprbx;
126-
char function_code[2];
127-
short int rule_length;
128-
char rule[8];
129-
short int verb_length;
130-
short int key_length;
131-
} __packed * msg = ap_msg->msg;
132-
static struct type6_hdr static_type6_hdrX = {
133-
.type = 0x06,
134-
.offset1 = 0x00000058,
135-
.agent_id = {'C', 'A'},
136-
.function_code = {'R', 'L'},
137-
.tocardlen1 = sizeof(*msg) - sizeof(msg->hdr),
138-
.fromcardlen1 = sizeof(*msg) - sizeof(msg->hdr),
139-
};
140-
static struct CPRBX local_cprbx = {
141-
.cprb_len = 0x00dc,
142-
.cprb_ver_id = 0x02,
143-
.func_id = {0x54, 0x32},
144-
.req_parml = sizeof(*msg) - sizeof(msg->hdr) -
145-
sizeof(msg->cprbx),
146-
.rpl_msgbl = sizeof(*msg) - sizeof(msg->hdr),
147-
};
148-
149-
msg->hdr = static_type6_hdrX;
150-
msg->hdr.fromcardlen2 = random_number_length;
151-
msg->cprbx = local_cprbx;
152-
msg->cprbx.rpl_datal = random_number_length;
153-
memcpy(msg->function_code, msg->hdr.function_code, 0x02);
154-
msg->rule_length = 0x0a;
155-
memcpy(msg->rule, "RANDOM ", 8);
156-
msg->verb_length = 0x02;
157-
msg->key_length = 0x02;
158-
ap_msg->len = sizeof(*msg);
159-
*domain = (unsigned short)msg->cprbx.domain;
160-
}
161-
162113
void zcrypt_msgtype6_init(void);
163114
void zcrypt_msgtype6_exit(void);
164115

0 commit comments

Comments
 (0)