Simplify code a bit.

MFC after:	1 week
This commit is contained in:
Pawel Jakub Dawidek 2010-09-23 11:26:38 +00:00
parent 1f0fb66f30
commit 745eb0ccb6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213064
2 changed files with 5 additions and 10 deletions

View File

@ -69,14 +69,12 @@ aesni_identify(driver_t *drv, device_t parent)
static int static int
aesni_probe(device_t dev) aesni_probe(device_t dev)
{ {
char capp[32];
if ((cpu_feature2 & CPUID2_AESNI) == 0) { if ((cpu_feature2 & CPUID2_AESNI) == 0) {
device_printf(dev, "No AESNI support.\n"); device_printf(dev, "No AESNI support.\n");
return (EINVAL); return (EINVAL);
} }
strlcpy(capp, "AES-CBC", sizeof(capp)); device_set_desc_copy(dev, "AES-CBC");
device_set_desc_copy(dev, capp);
return (0); return (0);
} }

View File

@ -147,15 +147,13 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
int error, allocated; int error, allocated;
buf = aesni_cipher_alloc(enccrd, crp, &allocated); buf = aesni_cipher_alloc(enccrd, crp, &allocated);
if (buf == NULL) { if (buf == NULL)
error = ENOMEM; return (ENOMEM);
goto out;
}
td = curthread; td = curthread;
error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL); error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
if (error != 0) if (error != 0)
goto out1; goto out;
if ((enccrd->crd_flags & CRD_F_ENCRYPT) != 0) { if ((enccrd->crd_flags & CRD_F_ENCRYPT) != 0) {
if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0) if ((enccrd->crd_flags & CRD_F_IV_EXPLICIT) != 0)
@ -184,11 +182,10 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
crypto_copydata(crp->crp_flags, crp->crp_buf, crypto_copydata(crp->crp_flags, crp->crp_buf,
enccrd->crd_skip + enccrd->crd_len - AES_BLOCK_LEN, enccrd->crd_skip + enccrd->crd_len - AES_BLOCK_LEN,
AES_BLOCK_LEN, ses->iv); AES_BLOCK_LEN, ses->iv);
out1: out:
if (allocated) { if (allocated) {
bzero(buf, enccrd->crd_len); bzero(buf, enccrd->crd_len);
free(buf, M_AESNI); free(buf, M_AESNI);
} }
out:
return (error); return (error);
} }