Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / mmc / core / crypto.c
blobfec4fbf16a5b648b6cca6d1236699586b1a24af6
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * MMC crypto engine (inline encryption) support
5 * Copyright 2020 Google LLC
6 */
8 #include <linux/blk-crypto.h>
9 #include <linux/mmc/host.h>
11 #include "core.h"
12 #include "crypto.h"
13 #include "queue.h"
15 void mmc_crypto_set_initial_state(struct mmc_host *host)
17 /* Reset might clear all keys, so reprogram all the keys. */
18 if (host->caps2 & MMC_CAP2_CRYPTO)
19 blk_crypto_reprogram_all_keys(&host->crypto_profile);
22 void mmc_crypto_setup_queue(struct request_queue *q, struct mmc_host *host)
24 if (host->caps2 & MMC_CAP2_CRYPTO)
25 blk_crypto_register(&host->crypto_profile, q);
27 EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
29 void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
31 struct request *req = mmc_queue_req_to_req(mqrq);
32 struct mmc_request *mrq = &mqrq->brq.mrq;
33 struct blk_crypto_keyslot *keyslot;
35 if (!req->crypt_ctx)
36 return;
38 mrq->crypto_ctx = req->crypt_ctx;
40 keyslot = req->crypt_keyslot;
41 if (keyslot)
42 mrq->crypto_key_slot = blk_crypto_keyslot_index(keyslot);
44 EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);