Skip to content

Commit 08a7ead

Browse files
ebiggersstorulf
authored andcommitted
mmc: crypto: add mmc_from_crypto_profile()
Add a helper function that encapsulates a container_of expression. For now there is just one user but soon there will be more. Signed-off-by: Eric Biggers <ebiggers@google.com> Message-ID: <20241213041958.202565-7-ebiggers@kernel.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f2d3630 commit 08a7ead

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

drivers/mmc/host/cqhci-crypto.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ static const struct cqhci_crypto_alg_entry {
2525
static inline struct cqhci_host *
2626
cqhci_host_from_crypto_profile(struct blk_crypto_profile *profile)
2727
{
28-
struct mmc_host *mmc =
29-
container_of(profile, struct mmc_host, crypto_profile);
30-
31-
return mmc->cqe_private;
28+
return mmc_from_crypto_profile(profile)->cqe_private;
3229
}
3330

3431
static int cqhci_crypto_program_key(struct cqhci_host *cq_host,

include/linux/mmc/host.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,14 @@ static inline struct mmc_host *mmc_from_priv(void *priv)
590590
return container_of(priv, struct mmc_host, private);
591591
}
592592

593+
#ifdef CONFIG_MMC_CRYPTO
594+
static inline struct mmc_host *
595+
mmc_from_crypto_profile(struct blk_crypto_profile *profile)
596+
{
597+
return container_of(profile, struct mmc_host, crypto_profile);
598+
}
599+
#endif
600+
593601
#define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
594602

595603
#define mmc_dev(x) ((x)->parent)

0 commit comments

Comments
 (0)