From patchwork Sat Sep 1 14:08:44 2018 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: 10584761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03E6817DE for ; Sat, 1 Sep 2018 14:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004692A20B for ; Sat, 1 Sep 2018 14:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E88702A218; Sat, 1 Sep 2018 14:08:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0783F2A20B for ; Sat, 1 Sep 2018 14:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbeIASU5 (ORCPT ); Sat, 1 Sep 2018 14:20:57 -0400 Received: from 183.pool-64.klikom.net ([91.227.64.183]:8558 "EHLO rere.qmqm.pl" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727261AbeIASU5 (ORCPT ); Sat, 1 Sep 2018 14:20:57 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 422dNk5rGtzbZ; Sat, 1 Sep 2018 16:08:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1535810886; bh=Eh3NwSBhd/6qo4Gal61knpd5lppRQQ+HPCEaYA1Bwwk=; h=Date:In-Reply-To:References:From:Subject:To:Cc:Cc:From; b=GwrGh/YtptzEKnqzQqlj6eNtUbcHx+yBKOqzGhNsXXgky4lLMy2VLDGWdTUi3gXi1 /+9En/gUXDjiQggYxobxLqvB7qLASHq+ExpBbWb7kxcRoSKy7da3hm37sJsPn04iJ1 wyqTTqkQGglNvP4wWX+84y04g7zYZIPXK9WU+D3qwq23SLuklp4tETLGf019Ypc1dx nk0O1SwXDt6xGG7fL+NVf+23nCY96EuUUG07gCbREPyibeW7Jb9SnQsLtKvmLmCjqd v/zeBPZkNhJxAg8s2hvvUJW+pB80bX9W1FiJTNj2dorzH5ZgsoSzPo2iwPKYxs5eBM IiGOiMOAVAWdQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.0 at mail Date: Sat, 01 Sep 2018 16:08:44 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v3 02/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers() MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org Cc: Alex Deucher , amd-gfx@lists.freedesktop.org, Dave Airlie , David Airlie , Eric Anholt , Gerd Hoffmann , Jonathan Hunter , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Maxime Ripard , Thierry Reding , virtualization@lists.linux-foundation.org Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 Acked-by: Bartlomiej Zolnierkiewicz --- v2: added kerneldoc to corresponding DRM helper v3: split kerneldoc to another patch --- 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 30a18d4c9de4..0df148eb4699 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1779,11 +1779,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);