From patchwork Wed Feb 14 08:21:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10218155 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 72930602CB for ; Wed, 14 Feb 2018 08:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6107128AB9 for ; Wed, 14 Feb 2018 08:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5566028F2B; Wed, 14 Feb 2018 08:22:00 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 CD5FB28AB9 for ; Wed, 14 Feb 2018 08:21:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB3B389951; Wed, 14 Feb 2018 08:21:58 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 420238994A; Wed, 14 Feb 2018 08:21:57 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id k87so3112546wmi.0; Wed, 14 Feb 2018 00:21:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=t2mF7pMuUKsACQlNWovx47PYbUSPyysaxk9F2brY/gA=; b=daOJwHC8fhKT8Wqx/BANErmVCKvNNDgaDEvC5oEdIfM1tUlwatTbdeXpj2ImDmMuXm ecIlKJyyTa6WeYn2S5tum/wsIUhaGkrJetaL8bnAfwyrfjFTp4U68+lNnCrCC1omoueX riI9WUX7rUz1qTkLmFxRDxpU+sws9yolwzSkPJ0d10RubbVGjoXHp+IkUFnbBgFvyRlO izonm9nNp6PIVmK2VM6+4PPEg+BhCCnj22HsEgGzg7+Q1e9GRwUBR9BTGhkTdADSV2di X4NPTuJrkF5ngLEClZHJ8iAX0FPqSvRPLLGNgnnTgrEK7AmoAV0zHKVUj3QWqpn1fc36 rZZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=t2mF7pMuUKsACQlNWovx47PYbUSPyysaxk9F2brY/gA=; b=WC3gaQagZZranZg2mdVE+L1slZ3ubJJGpoEafYcNFU7WqRMCm2EpLRMkP4Nn3MpoX2 Yy5d4eVPP+fBL3c9SmNL21rTyYbNuh3gOfGq63H2IMGI2JqYWbCTsXrQ63LuDPEOXrAh aQqPm1bqunKqFyqlbfuQ4Ctz2uNNDrQAm+veDIPvOOZTBqtXjMcWSaj/RAwKOGembEYO H/Ab1OEYzi3QmGhSPA1fEr+sJLlmXmyvXHBdWTpyhIlY/2yO05yVu4Yv7dfi/VcLd3tb y75htH2Fd333PyjScz9b3EpiboIv2Uykj1zZw/B8nk95x6zaLYvOx2raYpF4l9pr+AMb Zm+A== X-Gm-Message-State: APf1xPDWpKsly0KE81N8i2YE18hp9QrnsAOg/ajWJozmXy0qKSWOTEMY D2WTKdmMl5xrBfDG5AKjWb8= X-Google-Smtp-Source: AH8x224h1ZZtOphaZSHiNYrtkHg3AYIX1bZRpXbEEZr5qzTqXnevo9PBRAE32ej17qfFU5wajX0nBQ== X-Received: by 10.80.176.5 with SMTP id i5mr6001811edd.34.1518596515947; Wed, 14 Feb 2018 00:21:55 -0800 (PST) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id m37sm4528405edc.50.2018.02.14.00.21.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 00:21:54 -0800 (PST) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Wed, 14 Feb 2018 09:21:49 +0100 Message-Id: <20180214082151.25015-1-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v5 1/3] drm/i915: Add intel_bios_cleanup() function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans de Goede , intel-gfx , dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add an intel_bios_cleanup() function to act as counterpart of intel_bios_init() and move the cleanup of vbt related resources there, putting it in the same file as the allocation. Changed in v2: -While touching the code anyways, remove the unnecessary: if (dev_priv->vbt.child_dev) done before kfree(dev_priv->vbt.child_dev) Reviewed-by: Ville Syrjälä Signed-off-by: Hans de Goede --- drivers/gpu/drm/i915/i915_drv.c | 14 +------------- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_bios.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 9380c9f69b0f..a9931b8ec0b3 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -1448,19 +1448,7 @@ void i915_driver_unload(struct drm_device *dev) intel_modeset_cleanup(dev); - /* - * free the memory space allocated for the child device - * config parsed from VBT - */ - if (dev_priv->vbt.child_dev && dev_priv->vbt.child_dev_num) { - kfree(dev_priv->vbt.child_dev); - dev_priv->vbt.child_dev = NULL; - dev_priv->vbt.child_dev_num = 0; - } - kfree(dev_priv->vbt.sdvo_lvds_vbt_mode); - dev_priv->vbt.sdvo_lvds_vbt_mode = NULL; - kfree(dev_priv->vbt.lfp_lvds_vbt_mode); - dev_priv->vbt.lfp_lvds_vbt_mode = NULL; + intel_bios_cleanup(dev_priv); vga_switcheroo_unregister_client(pdev); vga_client_register(pdev, NULL, NULL, NULL); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c06d4126c447..ea71a2a6fc18 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3680,6 +3680,7 @@ extern void intel_i2c_reset(struct drm_i915_private *dev_priv); /* intel_bios.c */ void intel_bios_init(struct drm_i915_private *dev_priv); +void intel_bios_cleanup(struct drm_i915_private *dev_priv); bool intel_bios_is_valid_vbt(const void *buf, size_t size); bool intel_bios_is_tv_present(struct drm_i915_private *dev_priv); bool intel_bios_is_lvds_present(struct drm_i915_private *dev_priv, u8 *i2c_pin); diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index aa4df6548771..ea1ed84a1e7d 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c @@ -1610,6 +1610,21 @@ void intel_bios_init(struct drm_i915_private *dev_priv) pci_unmap_rom(pdev, bios); } +/** + * intel_bios_cleanup - Free any resources allocated by intel_bios_init() + * @dev_priv: i915 device instance + */ +void intel_bios_cleanup(struct drm_i915_private *dev_priv) +{ + kfree(dev_priv->vbt.child_dev); + dev_priv->vbt.child_dev = NULL; + dev_priv->vbt.child_dev_num = 0; + kfree(dev_priv->vbt.sdvo_lvds_vbt_mode); + dev_priv->vbt.sdvo_lvds_vbt_mode = NULL; + kfree(dev_priv->vbt.lfp_lvds_vbt_mode); + dev_priv->vbt.lfp_lvds_vbt_mode = NULL; +} + /** * intel_bios_is_tv_present - is integrated TV present in VBT * @dev_priv: i915 device instance