]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nvme-apple: stop casting function pointer signatures
authorChristoph Hellwig <hch@lst.de>
Fri, 15 Jul 2022 09:54:36 +0000 (11:54 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 2 Aug 2022 23:22:51 +0000 (17:22 -0600)
Casting function pointers breaks control flow enforcement and is
generally a horrible coding style.

Add two wrappers to get rid of these casts.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/apple.c

index 0510e8e07346280fc2c4b3ad5240238078bc5389..5fc5ea196b40072dc224c288a7ca8ef56aff5dee 100644 (file)
@@ -1219,6 +1219,11 @@ static void apple_nvme_async_probe(void *data, async_cookie_t cookie)
        nvme_put_ctrl(&anv->ctrl);
 }
 
+static void devm_apple_nvme_put_tag_set(void *data)
+{
+       blk_mq_free_tag_set(data);
+}
+
 static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 {
        int ret;
@@ -1235,8 +1240,7 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
        ret = blk_mq_alloc_tag_set(&anv->admin_tagset);
        if (ret)
                return ret;
-       ret = devm_add_action_or_reset(anv->dev,
-                                      (void (*)(void *))blk_mq_free_tag_set,
+       ret = devm_add_action_or_reset(anv->dev, devm_apple_nvme_put_tag_set,
                                       &anv->admin_tagset);
        if (ret)
                return ret;
@@ -1260,8 +1264,8 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
        ret = blk_mq_alloc_tag_set(&anv->tagset);
        if (ret)
                return ret;
-       ret = devm_add_action_or_reset(
-               anv->dev, (void (*)(void *))blk_mq_free_tag_set, &anv->tagset);
+       ret = devm_add_action_or_reset(anv->dev, devm_apple_nvme_put_tag_set,
+                                       &anv->tagset);
        if (ret)
                return ret;
 
@@ -1362,6 +1366,11 @@ static int apple_nvme_attach_genpd(struct apple_nvme *anv)
        return 0;
 }
 
+static void devm_apple_nvme_mempool_destroy(void *data)
+{
+       mempool_destroy(data);
+}
+
 static int apple_nvme_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -1459,8 +1468,8 @@ static int apple_nvme_probe(struct platform_device *pdev)
                ret = -ENOMEM;
                goto put_dev;
        }
-       ret = devm_add_action_or_reset(
-               anv->dev, (void (*)(void *))mempool_destroy, anv->iod_mempool);
+       ret = devm_add_action_or_reset(anv->dev,
+                       devm_apple_nvme_mempool_destroy, anv->iod_mempool);
        if (ret)
                goto put_dev;