From patchwork Mon Mar 19 16:00:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10295119 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 333F6600F6 for ; Mon, 19 Mar 2018 21:15:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 211C5294E1 for ; Mon, 19 Mar 2018 21:15:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15968294E4; Mon, 19 Mar 2018 21:15:43 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 DEB1E294E1 for ; Mon, 19 Mar 2018 21:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965389AbeCSVPj (ORCPT ); Mon, 19 Mar 2018 17:15:39 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33283 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965328AbeCSQBU (ORCPT ); Mon, 19 Mar 2018 12:01:20 -0400 Received: by mail-pf0-f193.google.com with SMTP id 123so1427721pfe.0 for ; Mon, 19 Mar 2018 09:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PMO2Tg7HXZJFlFgUvWkt36S8suaoYsGpskTVOzLgGvI=; b=QxspR+SCsx2fw2cqrrJTnt2eMfm44CuukUzzGNcrkpz6khZvUSWS2Vk18dsLbc0MQG hyGkxNBGG+Rm7Kwsq806cWYxDmxycOh7AmuMUbbWXKNoh/1U/JJuO52mSxT/cSNCZTXx c2p7TYCyGNvuHfpuPlv+jW/wnAWNR08kOpBtYwCh8pT9W42zU6ThIKR/ctAcuJbfSHCb AF/NRuImQxZZjhbVeyfJWqtClsshr+56DcBDf5wx5b1YSfcWrt4fOy79dkMLDBbFJfY6 /I91VlOYFg5ZhAmvxVWNQnRe3G96YiNEI18L58MNp0fL6tj1aAVkhkk/FotTk3l+pkmJ +5+A== 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; bh=PMO2Tg7HXZJFlFgUvWkt36S8suaoYsGpskTVOzLgGvI=; b=GWNUXd+k9nJXely67i8nb2BIvDLei0Yp7D6R4D5wzq3cmIfzGamOGRjbS1aWUcE2+9 ity/roLel2KI109B48YQoeWtaLvU0xPqfoGqtfocrY2pWCyX+1JTV0YQXlVz6Jnzrh8L hbvr64QfYVWOZR3tbY7gqGkxjICecRlOjhe/M8jHpOKgBG3Kb/Ne/g/YOEQ2DMbRttkk gmXPzOMd6Gu9DIrsa0+HO6UbVKBcYMoRgLB9yTvdry1SmJKWdlhfPRTpAKzFHxPddsDe NBL+KVd+ftXrVDPCIYKGqxsEi6NZQX4AQ4lQJUp1tjKZ1Nu/znOo9E67WLqmtrxUCH/X cnfQ== X-Gm-Message-State: AElRT7G9dzXnwq9KnmOfIS9hecBXSjOHe7u0eHq892yWX8Shkf6jCK0b y/IMNkbe0jaUpAOsL0WICchLQQ== X-Google-Smtp-Source: AG47ELv9t3N+/21m+zDBS/SE8jyzZ9o1juTASbIP8xmvC1u/sD41DgHutylhyrzU09dgTFqeA+GAXQ== X-Received: by 10.98.89.200 with SMTP id k69mr10377918pfj.100.1521475279914; Mon, 19 Mar 2018 09:01:19 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id h71sm805870pfc.47.2018.03.19.09.01.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 09:01:19 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, Akihiro Tsukada Subject: [PATCH v5] media/dvb: earth-pt3: use the new i2c binding helper Date: Tue, 20 Mar 2018 01:00:23 +0900 Message-Id: <20180319160023.6800-1-tskd08@gmail.com> X-Mailer: git-send-email 2.16.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akihiro Tsukada This patch slightly simplifies the binding code by introducing commit 8f569c0b4e6b ("media: dvb-core: add helper functions for I2C binding"). Signed-off-by: Akihiro Tsukada --- Changes since v4 - pci/pt3/pt3.c: removed redundant request_module() at line 390 Changes since v3 - earth-pt3: replaced the old helper functions (proposed by patch #27922) with the new one (commit:8f569c0b). - withdrew the following v3 patches: #27923 (tuners/qm1d1c0042), #27924 (tuners/mxl301rf), #27925 (dvb-frontends/tc90522). The new helper functions do not require changes to / apply to those demod/tuner i2c drivers. drivers/media/pci/pt3/pt3.c | 59 +++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c index da74828805b..b2d9fb976c9 100644 --- a/drivers/media/pci/pt3/pt3.c +++ b/drivers/media/pci/pt3/pt3.c @@ -376,25 +376,22 @@ static int pt3_fe_init(struct pt3_board *pt3) static int pt3_attach_fe(struct pt3_board *pt3, int i) { - struct i2c_board_info info; + const struct i2c_board_info *info; struct tc90522_config cfg; struct i2c_client *cl; struct dvb_adapter *dvb_adap; int ret; - info = adap_conf[i].demod_info; + info = &adap_conf[i].demod_info; cfg = adap_conf[i].demod_cfg; cfg.tuner_i2c = NULL; - info.platform_data = &cfg; ret = -ENODEV; - request_module("tc90522"); - cl = i2c_new_device(&pt3->i2c_adap, &info); - if (!cl || !cl->dev.driver) + cl = dvb_module_probe("tc90522", info->type, &pt3->i2c_adap, + info->addr, &cfg); + if (!cl) return -ENODEV; pt3->adaps[i]->i2c_demod = cl; - if (!try_module_get(cl->dev.driver->owner)) - goto err_demod_i2c_unregister_device; if (!strncmp(cl->name, TC90522_I2C_DEV_SAT, strlen(TC90522_I2C_DEV_SAT))) { @@ -402,41 +399,33 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i) tcfg = adap_conf[i].tuner_cfg.qm1d1c0042; tcfg.fe = cfg.fe; - info = adap_conf[i].tuner_info; - info.platform_data = &tcfg; - request_module("qm1d1c0042"); - cl = i2c_new_device(cfg.tuner_i2c, &info); + info = &adap_conf[i].tuner_info; + cl = dvb_module_probe("qm1d1c0042", info->type, cfg.tuner_i2c, + info->addr, &tcfg); } else { struct mxl301rf_config tcfg; tcfg = adap_conf[i].tuner_cfg.mxl301rf; tcfg.fe = cfg.fe; - info = adap_conf[i].tuner_info; - info.platform_data = &tcfg; - request_module("mxl301rf"); - cl = i2c_new_device(cfg.tuner_i2c, &info); + info = &adap_conf[i].tuner_info; + cl = dvb_module_probe("mxl301rf", info->type, cfg.tuner_i2c, + info->addr, &tcfg); } - if (!cl || !cl->dev.driver) - goto err_demod_module_put; + if (!cl) + goto err_demod_module_release; pt3->adaps[i]->i2c_tuner = cl; - if (!try_module_get(cl->dev.driver->owner)) - goto err_tuner_i2c_unregister_device; dvb_adap = &pt3->adaps[one_adapter ? 0 : i]->dvb_adap; ret = dvb_register_frontend(dvb_adap, cfg.fe); if (ret < 0) - goto err_tuner_module_put; + goto err_tuner_module_release; pt3->adaps[i]->fe = cfg.fe; return 0; -err_tuner_module_put: - module_put(pt3->adaps[i]->i2c_tuner->dev.driver->owner); -err_tuner_i2c_unregister_device: - i2c_unregister_device(pt3->adaps[i]->i2c_tuner); -err_demod_module_put: - module_put(pt3->adaps[i]->i2c_demod->dev.driver->owner); -err_demod_i2c_unregister_device: - i2c_unregister_device(pt3->adaps[i]->i2c_demod); +err_tuner_module_release: + dvb_module_release(pt3->adaps[i]->i2c_tuner); +err_demod_module_release: + dvb_module_release(pt3->adaps[i]->i2c_demod); return ret; } @@ -630,14 +619,10 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index) adap->fe->callback = NULL; if (adap->fe->frontend_priv) dvb_unregister_frontend(adap->fe); - if (adap->i2c_tuner) { - module_put(adap->i2c_tuner->dev.driver->owner); - i2c_unregister_device(adap->i2c_tuner); - } - if (adap->i2c_demod) { - module_put(adap->i2c_demod->dev.driver->owner); - i2c_unregister_device(adap->i2c_demod); - } + if (adap->i2c_tuner) + dvb_module_release(adap->i2c_tuner); + if (adap->i2c_demod) + dvb_module_release(adap->i2c_demod); } pt3_free_dmabuf(adap); dvb_dmxdev_release(&adap->dmxdev);