[PATCH 08/21] platform: goldfish: pipe: Remove the goldfish_pipe_miscdev global variable

From: rkir
Date: Fri Sep 14 2018 - 13:52:23 EST


From: Roman Kiryanov <rkir@xxxxxxxxxx>

This is a series of patches to remove mutable global variables
to introduce another version of the pipe driver for the older
host interface. I don't want to have two driver states where
only one is used.

Signed-off-by: Roman Kiryanov <rkir@xxxxxxxxxx>
---
drivers/platform/goldfish/goldfish_pipe.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 8a5ce7c01f11..53832e46ad1a 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -245,6 +245,8 @@ struct goldfish_pipe_dev {
/* an irq tasklet to run goldfish_interrupt_task */
struct tasklet_struct irq_tasklet;

+ struct miscdevice miscdev;
+
/* DMA info */
size_t dma_alloc_total;
};
@@ -1093,11 +1095,14 @@ static const struct file_operations goldfish_pipe_fops = {
.compat_ioctl = goldfish_dma_ioctl,
};

-static struct miscdevice goldfish_pipe_miscdev = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = "goldfish_pipe",
- .fops = &goldfish_pipe_fops,
-};
+static void init_miscdevice(struct miscdevice *miscdev)
+{
+ memset(miscdev, 0, sizeof(*miscdev));
+
+ miscdev->minor = MISC_DYNAMIC_MINOR;
+ miscdev->name = "goldfish_pipe";
+ miscdev->fops = &goldfish_pipe_fops;
+}

static void write_pa_addr(void *addr, void __iomem *portl, void __iomem *porth)
{
@@ -1123,7 +1128,8 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
return err;
}

- err = misc_register(&goldfish_pipe_miscdev);
+ init_miscdevice(&dev->miscdev);
+ err = misc_register(&dev->miscdev);
if (err) {
dev_err(&pdev->dev, "unable to register v2 device\n");
return err;
@@ -1168,7 +1174,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)

static void goldfish_pipe_device_deinit(struct platform_device *pdev)
{
- misc_deregister(&goldfish_pipe_miscdev);
+ misc_deregister(&goldfish_pipe_dev.miscdev);
tasklet_kill(&goldfish_pipe_dev.irq_tasklet);
kfree(goldfish_pipe_dev.pipes);
free_page((unsigned long)goldfish_pipe_dev.buffers);
--
2.19.0.397.gdd90340f6a-goog