Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1083904imm; Fri, 14 Sep 2018 10:54:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYMJOkJ+pJC2yf21EzEBCGt6SJCshk++T30V5zpOGLAItLwYiBlWOY4jCbWRSyreWT9Rq6t X-Received: by 2002:a17:902:280a:: with SMTP id e10-v6mr13288398plb.187.1536947684785; Fri, 14 Sep 2018 10:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536947684; cv=none; d=google.com; s=arc-20160816; b=Iig13Yc9pStsVIOR23/KcI7s3tumPpnuWOkxBFdDqGFpAeOrOXgomGx3p1Q2QFW8Go UGHvE4oQD4E21cfNEOdr5w4+b6dd3GX36jPOipnidI5ZIc6s4GJolFsqBw67J16j2hfP gNawnfA4C6VTE5KndjhUPoKHwBiXxmFq+R31u6obajrr/Pk1Tpdt0ugZc6Evo/v3ezbd 7gXqNI8RdpxRIL3uRzsw63UDu8lV2ixMvGQwdA3tkyKT3wCKUf2IMbrV6VyLDCbhAhah 9qRtfRnQPIUxvu9JdCX44dJhV5ddovKt0XWdIynhH/FKX/KwCyvRmGOaNm7hSlSlLS7H +UMA== 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=Pyz7D5yfP+NwIsfgDDo9dr4phFAR5bRy/Nwh9J24D9w=; b=r7vIQFzjS2EHXGpZRzqxcC32nuP1fgUk7PyS+4CxqehyUin4Axe0QvIFiYRBkj7jI+ wtke7Lq0mEqq4OHPtaIjNbbPD+kM0sCOhGngP2YqDefhXg7f7cCMTqwicwiTLX/fMG6l s1SYirpqBeprC5VbQwimqexSBabEfOjCk0SnZHYqZGoxMhJYwVOwBhnJbw1WVJZmEFNr PH6ihj5XAxEldcJShD87mp8CX2KiBKZchwovasC+fSx2X5zb/siN5JIHnWWx/6sXR0I+ e6WP6DWeSz4cxaICBc2xmRVsMpvEa/jLgCg6GecsNhsCYsewfxAfk0K1IcKUIx2cjIgT MoBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rSJdTOI5; 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 q145-v6si8188518pfq.315.2018.09.14.10.54.29; Fri, 14 Sep 2018 10:54:44 -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=rSJdTOI5; 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 S1728405AbeINXIK (ORCPT + 99 others); Fri, 14 Sep 2018 19:08:10 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:33445 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbeINXIK (ORCPT ); Fri, 14 Sep 2018 19:08:10 -0400 Received: by mail-io1-f73.google.com with SMTP id s14-v6so9474312ioc.0 for ; Fri, 14 Sep 2018 10:52:36 -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=Pyz7D5yfP+NwIsfgDDo9dr4phFAR5bRy/Nwh9J24D9w=; b=rSJdTOI56AYlPv0a0lbKEP3DhTyzWOE3O+GLKpoQzMHIDyvUL0Yh1Ey9Q8WEvigOl1 41E1tDhDVYR9m6UViPPcHGViDQMVSFEpznHGIXphUKIy0v0lR6HvLyM0MeaZwzAL6ZmE CM8Wnzh4alQI88m32yevZYRwECbVcn/QbfQXk0FpSCaIly+Hfd04tIx3FxMEi3lLplSq 4Wk3F4T8umwmSKcgO0LblrW81bgKM2MaSIxY+SG3dE/ybk++FMFBfCL8r/oxxFpHzvSg zw9TsTNXSJBmwDFZQRLpg+0hAPnicUYtcxw96m459l6Iq++KUHgA/p4tQyHUqaBcRvHD 86QQ== 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=Pyz7D5yfP+NwIsfgDDo9dr4phFAR5bRy/Nwh9J24D9w=; b=iB/iAe8eoQsFDltli1SGVYqwQ0jxLrcv6oFi78AqOqJKnHPvDfUefNZcKbTQ8LVdqc 8X3CSydEBx7l/80u63ErC+7dCnBXvFltEiOqSJ4hNuapGzRkSbTUZa6yPki4rqwIy+5k kXNgPITUbF/dSnxqde6XrUWy+xtXJNoa2sg6P6Z1y61mMNV527m+PA9YuokINEoIGBmq IaFe7pwNT4f2zGeZjxCoOn+XSzp5BkNrRXTmLmw5MBK35xv/V1u0i/WoDQ3VKpd9SGj6 CsYpPzA3J0WlQOFBtGZ8+Yx7lqmZfjnPb8C+ViB6Q1FyLDZ380G/GHXrclrN3i4h0Lzp //yQ== X-Gm-Message-State: APzg51CpROfzNpaLHzpXQjb7/wWF1+Fcul38phAXurPEjA4lPKeZmUiW R1gedjCezvc17ChxzNexyj1yEJsD X-Received: by 2002:a6b:d91a:: with SMTP id r26-v6mr10362020ioc.60.1536947556132; Fri, 14 Sep 2018 10:52:36 -0700 (PDT) Date: Fri, 14 Sep 2018 10:51:12 -0700 In-Reply-To: <20180914175122.21036-1-rkir@google.com> Message-Id: <20180914175122.21036-11-rkir@google.com> Mime-Version: 1.0 References: <20180914175122.21036-1-rkir@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 11/21] platform: goldfish: pipe: Move memory allocation from probe to init From: rkir@google.com To: gregkh@linuxfoundation.org Cc: tkjos@google.com, linux-kernel@vger.kernel.org, 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 and they will allocate different state. Signed-off-by: Roman Kiryanov --- drivers/platform/goldfish/goldfish_pipe_v2.c | 41 +++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe_v2.c b/drivers/platform/goldfish/goldfish_pipe_v2.c index c68035be4389..ccde28abcb24 100644 --- a/drivers/platform/goldfish/goldfish_pipe_v2.c +++ b/drivers/platform/goldfish/goldfish_pipe_v2.c @@ -241,8 +241,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 */ @@ -1125,14 +1123,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) { @@ -1147,6 +1154,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; @@ -1197,22 +1205,17 @@ 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; } @@ -1221,7 +1224,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 @@ -1230,12 +1233,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((u32)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((u32)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.397.gdd90340f6a-goog