Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2865084imm; Wed, 3 Oct 2018 10:18:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV610HQNCCK09eBq6LEHm//0lt6YVsJ3uB3ykPK05QvF9Tm2W2uFUsGzQ4QRDHtASqOevESkw X-Received: by 2002:a62:594f:: with SMTP id n76-v6mr2722325pfb.42.1538587092231; Wed, 03 Oct 2018 10:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538587092; cv=none; d=google.com; s=arc-20160816; b=TZ2W5UbHYKBdSxX2hQ/WpGRWj1mg+P3CJO1F9QRFVK7t74hCdIRNeCjAEf1wGdX4lu k5bY3YvDWgXP9oNmiOhoZKBDPFd9sOeLM+SfM2AcRohU2vek9qu/okJiIib5E8ez0As9 LuMVI6kcQFAbtlNZaP1waJFhor3ZQnEHVvMJu5KkaEFNSyGEaSbXnM+eKdJVljrZObcH 7aIFUw5R7Ow9kK9CbqqRfPQTwyMj+rlhiamsxDK+m7/B8iQ7HtA2/c3+kmz6F3znS6oe /xC1u/5LL0iBcbrXCsU7OmgGUSM2Rm5DlKySXUPM0GwhbAEm9vM7G+o9uLICgEv+x6hK YcDw== 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:mime-version :message-id:date:dkim-signature; bh=2FgyjsgMohzJjsdQ4jm1QY2apbCQQphH7verDaFtLCY=; b=kerj9NjZb4tppXwJfO0K9jcOHdeS9TvY5g+3fBKsv+hyluVZCwr2amZFxlpFfNMeeF SFToSB7gqoTN3Fzo41DYQYDAzFz3cWX1iukAYJEGF4k5hPRg2SYbbsTpDj6scawlKRKm dVi6Yfo8YohKei+Q+rfMn95zPhz7WDrFbAms2F/7EMY95b+P7PgMHvNXfMQnJjvPvOMl hu74ZPwY360zrFDJoOiGFwe8CZZHKWJre8GRVFphaJruD5/ZcJn2s1PZrr5WsFjRyNmW tic7vAhFLaJ4+EN/nvzgCXqe43XddvOXYo+p/PI7815KSzW3EamxC9oyl7iTjQly6RPZ x8Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=q03Ykof1; 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 3-v6si97071plp.173.2018.10.03.10.17.55; Wed, 03 Oct 2018 10:18:12 -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=q03Ykof1; 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 S1727091AbeJDAHD (ORCPT + 99 others); Wed, 3 Oct 2018 20:07:03 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:32861 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeJDAHD (ORCPT ); Wed, 3 Oct 2018 20:07:03 -0400 Received: by mail-vs1-f74.google.com with SMTP id e20-v6so2113113vsl.0 for ; Wed, 03 Oct 2018 10:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=2FgyjsgMohzJjsdQ4jm1QY2apbCQQphH7verDaFtLCY=; b=q03Ykof1SAvN0bkl+PQ+W/5EfDbUxVliougLPuCoeAmc8ZrH10TtKLpdwJ772BA1TO yflEBXVSUnwW9A6PJalNcrJrAWPUiZOeX84R7gER1Y/I4uQ7lYVCWHRrgNkl+3lSUb5q q3WuMrZsh2sseh+V4rc+OjGKm3RQFDb4yfwi8p1RDfbk6cZUQpKe+u6fcm490M1QTENC /L5Wv/mBkYmjn/QTvOjW2+7t5JA1K1Z9tTshD5PvsGcmraIHTW/n/Jvm1NmuAAV0/EIq krth5yKBOhVwOtJpYppmR86BklGETvMm7Pyo5uB1UeHN1uWH4R29OhWGEp1VIA3Jnz4r 8JQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=2FgyjsgMohzJjsdQ4jm1QY2apbCQQphH7verDaFtLCY=; b=uCrR6QNwm0VYcYFHkL671p+5p9azpr7Ol0i1UKodMQhFHbLnOzijwtyFHn3fDUQuV1 ejPAlytdhoXcJFxJWyaT69f3G9FoH3JUyZan/bebuWxnuyFTVy5as4bHHtague5C8kVx Xgttq1zvRb0JmuULWSVoElVXaPt7q1+csoiVNyigpH4Lcf7szhE/PKC9VODQf6LyR++V z+jrSOFLSQO/9liElj90zxSbjLCP6g+hZ1qOmsBGjtp1Fgpl4SViHtOkPK8pK/8tGGzj yObh5Zj5mDSDfPncAznxGq7tMIYIZfAAfjY/+CZA0nR/HbZKAvAMoONOYRkP3ZeK3a/S w7pQ== X-Gm-Message-State: ABuFfoi94GMPbuF2OtFQa0xyW1+IA2mxaXqexDKq00ST5dmza2W+mSqL VeZKvKG9yAhD98+3pLXUw2ZPWmf4 X-Received: by 2002:a1f:b3c3:: with SMTP id c186-v6mr2180850vkf.7.1538587065238; Wed, 03 Oct 2018 10:17:45 -0700 (PDT) Date: Wed, 3 Oct 2018 10:17:06 -0700 Message-Id: <20181003171720.169953-1-rkir@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH v3 01/15] platform: goldfish: pipe: Move the file-scope goldfish_interrupt_tasklet variable into the driver state 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 This is a series of patches to move mutable file-scope variables into the driver state. This change will help to introduce another version of the pipe driver (with different state) for the older host interface or having several instances of this device. Signed-off-by: Roman Kiryanov --- Changes in v3: - No change. Changes in v2: - Updated the commit message. drivers/platform/goldfish/goldfish_pipe.c | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 56665e879e5a..ba9aede17d57 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -208,6 +208,9 @@ struct goldfish_pipe_dev { int irq; int version; unsigned char __iomem *base; + + /* an irq tasklet to run goldfish_interrupt_task */ + struct tasklet_struct irq_tasklet; }; static struct goldfish_pipe_dev goldfish_pipe_dev; @@ -582,14 +585,14 @@ static struct goldfish_pipe *signalled_pipes_pop_front( return pipe; } -static void goldfish_interrupt_task(unsigned long unused) +static void goldfish_interrupt_task(unsigned long dev_addr) { /* Iterate over the signalled pipes and wake them one by one */ + struct goldfish_pipe_dev *dev = (struct goldfish_pipe_dev *)dev_addr; struct goldfish_pipe *pipe; int wakes; - while ((pipe = signalled_pipes_pop_front(&goldfish_pipe_dev, &wakes)) != - NULL) { + while ((pipe = signalled_pipes_pop_front(dev, &wakes)) != NULL) { if (wakes & PIPE_WAKE_CLOSED) { pipe->flags = 1 << BIT_CLOSED_ON_HOST; } else { @@ -605,7 +608,6 @@ static void goldfish_interrupt_task(unsigned long unused) wake_up_interruptible(&pipe->wake_queue); } } -static DECLARE_TASKLET(goldfish_interrupt_tasklet, goldfish_interrupt_task, 0); /* * The general idea of the interrupt handling: @@ -648,7 +650,7 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) spin_unlock_irqrestore(&dev->lock, flags); - tasklet_schedule(&goldfish_interrupt_tasklet); + tasklet_schedule(&dev->irq_tasklet); return IRQ_HANDLED; } @@ -800,9 +802,14 @@ 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 = &goldfish_pipe_dev; - int err = devm_request_irq(&pdev->dev, dev->irq, - goldfish_pipe_interrupt, - IRQF_SHARED, "goldfish_pipe", dev); + int err; + + tasklet_init(&dev->irq_tasklet, &goldfish_interrupt_task, + (unsigned long)dev); + + err = devm_request_irq(&pdev->dev, dev->irq, + goldfish_pipe_interrupt, + IRQF_SHARED, "goldfish_pipe", dev); if (err) { dev_err(&pdev->dev, "unable to allocate IRQ for v2\n"); return err; @@ -854,6 +861,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); + tasklet_kill(&goldfish_pipe_dev.irq_tasklet); kfree(goldfish_pipe_dev.pipes); free_page((unsigned long)goldfish_pipe_dev.buffers); } -- 2.19.0.605.g01d371f741-goog