Skip to content

Commit 91b6ff5

Browse files
committed
crypto: algapi - Add driver template support to crypto_inst_setname
Add support to crypto_inst_setname for having a driver template name that differs from the algorithm template name. Signed-off-by: Herbert Xu <[email protected]>
1 parent 32a9fd8 commit 91b6ff5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crypto/algapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,20 +923,20 @@ const char *crypto_attr_alg_name(struct rtattr *rta)
923923
}
924924
EXPORT_SYMBOL_GPL(crypto_attr_alg_name);
925925

926-
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
927-
struct crypto_alg *alg)
926+
int __crypto_inst_setname(struct crypto_instance *inst, const char *name,
927+
const char *driver, struct crypto_alg *alg)
928928
{
929929
if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME, "%s(%s)", name,
930930
alg->cra_name) >= CRYPTO_MAX_ALG_NAME)
931931
return -ENAMETOOLONG;
932932

933933
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s(%s)",
934-
name, alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
934+
driver, alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
935935
return -ENAMETOOLONG;
936936

937937
return 0;
938938
}
939-
EXPORT_SYMBOL_GPL(crypto_inst_setname);
939+
EXPORT_SYMBOL_GPL(__crypto_inst_setname);
940940

941941
void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen)
942942
{

include/crypto/algapi.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,16 @@ void *crypto_spawn_tfm2(struct crypto_spawn *spawn);
146146
struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
147147
int crypto_check_attr_type(struct rtattr **tb, u32 type, u32 *mask_ret);
148148
const char *crypto_attr_alg_name(struct rtattr *rta);
149-
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
150-
struct crypto_alg *alg);
149+
int __crypto_inst_setname(struct crypto_instance *inst, const char *name,
150+
const char *driver, struct crypto_alg *alg);
151+
152+
#define crypto_inst_setname(inst, name, ...) \
153+
CONCATENATE(crypto_inst_setname_, COUNT_ARGS(__VA_ARGS__))( \
154+
inst, name, ##__VA_ARGS__)
155+
#define crypto_inst_setname_1(inst, name, alg) \
156+
__crypto_inst_setname(inst, name, name, alg)
157+
#define crypto_inst_setname_2(inst, name, driver, alg) \
158+
__crypto_inst_setname(inst, name, driver, alg)
151159

152160
void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen);
153161
int crypto_enqueue_request(struct crypto_queue *queue,

0 commit comments

Comments
 (0)