From patchwork Fri Nov 24 17:53:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10076109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D8A60602BD for ; Mon, 27 Nov 2017 08:36:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6586288F6 for ; Mon, 27 Nov 2017 08:36:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9B9D28D94; Mon, 27 Nov 2017 08:36:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62BE7288F6 for ; Mon, 27 Nov 2017 08:36:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B65C6E275; Mon, 27 Nov 2017 08:34:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from rere.qmqm.pl (78-11-180-123.static.ip.netia.com.pl [78.11.180.123]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DA926E0E9 for ; Fri, 24 Nov 2017 18:02:48 +0000 (UTC) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 3yk3hZ04xnz5H; Fri, 24 Nov 2017 18:53:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1511546014; bh=ZrAbLHw4ksVWFLK3mOfzMwdTFqybQwrtdv13DvRYyNo=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=BGiGLpQEOwDTcVTjo4BzTIlblBWFjZ3lGalBaz57VIHGqydH+bMNqWLq1EdtXSPYz 7zy6xh/XEtkAdMrxbe/ay/fjo7srT2yv/9Vh/Jo41yP7UqPMWoXT471Ot4TOn0ZYrn FHr9bSiglIrRG81swxybrENzzsI9fj06OfzV94rCeK9ZjM3YMn0QcGaZAKKJ8HWOi8 MulhrJFVrK0fHAQd8xrGlfB5PIrsScm1sGOOO5FbvlKipmKpGJYGAvt1PTJYJoNuoy XnNMc7btfVrQ013uVAouPkisltQAT6iP6p11xXMQhEyuLOvXNorQmgsJweDjxixRCE m4MjuG1tsAaQQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Fri, 24 Nov 2017 18:53:33 +0100 Message-Id: <13240c59cafec988cdda37cc4d48252ff56f0d04.1511544782.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 10/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers() MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org X-Mailman-Approved-At: Mon, 27 Nov 2017 08:34:15 +0000 Cc: Bartlomiej Zolnierkiewicz , David Airlie , Jonathan Hunter , Chen-Yu Tsai , Thierry Reding , linux-tegra@vger.kernel.org, Maxime Ripard X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Interpret (otherwise-invalid) NULL apertures argument to mean all-memory range. This will allow to remove several duplicates of this code from drivers in following patches. Signed-off-by: Michał Mirosław --- drivers/video/fbdev/core/fbmem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 5ea980e5d3b7..927e016487e9 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1780,11 +1780,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { int ret; + bool do_free = false; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return -ENOMEM; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } mutex_lock(®istration_lock); ret = do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(®istration_lock); + if (do_free) + kfree(a); + return ret; } EXPORT_SYMBOL(remove_conflicting_framebuffers);