Date: Tue, 5 Dec 2006 04:38:54 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 111105 for review Message-ID: <200612050438.kB54csFf049064@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=111105 Change 111105 by sam@sam_ebb on 2006/12/05 04:37:53 factor driver cleanup code into driver_finis Affected files ... .. //depot/projects/crypto/sys/opencrypto/crypto.c#3 edit Differences ... ==== //depot/projects/crypto/sys/opencrypto/crypto.c#3 (text+ko) ==== @@ -676,6 +676,27 @@ return err; } +static void +driver_finis(struct cryptocap *cap) +{ + u_int32_t ses, kops; + + CRYPTO_DRIVER_ASSERT(); + + ses = cap->cc_sessions; + kops = cap->cc_koperations; + bzero(cap, sizeof(*cap)); + if (ses != 0 || kops != 0) { + /* + * If there are pending sessions, + * just mark as invalid. + */ + cap->cc_flags |= CRYPTOCAP_F_CLEANUP; + cap->cc_sessions = ses; + cap->cc_koperations = kops; + } +} + /* * Unregister a crypto driver. If there are pending sessions using it, * leave enough information around so that subsequent calls using those @@ -686,7 +707,6 @@ crypto_unregister(u_int32_t driverid, int alg) { struct cryptocap *cap; - u_int32_t ses, kops; int i, err; CRYPTO_DRIVER_LOCK(); @@ -703,20 +723,8 @@ if (cap->cc_alg[i] != 0) break; - if (i == CRYPTO_ALGORITHM_MAX + 1) { - ses = cap->cc_sessions; - kops = cap->cc_koperations; - bzero(cap, sizeof(*cap)); - if (ses != 0 || kops != 0) { - /* - * If there are pending sessions, - * just mark as invalid. - */ - cap->cc_flags |= CRYPTOCAP_F_CLEANUP; - cap->cc_sessions = ses; - cap->cc_koperations = kops; - } - } + if (i == CRYPTO_ALGORITHM_MAX + 1) + driver_finis(cap); err = 0; } else err = EINVAL; @@ -736,28 +744,13 @@ crypto_unregister_all(u_int32_t driverid) { struct cryptocap *cap; - u_int32_t ses, kops; - int i, err; + int err; CRYPTO_DRIVER_LOCK(); cap = crypto_checkdriver(driverid); if (cap != NULL) { - for (i = CRYPTO_ALGORITHM_MIN; i <= CRYPTO_ALGORITHM_MAX; i++) { - cap->cc_alg[i] = 0; - cap->cc_max_op_len[i] = 0; - } - ses = cap->cc_sessions; - kops = cap->cc_koperations; - bzero(cap, sizeof(*cap)); - if (ses != 0 || kops != 0) { - /* - * If there are pending sessions, just mark as invalid. - */ - cap->cc_flags |= CRYPTOCAP_F_CLEANUP; - cap->cc_sessions = ses; - cap->cc_koperations = kops; - } + driver_finis(cap); err = 0; } else err = EINVAL;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612050438.kB54csFf049064>