From patchwork Mon Jan 18 06:00:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 365791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A903AC433DB for ; Mon, 18 Jan 2021 06:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79A6522512 for ; Mon, 18 Jan 2021 06:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732483AbhARGCg (ORCPT ); Mon, 18 Jan 2021 01:02:36 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:47323 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731743AbhARGB5 (ORCPT ); Mon, 18 Jan 2021 01:01:57 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5F37C1660; Mon, 18 Jan 2021 01:00:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 18 Jan 2021 01:00:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=TiYp14NjYhNaG DavfUkENnnnnmh73vB4utXtV8iWYX0=; b=FPg4r9tRpwRmswroWGsQxOq3qILvr nsXHfX+BuWNW1+RQ/l02+H6LFJDlyx+3Folfg9N3/EpSM4jFyUHRaHfVcky3jmWQ 7PupsshJ+AiVSibidgbD1duvnCQ7xepROMNBRj1vPZkhQn48fqXIkJdkLoDKezhD gSE1n12ysiQo91AMYW7o+RcOfC84q0YtfdAW8AS3mCgOUb5RnmJeHWp5DteTqBR+ xJaXjT+IH4J7ghw0rKUBIgTL6yLmbZxgA0xl6MhVNO+qASTVKmW8iiS20HczQl6k sdpXDKJpJLuvENgk8kx4oSXX3lptAPtwQRigbvb29yJ3m/o6xL0oLZJnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=TiYp14NjYhNaGDavfUkENnnnnmh73vB4utXtV8iWYX0=; b=SU6iRwRq F7T64xbv8yTN9dgjmPfyWfTiqmT1ZC0jChmvsFGKJ1BbrsIh8qsfN/94G+Jg3egf 3VKGsbIJY+6iGQOyVOe+euXHrnOvOELnyXBhaNwWDkeh/Vy8kP1fzU4e5PmpWzdX Ae4Hyl5h3mtKpcjKXLvgBNpq+YJSfORoJHyEccC/wa+Iw5/8akGlsGH9agTkv9H1 5ClysimHBD0XNStaI99broATyJMGySgw0XgLnvmwJcLUWqNqlxfMCnA1lWE9V/en F0gXVtmk1gTg3k93KfE5UUeN7B8qK0dYTXzfXlD5k33GYN+hD83xphIkTWMlUEvD Cpl0xA3XveRuQA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrtdejgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepudfhjeefvdfhgfefheetgffhieeigfefhefgvddvveefgeejheejvdfg jeehueeinecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 69C47108005F; Mon, 18 Jan 2021 01:00:50 -0500 (EST) From: Samuel Holland To: Sean Young , Mauro Carvalho Chehab , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Samuel Holland Subject: [PATCH v2 2/4] media: sunxi-cir: Remove unnecessary spinlock Date: Mon, 18 Jan 2021 00:00:46 -0600 Message-Id: <20210118060048.22267-3-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210118060048.22267-1-samuel@sholland.org> References: <20210118060048.22267-1-samuel@sholland.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Only one register, SUNXI_IR_CIR_REG, is accessed from outside the interrupt handler, and that register is not accessed from inside it. As there is no overlap between different contexts, no lock is needed. Signed-off-by: Samuel Holland --- drivers/media/rc/sunxi-cir.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c index 0a7f7eab3cc3..48be400421cd 100644 --- a/drivers/media/rc/sunxi-cir.c +++ b/drivers/media/rc/sunxi-cir.c @@ -86,7 +86,6 @@ struct sunxi_ir_quirks { }; struct sunxi_ir { - spinlock_t ir_lock; struct rc_dev *rc; void __iomem *base; int irq; @@ -105,8 +104,6 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id) struct sunxi_ir *ir = dev_id; struct ir_raw_event rawir = {}; - spin_lock(&ir->ir_lock); - status = readl(ir->base + SUNXI_IR_RXSTA_REG); /* clean all pending statuses */ @@ -137,8 +134,6 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id) ir_raw_event_handle(ir->rc); } - spin_unlock(&ir->ir_lock); - return IRQ_HANDLED; } @@ -160,17 +155,14 @@ static int sunxi_ir_set_timeout(struct rc_dev *rc_dev, unsigned int timeout) { struct sunxi_ir *ir = rc_dev->priv; unsigned int base_clk = clk_get_rate(ir->clk); - unsigned long flags; unsigned int ithr = sunxi_usec_to_ithr(base_clk, timeout); dev_dbg(rc_dev->dev.parent, "setting idle threshold to %u\n", ithr); - spin_lock_irqsave(&ir->ir_lock, flags); /* Set noise threshold and idle threshold */ writel(REG_CIR_NTHR(SUNXI_IR_RXNOISE) | REG_CIR_ITHR(ithr), ir->base + SUNXI_IR_CIR_REG); - spin_unlock_irqrestore(&ir->ir_lock, flags); rc_dev->timeout = sunxi_ithr_to_usec(base_clk, ithr); @@ -199,8 +191,6 @@ static int sunxi_ir_probe(struct platform_device *pdev) return -ENODEV; } - spin_lock_init(&ir->ir_lock); - ir->fifo_size = quirks->fifo_size; /* Clock */ From patchwork Mon Jan 18 06:00:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 365792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8552C433DB for ; Mon, 18 Jan 2021 06:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 927A922512 for ; Mon, 18 Jan 2021 06:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732455AbhARGB7 (ORCPT ); Mon, 18 Jan 2021 01:01:59 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33593 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732323AbhARGBt (ORCPT ); Mon, 18 Jan 2021 01:01:49 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 2BBFF1654; Mon, 18 Jan 2021 01:00:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 18 Jan 2021 01:00:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=APUXW7opGCrXk J0FX4uaEp3rryEdb5R1fRBATUuYTOM=; b=qsSVq+hOyAm1CHFlR4JOonLTl7qxh 4I18dJqO6AbzXerv2cGxKkY025xWiUgwIABvQhnKeBaMHUZ/IZ+OdRs36esqk/mJ 2iEzCnowIJTfpRQjKalVf5BgsC2xStuQGIRrrKhdCDfhUTJImzpCW7c8HnaOeqmx rOsBmiwKaUqcjp0iemBUcrtIJjh75hJyLaPcbPKqTmRi6w8Xg6m8BwJoYbFjyST2 1TSP4ajVcmJCR9cihC9RWNc87F/cR2kWDj3dHW2yhdfui939LGLLL2SEShlyZkqZ O7FgrWOYQyU2RSguSjVFyUGnmzD8BWjs5rxSmn6Clp73N9g7TJ6VygUHA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=APUXW7opGCrXkJ0FX4uaEp3rryEdb5R1fRBATUuYTOM=; b=OUn2j+Jt cqoXjF7mevlqrYIaBGXjgh3UuTwRi8orDT2pA/S2h0yxCZJnzvbUndNv5hgNGJZq cGKdSI2YytzbgsvVC8v0dr5dwqHo+sgXaQySk4dW8RQMZVHv/xKu12QqseqR7OZr nyzpvxewQbuBiTWChqwgwPuHIv7/tBfsRvTa64D72mpvlrlZsHrhLnhjYLnPVHZ7 DEANBedxmrJxnlTSkaMtb28Wrsj7vVyOcGnTLgsZ4oawuD+k94Oy7Ctc9vrupEtl zlorgT25rdyz3lmxzxbwKvWbQ8FrrbgnZTbmy1T4OyKWFaiR+9SQSjRfoUkgnMms 6vQzIczdrTANdw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrtdejgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepudfhjeefvdfhgfefheetgffhieeigfefhefgvddvveefgeejheejvdfg jeehueeinecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 3A5391080067; Mon, 18 Jan 2021 01:00:51 -0500 (EST) From: Samuel Holland To: Sean Young , Mauro Carvalho Chehab , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Samuel Holland Subject: [PATCH v2 4/4] media: sunxi-cir: Implement suspend/resume/shutdown callbacks Date: Mon, 18 Jan 2021 00:00:48 -0600 Message-Id: <20210118060048.22267-5-samuel@sholland.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210118060048.22267-1-samuel@sholland.org> References: <20210118060048.22267-1-samuel@sholland.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To save power, gate/reset the hardware block while the system is asleep or powered off. Signed-off-by: Samuel Holland --- drivers/media/rc/sunxi-cir.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c index 2d099da8d3cc..168e1d2c876a 100644 --- a/drivers/media/rc/sunxi-cir.c +++ b/drivers/media/rc/sunxi-cir.c @@ -234,6 +234,20 @@ static void sunxi_ir_hw_exit(struct device *dev) reset_control_assert(ir->rst); } +static int __maybe_unused sunxi_ir_suspend(struct device *dev) +{ + sunxi_ir_hw_exit(dev); + + return 0; +} + +static int __maybe_unused sunxi_ir_resume(struct device *dev) +{ + return sunxi_ir_hw_init(dev); +} + +static SIMPLE_DEV_PM_OPS(sunxi_ir_pm_ops, sunxi_ir_suspend, sunxi_ir_resume); + static int sunxi_ir_probe(struct platform_device *pdev) { int ret = 0; @@ -362,6 +376,11 @@ static int sunxi_ir_remove(struct platform_device *pdev) return 0; } +static void sunxi_ir_shutdown(struct platform_device *pdev) +{ + sunxi_ir_hw_exit(&pdev->dev); +} + static const struct sunxi_ir_quirks sun4i_a10_ir_quirks = { .has_reset = false, .fifo_size = 16, @@ -397,9 +416,11 @@ MODULE_DEVICE_TABLE(of, sunxi_ir_match); static struct platform_driver sunxi_ir_driver = { .probe = sunxi_ir_probe, .remove = sunxi_ir_remove, + .shutdown = sunxi_ir_shutdown, .driver = { .name = SUNXI_IR_DEV, .of_match_table = sunxi_ir_match, + .pm = &sunxi_ir_pm_ops, }, };