From patchwork Fri Mar 6 12:58:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 5956771 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 23583BF440 for ; Fri, 6 Mar 2015 17:12:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FDA4201CE for ; Fri, 6 Mar 2015 17:12:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EB6E420254 for ; Fri, 6 Mar 2015 17:12:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C53016E8EF; Fri, 6 Mar 2015 09:12:39 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by gabe.freedesktop.org (Postfix) with ESMTP id CF4F06E865 for ; Fri, 6 Mar 2015 04:59:24 -0800 (PST) Received: by padfa1 with SMTP id fa1so45206181pad.3 for ; Fri, 06 Mar 2015 04:59:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=vj0jqYh7q9gZ6L0G/W0CzNhFIYej4muR3Yq4t4r8Pdw=; b=LUjyQ9jw+tbkmMOEmng6rORWIs4YlPH8qfJR4flFWN8QW9XU9L0m788l7ErgSv2Abl ngNds43r8d3s3F/eA+mSnPZ+XZ2x9//xdSjhDI6PaN3OuCwW6XFTdChSaePFsyZ3KHMt F+GmeTFjmEICc23ljtGNsmag+g+lg7enMxpkmjHlVLjxiZ1Fak8mxSU8NGSxTlfYs9Ih gxbUb+U5EpN/m9IUpWxlQkYNuV6ilGaGnf47LnQ9wznrUbgUW5S6Ln20Ip8EhAmD7LET UeRLM5DvhxkvjWiwDck9mVCVQh2mAw0tgy0N/LWcDJ8bXg43wZp69+uxXNkD7JVLTxwg SyHw== X-Received: by 10.66.137.42 with SMTP id qf10mr4421792pab.52.1425646764509; Fri, 06 Mar 2015 04:59:24 -0800 (PST) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id qw7sm9534825pbc.35.2015.03.06.04.59.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Mar 2015 04:59:23 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org Subject: [PATCH] drm: fix sysfs symlinks between driver and module Date: Fri, 6 Mar 2015 21:58:48 +0900 Message-Id: <1425646728-7334-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Fri, 06 Mar 2015 09:12:36 -0800 Cc: Akinobu Mita , dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When registering drivers, the symlinks for mapping between driver and module are created in sysfs. But the drm drivers registered by drm_pci_init() create wrong symlinks, because correct owner module of pci driver is not passed to pci_register_driver(). For example, the i915 driver creates the following wrong symlinks: /sys/bus/pci/drivers/i915/module -> ../../../../module/drm /sys/module/drm/drivers/pci:i915 -> ../../../bus/pci/drivers/i915 With this change, these symlinks are fixed: /sys/bus/pci/drivers/i915/module -> ../../../../module/i915 /sys/module/i915/drivers/pci:i915 -> ../../../bus/pci/drivers/i915 Signed-off-by: Akinobu Mita Cc: David Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_pci.c | 14 +++++++++----- include/drm/drmP.h | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index fd29f03..e093a11 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -318,16 +318,19 @@ err_free: EXPORT_SYMBOL(drm_get_pci_dev); /** - * drm_pci_init - Register matching PCI devices with the DRM subsystem + * __drm_pci_init - Register matching PCI devices with the DRM subsystem * @driver: DRM device driver * @pdriver: PCI device driver + * @owner: owner module of pdriver + * @mod_name: module name string * * Initializes a drm_device structures, registering the stubs and initializing * the AGP device. * * Return: 0 on success or a negative error code on failure. */ -int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) +int __drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver, + struct module *owner, const char *mod_name) { struct pci_dev *pdev = NULL; const struct pci_device_id *pid; @@ -336,7 +339,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) DRM_DEBUG("\n"); if (driver->driver_features & DRIVER_MODESET) - return pci_register_driver(pdriver); + return __pci_register_driver(pdriver, owner, mod_name); /* If not using KMS, fall back to stealth mode manual scanning. */ INIT_LIST_HEAD(&driver->legacy_dev_list); @@ -404,7 +407,8 @@ EXPORT_SYMBOL(drm_pcie_get_speed_cap_mask); #else -int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) +int __drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver, + struct module *owner, const char *mod_name) { return -1; } @@ -425,7 +429,7 @@ int drm_pci_set_unique(struct drm_device *dev, } #endif -EXPORT_SYMBOL(drm_pci_init); +EXPORT_SYMBOL(__drm_pci_init); /** * drm_pci_exit - Unregister matching PCI devices from the DRM subsystem diff --git a/include/drm/drmP.h b/include/drm/drmP.h index e928625..8a06d9d 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1034,7 +1034,10 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) } void drm_pci_agp_destroy(struct drm_device *dev); -extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); +extern int __drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver, + struct module *owner, const char *mod_name); +#define drm_pci_init(driver, pdriver) \ + __drm_pci_init(driver, pdriver, THIS_MODULE, KBUILD_MODNAME) extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); #ifdef CONFIG_PCI extern int drm_get_pci_dev(struct pci_dev *pdev,