[PATCH 1/3] blk-crypto: pass a gendisk to blk_crypto_sysfs_register

Christoph Hellwig
2022-11-05T08:08:28Z

Prepare for changes to the block layer sysfs handling by passing the
readily available gendisk to blk_crypto_sysfs_register.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-crypto-internal.h | 4 ++--
block/blk-crypto-sysfs.c | 3 ++-
block/blk-sysfs.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/blk-crypto-internal.h b/block/blk-crypto-internal.h
index e6818ffaddbf8..32990299dace1 100644
--- a/block/blk-crypto-internal.h
+++ b/block/blk-crypto-internal.h
@@ -21,7 +21,7 @@ extern const struct blk_crypto_mode blk_crypto_modes[];

#ifdef CONFIG_BLK_INLINE_ENCRYPTION

-int blk_crypto_sysfs_register(struct request_queue *q);
+int blk_crypto_sysfs_register(struct gendisk *disk);

void blk_crypto_sysfs_unregister(struct request_queue *q);

@@ -67,7 +67,7 @@ static inline bool blk_crypto_rq_is_encrypted(struct request *rq)

#else /* CONFIG_BLK_INLINE_ENCRYPTION */

-static inline int blk_crypto_sysfs_register(struct request_queue *q)
+static inline int blk_crypto_sysfs_register(struct gendisk *disk)
{
return 0;
}
diff --git a/block/blk-crypto-sysfs.c b/block/blk-crypto-sysfs.c
index fd93bd2f33b75..a638a2eecfc89 100644
--- a/block/blk-crypto-sysfs.c
+++ b/block/blk-crypto-sysfs.c
@@ -126,8 +126,9 @@ static struct kobj_type blk_crypto_ktype = {
* If the request_queue has a blk_crypto_profile, create the "crypto"
* subdirectory in sysfs (/sys/block/$disk/queue/crypto/).
*/
-int blk_crypto_sysfs_register(struct request_queue *q)
+int blk_crypto_sysfs_register(struct gendisk *disk)
{
+ struct request_queue *q = disk->queue;
struct blk_crypto_kobj *obj;
int err;

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 02e94c4beff17..440149d0e21b9 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -836,7 +836,7 @@ int blk_register_queue(struct gendisk *disk)
goto put_dev;
}

- ret = blk_crypto_sysfs_register(q);
+ ret = blk_crypto_sysfs_register(disk);
if (ret)
goto put_dev;

--
2.30.2