Return a bio pointer instead of accepting a struct bio ** argument. No functionality has been changed. Suggested-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- block/blk-crypto-fallback.c | 16 ++++++++-------- block/blk-crypto-internal.h | 8 ++++---- block/blk-crypto.c | 6 ++++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 98bba0cf89cc..bd668a52817d 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -484,7 +484,7 @@ static void blk_crypto_fallback_decrypt_endio(struct bio *bio) /** * blk_crypto_fallback_bio_prep - Prepare a bio to use fallback en/decryption * - * @bio_ptr: pointer to the bio to prepare + * @bio: bio to prepare * * If bio is doing a WRITE operation, this splits the bio into two parts if it's * too big (see blk_crypto_fallback_split_bio_if_needed()). It then allocates a @@ -499,28 +499,28 @@ static void blk_crypto_fallback_decrypt_endio(struct bio *bio) * of the stack except for blk-integrity (blk-integrity and blk-crypto are not * currently supported together). * - * Return: true on success. Sets bio->bi_status and returns false on error. + * Return: a bio pointer on success; %NULL upon failure. Sets bio->bi_status on + * error. */ -bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr) +struct bio *blk_crypto_fallback_bio_prep(struct bio *bio) { - struct bio *bio = *bio_ptr; struct bio_crypt_ctx *bc = bio->bi_crypt_context; struct bio_fallback_crypt_ctx *f_ctx; if (WARN_ON_ONCE(!tfms_inited[bc->bc_key->crypto_cfg.crypto_mode])) { /* User didn't call blk_crypto_start_using_key() first */ bio->bi_status = BLK_STS_IOERR; - return false; + return NULL; } if (!__blk_crypto_cfg_supported(blk_crypto_fallback_profile, &bc->bc_key->crypto_cfg)) { bio->bi_status = BLK_STS_NOTSUPP; - return false; + return NULL; } if (bio_data_dir(bio) == WRITE) - return blk_crypto_fallback_encrypt_bio(bio_ptr); + return blk_crypto_fallback_encrypt_bio(&bio) ? bio : NULL; /* * bio READ case: Set up a f_ctx in the bio's bi_private and set the @@ -535,7 +535,7 @@ bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr) bio->bi_end_io = blk_crypto_fallback_decrypt_endio; bio_crypt_free_ctx(bio); - return true; + return bio; } int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key) diff --git a/block/blk-crypto-internal.h b/block/blk-crypto-internal.h index e2fd5a3221d3..212e5bbfc95f 100644 --- a/block/blk-crypto-internal.h +++ b/block/blk-crypto-internal.h @@ -219,7 +219,7 @@ static inline int blk_crypto_rq_bio_prep(struct request *rq, struct bio *bio, int blk_crypto_fallback_start_using_mode(enum blk_crypto_mode_num mode_num); -bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr); +struct bio *blk_crypto_fallback_bio_prep(struct bio *bio); int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key); @@ -232,11 +232,11 @@ blk_crypto_fallback_start_using_mode(enum blk_crypto_mode_num mode_num) return -ENOPKG; } -static inline bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr) +static inline struct bio *blk_crypto_fallback_bio_prep(struct bio *bio) { pr_warn_once("crypto API fallback disabled; failing request.\n"); - (*bio_ptr)->bi_status = BLK_STS_NOTSUPP; - return false; + bio->bi_status = BLK_STS_NOTSUPP; + return NULL; } static inline int diff --git a/block/blk-crypto.c b/block/blk-crypto.c index 84efb65fc51c..4bf8c212aee8 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -281,6 +281,7 @@ void __blk_crypto_free_request(struct request *rq) */ struct bio *__blk_crypto_bio_prep(struct bio *bio) { + struct bio *new_bio; const struct blk_crypto_key *bc_key = bio->bi_crypt_context->bc_key; /* Error if bio has no data. */ @@ -301,8 +302,9 @@ struct bio *__blk_crypto_bio_prep(struct bio *bio) if (blk_crypto_config_supported_natively(bio->bi_bdev, &bc_key->crypto_cfg)) return bio; - if (blk_crypto_fallback_bio_prep(&bio)) - return bio; + new_bio = blk_crypto_fallback_bio_prep(bio); + if (new_bio) + return new_bio; fail: bio_endio(bio); return NULL;