Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1853833imm; Tue, 2 Oct 2018 15:22:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ZVqjCjFikYJIov03+28lb2ViQFfygd0cL0xbcqGg/z8Egwg/Qe6S5mR9u5ewGJYIZy0wb X-Received: by 2002:a63:4860:: with SMTP id x32-v6mr16086566pgk.375.1538518963999; Tue, 02 Oct 2018 15:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538518963; cv=none; d=google.com; s=arc-20160816; b=pcCNiidNgszdynnouwyHb7OuhW1ITwQGfr7RKZWdGgvoNFRrLCBOEPrmnBF/ITBkJ2 Q7io6beE6OazT7OapITPTVhn2el1JmoZ8/w6dlbLovNY87719VsBwWmApTLMDQSWvw4Y Skr+zumrE0tgZVLWY14pW69pEL2klKjkogla60L0773ChGJU8s6ccGn5sTkGoERq76Wy ylp/j3RU+35W5QenxzNCSJ9LAStDJVREOPvN5GJCCJ26jTEiOMBy52YM95MDKwdsp9ly 9n+9Rf5aOLT8+9tfwGWuMWxauqOTbngWt6g5BPj9U51e5vMgAXIXas7Vskeu8rGCDyRv CY0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=FygyPVxby0KPbnU/slZqgrgrOyyCkhv2g/IDUsh5K4k=; b=TN9h/QL7y3nqAEd4AUYJrKkHFEp3RZNtfqK7tjMWFvbEXf50dJxSH5aEeEAwHmduiA 7dNKq8WEWvpiPHEnrZwdLdMvQzo/r3ehGKgZbcs32VohkmaviIxb0H5/2zOIQgnXPNBW geCMngVln9RDYX2kHQzwMDKzVMxEcqMTCXG4ZiKROH5/ri+Wd2pEOELrYV5Z6cs0Q71R yDt5cXxLk4TlwzIgHToW8bNtRYUTN2qhLui3FA2yy/rggHE0ALoAFMLqrqTeteOvBhe5 FqMT8Kqw93fQ89yZOO0SqGKmSHJUozHkCopr5QkZDVmixC2cH4yJ7sZmQzBREZa3uHUb IEnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pYk3rivE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19-v6si16649825plp.304.2018.10.02.15.22.29; Tue, 02 Oct 2018 15:22:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pYk3rivE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727775AbeJCFGA (ORCPT + 99 others); Wed, 3 Oct 2018 01:06:00 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:54035 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725198AbeJCFF7 (ORCPT ); Wed, 3 Oct 2018 01:05:59 -0400 Received: by mail-io1-f74.google.com with SMTP id t22-v6so2398315ioc.20 for ; Tue, 02 Oct 2018 15:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FygyPVxby0KPbnU/slZqgrgrOyyCkhv2g/IDUsh5K4k=; b=pYk3rivEpG+UC2eGjjx43jioHq9lYfeMEH2uPSwRJH2MRnJQ7zVk1NFafY50Ii6AjJ 35efI/s+N45PM6lnluEIdLKkNWywn2SQeZVul1VZHFWynMcc6IF3pAASyS0STkW+hVYr 2kn/Vm/Nc/OiUULAgIEPVBBlF327mK6HpbFGZJSpDU6Juy7CpssI5Xf6UIM9XNb+mXuv 3qgEHuDu4WE7VvvXHV4GHMkivpL22GQCiyqGcuYdf22bJ2lXA+98GBuiz2bZYfxWpw0c wnJNUK+cK2s/zTdvWPVZvCj17M1nvWVPkkmsd6ekVuVUVHOOl773ns1WmSbUcT3Dp/42 5lqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FygyPVxby0KPbnU/slZqgrgrOyyCkhv2g/IDUsh5K4k=; b=E005KQ0EX2hgT4idUQb+eU6ZwkMr7maHkj4jLcqCLy/d0mzSuF6i3XFN2i7/BVNGrN +PbjKP9hK1Dr/Ug3dALp2trg1vLcA2sawPphNOUP8ovlysLVK4utC0bVrnyB+v5T18Vr 1A9FdFfBe/VnX1qToeGto5i4RD3EivN1yVtkz9cGpPtY1QWrrgFB4lJz4VY7OaBNRB0v ls0tbwpS+D7SpEw1RbBz78erHyy+qOSQ3mRij94qusrQBNBeqZddqAKHlX8R+zvM3Zk3 JKlsZ7x24m6rxCeeGXyC/bYIutl7cB1t9l4emd/mMEw9dhKRQ805QvEXNrA37mAQOcCk tZzA== X-Gm-Message-State: ABuFfoidaeSpEJaXO4TNqsUDsBctj6nVyr14gs3Xl3+/I+VUmMwVxmiI AkASGsbiHlsxieqGrnCfxHMoD7ZL X-Received: by 2002:a24:6b97:: with SMTP id v145-v6mr3451471itc.40.1538518825207; Tue, 02 Oct 2018 15:20:25 -0700 (PDT) Date: Tue, 2 Oct 2018 15:18:54 -0700 In-Reply-To: <20181002221903.19476-1-rkir@google.com> Message-Id: <20181002221903.19476-6-rkir@google.com> Mime-Version: 1.0 References: <20181002221903.19476-1-rkir@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH 06/15] platform: goldfish: pipe: Move memory allocation from probe to init From: rkir@google.com To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, tkjos@google.com, Roman Kiryanov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Kiryanov There will be two separate init functions for v1 and v2 (different driver versions) and they will allocate different state. Signed-off-by: Roman Kiryanov --- drivers/platform/goldfish/goldfish_pipe.c | 42 +++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index bc431f04c4cf..445c0c0c66c4 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -208,8 +208,6 @@ struct goldfish_pipe_dev { struct device *pdev_dev; /* Some device-specific data */ - int irq; - int version; unsigned char __iomem *base; /* an irq tasklet to run goldfish_interrupt_task */ @@ -817,14 +815,23 @@ static void write_pa_addr(void *addr, void __iomem *portl, void __iomem *porth) } static int goldfish_pipe_device_init(struct platform_device *pdev, - struct goldfish_pipe_dev *dev) + char __iomem *base, + int irq) { + struct goldfish_pipe_dev *dev; int err; + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + + dev->magic = &goldfish_pipe_device_deinit; + spin_lock_init(&dev->lock); + tasklet_init(&dev->irq_tasklet, &goldfish_interrupt_task, (unsigned long)dev); - err = devm_request_irq(&pdev->dev, dev->irq, + err = devm_request_irq(&pdev->dev, irq, goldfish_pipe_interrupt, IRQF_SHARED, "goldfish_pipe", dev); if (err) { @@ -839,6 +846,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev, return err; } + dev->base = base; dev->pdev_dev = &pdev->dev; dev->first_signalled_pipe = NULL; dev->pipes_capacity = INITIAL_PIPES_CAPACITY; @@ -892,22 +900,18 @@ static void goldfish_pipe_device_deinit(struct platform_device *pdev, static int goldfish_pipe_probe(struct platform_device *pdev) { struct resource *r; - struct goldfish_pipe_dev *dev; - - dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; - - dev->magic = &goldfish_pipe_device_deinit; - spin_lock_init(&dev->lock); + char __iomem *base; + int irq; + int version; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r || resource_size(r) < PAGE_SIZE) { dev_err(&pdev->dev, "can't allocate i/o page\n"); return -EINVAL; } - dev->base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); - if (!dev->base) { + + base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); + if (!base) { dev_err(&pdev->dev, "ioremap failed\n"); return -EINVAL; } @@ -916,7 +920,7 @@ static int goldfish_pipe_probe(struct platform_device *pdev) if (!r) return -EINVAL; - dev->irq = r->start; + irq = r->start; /* * Exchange the versions with the host device @@ -925,12 +929,12 @@ static int goldfish_pipe_probe(struct platform_device *pdev) * reading device version back: this allows the host implementation to * detect the old driver (if there was no version write before read). */ - writel(PIPE_DRIVER_VERSION, dev->base + PIPE_REG_VERSION); - dev->version = readl(dev->base + PIPE_REG_VERSION); - if (WARN_ON(dev->version < PIPE_CURRENT_DEVICE_VERSION)) + writel(PIPE_DRIVER_VERSION, base + PIPE_REG_VERSION); + version = readl(base + PIPE_REG_VERSION); + if (WARN_ON(version < PIPE_CURRENT_DEVICE_VERSION)) return -EINVAL; - return goldfish_pipe_device_init(pdev, dev); + return goldfish_pipe_device_init(pdev, base, irq); } static int goldfish_pipe_remove(struct platform_device *pdev) -- 2.19.0.605.g01d371f741-goog