Skip to content

Commit e8989a4

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
char: xilinx_hwicap: Fold hwicap_remove() into only caller
hwicap_remove() is only called by hwicap_drv_remove(). Simplify by unrolling the former into the latter function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Michal Simek <michal.simek@amd.com> Message-ID: <20230605092047.50472-1-u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 303c9c6 commit e8989a4

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

drivers/char/xilinx_hwicap/xilinx_hwicap.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -721,27 +721,6 @@ static struct hwicap_driver_config fifo_icap_config = {
721721
.reset = fifo_icap_reset,
722722
};
723723

724-
static int hwicap_remove(struct device *dev)
725-
{
726-
struct hwicap_drvdata *drvdata;
727-
728-
drvdata = dev_get_drvdata(dev);
729-
730-
if (!drvdata)
731-
return 0;
732-
733-
device_destroy(icap_class, drvdata->devt);
734-
cdev_del(&drvdata->cdev);
735-
iounmap(drvdata->base_address);
736-
release_mem_region(drvdata->mem_start, drvdata->mem_size);
737-
kfree(drvdata);
738-
739-
mutex_lock(&icap_sem);
740-
probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0;
741-
mutex_unlock(&icap_sem);
742-
return 0; /* success */
743-
}
744-
745724
#ifdef CONFIG_OF
746725
static int hwicap_of_probe(struct platform_device *op,
747726
const struct hwicap_driver_config *config)
@@ -827,7 +806,24 @@ static int hwicap_drv_probe(struct platform_device *pdev)
827806

828807
static int hwicap_drv_remove(struct platform_device *pdev)
829808
{
830-
return hwicap_remove(&pdev->dev);
809+
struct device *dev = &pdev->dev;
810+
struct hwicap_drvdata *drvdata;
811+
812+
drvdata = dev_get_drvdata(dev);
813+
if (!drvdata)
814+
return 0;
815+
816+
device_destroy(icap_class, drvdata->devt);
817+
cdev_del(&drvdata->cdev);
818+
iounmap(drvdata->base_address);
819+
release_mem_region(drvdata->mem_start, drvdata->mem_size);
820+
kfree(drvdata);
821+
822+
mutex_lock(&icap_sem);
823+
probed_devices[MINOR(dev->devt)-XHWICAP_MINOR] = 0;
824+
mutex_unlock(&icap_sem);
825+
826+
return 0;
831827
}
832828

833829
#ifdef CONFIG_OF

0 commit comments

Comments
 (0)