From patchwork Thu Oct 22 18:30:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 7468881 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 BFE88BEEA4 for ; Fri, 23 Oct 2015 00:33:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A084920819 for ; Fri, 23 Oct 2015 00:33:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 825D92080E for ; Fri, 23 Oct 2015 00:33:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 600456E4DA; Thu, 22 Oct 2015 17:33:55 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9BD072211 for ; Thu, 22 Oct 2015 11:32:11 -0700 (PDT) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9MIW0vb030449; Thu, 22 Oct 2015 13:32:00 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9MIW0C2018435; Thu, 22 Oct 2015 13:32:00 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 22 Oct 2015 13:32:00 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9MIVxdU005286; Thu, 22 Oct 2015 13:31:59 -0500 Received: from localhost (uda0226330.am.dhcp.ti.com [128.247.8.252]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id t9MIVx913286; Thu, 22 Oct 2015 13:31:59 -0500 (CDT) From: "Andrew F. Davis" To: David Airlie , Russell King , Laurent Pinchart , Lars-Peter Clausen Subject: [PATCH] drm: Add helper macro for drm_i2c_encoder_driver boilerplate Date: Thu, 22 Oct 2015 13:30:12 -0500 Message-ID: <1445538612-3633-1-git-send-email-afd@ti.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 22 Oct 2015 17:33:32 -0700 Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Andrew F. Davis" 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This patch introduces the module_drm_i2c_encoder_driver macro which is a convenience macro for I2C encoder driver modules similar to others such as module_platform_driver. To help with this we also add the drm_i2c_encoder_register macro that gets THIS_MODULE without include chaining or adding it to every driver filel, renaming the old drm_i2c_encoder_register to __drm_i2c_encoder_register, again similar to many other subsystems. Finally, use this macro in all aplicable drivers. Signed-off-by: Andrew F. Davis --- drivers/gpu/drm/i2c/adv7511.c | 12 +----------- drivers/gpu/drm/i2c/ch7006_drv.c | 12 +----------- drivers/gpu/drm/i2c/sil164_drv.c | 14 +------------- drivers/gpu/drm/i2c/tda998x_drv.c | 17 +---------------- include/drm/drm_encoder_slave.h | 23 +++++++++++++++++++---- 5 files changed, 23 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c index 00416f2..c1d1206 100644 --- a/drivers/gpu/drm/i2c/adv7511.c +++ b/drivers/gpu/drm/i2c/adv7511.c @@ -997,17 +997,7 @@ static struct drm_i2c_encoder_driver adv7511_driver = { .encoder_init = adv7511_encoder_init, }; -static int __init adv7511_init(void) -{ - return drm_i2c_encoder_register(THIS_MODULE, &adv7511_driver); -} -module_init(adv7511_init); - -static void __exit adv7511_exit(void) -{ - drm_i2c_encoder_unregister(&adv7511_driver); -} -module_exit(adv7511_exit); +module_drm_i2c_encoder_driver(adv7511_driver); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_DESCRIPTION("ADV7511 HDMI transmitter driver"); diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c index 51fa323..cdf79f8 100644 --- a/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/drivers/gpu/drm/i2c/ch7006_drv.c @@ -517,15 +517,7 @@ static struct drm_i2c_encoder_driver ch7006_driver = { /* Module initialization */ -static int __init ch7006_init(void) -{ - return drm_i2c_encoder_register(THIS_MODULE, &ch7006_driver); -} - -static void __exit ch7006_exit(void) -{ - drm_i2c_encoder_unregister(&ch7006_driver); -} +module_drm_i2c_encoder_driver(ch7006_driver); int ch7006_debug; module_param_named(debug, ch7006_debug, int, 0600); @@ -548,5 +540,3 @@ MODULE_AUTHOR("Francisco Jerez "); MODULE_DESCRIPTION("Chrontel ch7006 TV encoder driver"); MODULE_LICENSE("GPL and additional rights"); -module_init(ch7006_init); -module_exit(ch7006_exit); diff --git a/drivers/gpu/drm/i2c/sil164_drv.c b/drivers/gpu/drm/i2c/sil164_drv.c index 002ce78..2d217ba 100644 --- a/drivers/gpu/drm/i2c/sil164_drv.c +++ b/drivers/gpu/drm/i2c/sil164_drv.c @@ -444,21 +444,9 @@ static struct drm_i2c_encoder_driver sil164_driver = { /* Module initialization */ -static int __init -sil164_init(void) -{ - return drm_i2c_encoder_register(THIS_MODULE, &sil164_driver); -} - -static void __exit -sil164_exit(void) -{ - drm_i2c_encoder_unregister(&sil164_driver); -} +module_drm_i2c_encoder_driver(sil164_driver); MODULE_AUTHOR("Francisco Jerez "); MODULE_DESCRIPTION("Silicon Image sil164 TMDS transmitter driver"); MODULE_LICENSE("GPL and additional rights"); -module_init(sil164_init); -module_exit(sil164_exit); diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index 424228b..2d77a5a 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -1620,23 +1620,8 @@ static struct drm_i2c_encoder_driver tda998x_driver = { /* Module initialization */ -static int __init -tda998x_init(void) -{ - DBG(""); - return drm_i2c_encoder_register(THIS_MODULE, &tda998x_driver); -} - -static void __exit -tda998x_exit(void) -{ - DBG(""); - drm_i2c_encoder_unregister(&tda998x_driver); -} +module_drm_i2c_encoder_driver(tda998x_driver); MODULE_AUTHOR("Rob Clark i2c_driver); } +/* use a define to avoid include chaining to get THIS_MODULE */ +#define drm_i2c_encoder_register(driver) \ + __drm_i2c_encoder_register(THIS_MODULE, driver) + /** * drm_i2c_encoder_unregister - Unregister an I2C encoder driver * @driver: Driver to be unregistered. @@ -159,7 +163,6 @@ static inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *dri void drm_i2c_encoder_destroy(struct drm_encoder *encoder); - /* * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs: */ @@ -178,5 +181,17 @@ enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder, void drm_i2c_encoder_save(struct drm_encoder *encoder); void drm_i2c_encoder_restore(struct drm_encoder *encoder); +/** + * module_drm_i2c_encoder_driver() - Helper macro for registering a I2C + * Encoder driver + * @__drm_i2c_encoder_driver: drm_i2c_encoder_driver struct + * + * Helper macro for I2C Encoder drivers which do not do anything special in + * module init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_drm_i2c_encoder_driver(__drm_i2c_encoder_driver) \ + module_driver(__drm_i2c_encoder_driver, drm_i2c_encoder_register, \ + drm_i2c_encoder_unregister) #endif