Print this page
6640 dca gets the instance number a lot, never actually uses it

@@ -412,16 +412,11 @@
         0,                              /* pi_logical_provider_count */
         NULL                            /* pi_logical_providers */
 };
 
 /* Convenience macros */
-/* Retrieve the softc and instance number from a SPI crypto context */
-#define DCA_SOFTC_FROM_CTX(ctx, softc, instance) {              \
-        (softc) = (dca_t *)(ctx)->cc_provider;                  \
-        (instance) = ddi_get_instance((softc)->dca_dip);        \
-}
-
+#define DCA_SOFTC_FROM_CTX(ctx) ((dca_t *)(ctx)->cc_provider)
 #define DCA_MECH_FROM_CTX(ctx) \
         (((dca_request_t *)(ctx)->cc_provider_private)->dr_ctx.ctx_cm_type)
 
 static int dca_bindchains_one(dca_request_t *reqp, size_t cnt, int dr_offset,
     caddr_t kaddr, ddi_dma_handle_t handle, uint_t flags,

@@ -3692,15 +3687,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_encrypt_init: started");
 
         /* check mechanism */
         switch (mechanism->cm_type) {
         case DES_CBC_MECH_INFO_TYPE:

@@ -3735,18 +3727,15 @@
 dca_encrypt(crypto_ctx_t *ctx, crypto_data_t *plaintext,
     crypto_data_t *ciphertext, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_encrypt: started");
 
         /* handle inplace ops */
         if (!ciphertext) {
                 dca_request_t *reqp = ctx->cc_provider_private;

@@ -3790,18 +3779,15 @@
 dca_encrypt_update(crypto_ctx_t *ctx, crypto_data_t *plaintext,
     crypto_data_t *ciphertext, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_encrypt_update: started");
 
         /* handle inplace ops */
         if (!ciphertext) {
                 dca_request_t *reqp = ctx->cc_provider_private;

@@ -3836,18 +3822,15 @@
 dca_encrypt_final(crypto_ctx_t *ctx, crypto_data_t *ciphertext,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_encrypt_final: started");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case DES_CBC_MECH_INFO_TYPE:

@@ -3926,15 +3909,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_decrypt_init: started");
 
         /* check mechanism */
         switch (mechanism->cm_type) {
         case DES_CBC_MECH_INFO_TYPE:

@@ -3969,18 +3949,15 @@
 dca_decrypt(crypto_ctx_t *ctx, crypto_data_t *ciphertext,
     crypto_data_t *plaintext, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_decrypt: started");
 
         /* handle inplace ops */
         if (!plaintext) {
                 dca_request_t *reqp = ctx->cc_provider_private;

@@ -4025,18 +4002,15 @@
 dca_decrypt_update(crypto_ctx_t *ctx, crypto_data_t *ciphertext,
     crypto_data_t *plaintext, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_decrypt_update: started");
 
         /* handle inplace ops */
         if (!plaintext) {
                 dca_request_t *reqp = ctx->cc_provider_private;

@@ -4071,18 +4045,15 @@
 dca_decrypt_final(crypto_ctx_t *ctx, crypto_data_t *plaintext,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_decrypt_final: started");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case DES_CBC_MECH_INFO_TYPE:

@@ -4165,15 +4136,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign_init: started\n");
 
         if (ctx_template != NULL)
                 return (CRYPTO_ARGUMENTS_BAD);
 

@@ -4206,18 +4174,15 @@
 dca_sign(crypto_ctx_t *ctx, crypto_data_t *data,
     crypto_data_t *signature, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign: started\n");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case RSA_PKCS_MECH_INFO_TYPE:

@@ -4243,18 +4208,15 @@
 dca_sign_update(crypto_ctx_t *ctx, crypto_data_t *data,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign_update: started\n");
 
         cmn_err(CE_WARN, "dca_sign_update: unexpected mech type "
             "0x%llx\n", (unsigned long long)DCA_MECH_FROM_CTX(ctx));
 

@@ -4268,18 +4230,15 @@
 dca_sign_final(crypto_ctx_t *ctx, crypto_data_t *signature,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign_final: started\n");
 
         cmn_err(CE_WARN, "dca_sign_final: unexpected mech type "
             "0x%llx\n", (unsigned long long)DCA_MECH_FROM_CTX(ctx));
 

@@ -4330,15 +4289,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign_recover_init: started\n");
 
         if (ctx_template != NULL)
                 return (CRYPTO_ARGUMENTS_BAD);
 

@@ -4367,18 +4323,15 @@
 dca_sign_recover(crypto_ctx_t *ctx, crypto_data_t *data,
     crypto_data_t *signature, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_sign_recover: started\n");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case RSA_PKCS_MECH_INFO_TYPE:

@@ -4402,14 +4355,11 @@
     crypto_key_t *key, crypto_data_t *data, crypto_data_t *signature,
     crypto_spi_ctx_template_t ctx_template, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc = (dca_t *)provider;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        instance = ddi_get_instance(softc->dca_dip);
         DBG(softc, DENTRY, "dca_sign_recover_atomic: started\n");
 
         if (ctx_template != NULL)
                 return (CRYPTO_ARGUMENTS_BAD);
 

@@ -4441,15 +4391,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify_init: started\n");
 
         if (ctx_template != NULL)
                 return (CRYPTO_ARGUMENTS_BAD);
 

@@ -4482,18 +4429,15 @@
 dca_verify(crypto_ctx_t *ctx, crypto_data_t *data, crypto_data_t *signature,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify: started\n");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case RSA_PKCS_MECH_INFO_TYPE:

@@ -4519,18 +4463,15 @@
 dca_verify_update(crypto_ctx_t *ctx, crypto_data_t *data,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify_update: started\n");
 
         cmn_err(CE_WARN, "dca_verify_update: unexpected mech type "
             "0x%llx\n", (unsigned long long)DCA_MECH_FROM_CTX(ctx));
 

@@ -4544,18 +4485,15 @@
 dca_verify_final(crypto_ctx_t *ctx, crypto_data_t *signature,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify_final: started\n");
 
         cmn_err(CE_WARN, "dca_verify_final: unexpected mech type "
             "0x%llx\n", (unsigned long long)DCA_MECH_FROM_CTX(ctx));
 

@@ -4606,15 +4544,12 @@
     crypto_key_t *key, crypto_spi_ctx_template_t ctx_template,
     crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify_recover_init: started\n");
 
         if (ctx_template != NULL)
                 return (CRYPTO_ARGUMENTS_BAD);
 

@@ -4642,18 +4577,15 @@
 dca_verify_recover(crypto_ctx_t *ctx, crypto_data_t *signature,
     crypto_data_t *data, crypto_req_handle_t req)
 {
         int error = CRYPTO_MECHANISM_INVALID;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
         if (!ctx || !ctx->cc_provider || !ctx->cc_provider_private)
                 return (CRYPTO_OPERATION_NOT_INITIALIZED);
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_verify_recover: started\n");
 
         /* check mechanism */
         switch (DCA_MECH_FROM_CTX(ctx)) {
         case RSA_PKCS_MECH_INFO_TYPE:

@@ -4713,14 +4645,11 @@
     crypto_session_id_t session_id,
     uchar_t *buf, size_t len, crypto_req_handle_t req)
 {
         int error = CRYPTO_FAILED;
         dca_t *softc = (dca_t *)provider;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        instance = ddi_get_instance(softc->dca_dip);
         DBG(softc, DENTRY, "dca_generate_random: started");
 
         error = dca_rng(softc, buf, len, req);
 
         DBG(softc, DENTRY, "dca_generate_random: done, err = 0x%x", error);

@@ -4735,15 +4664,12 @@
 int
 dca_free_context(crypto_ctx_t *ctx)
 {
         int error = CRYPTO_SUCCESS;
         dca_t *softc;
-        /* LINTED E_FUNC_SET_NOT_USED */
-        int instance;
 
-        /* extract softc and instance number from context */
-        DCA_SOFTC_FROM_CTX(ctx, softc, instance);
+        softc = DCA_SOFTC_FROM_CTX(ctx);
         DBG(softc, DENTRY, "dca_free_context: entered");
 
         if (ctx->cc_provider_private == NULL)
                 return (error);