From patchwork Mon Mar 26 18:06:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10308465 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 0B2C960212 for ; Mon, 26 Mar 2018 18:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2CA1290C7 for ; Mon, 26 Mar 2018 18:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E77DD297EC; Mon, 26 Mar 2018 18:08:25 +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 818C528B66 for ; Mon, 26 Mar 2018 18:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752275AbeCZSIY (ORCPT ); Mon, 26 Mar 2018 14:08:24 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40854 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbeCZSIY (ORCPT ); Mon, 26 Mar 2018 14:08:24 -0400 Received: by mail-pg0-f67.google.com with SMTP id g8so7575062pgv.7 for ; Mon, 26 Mar 2018 11:08:23 -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:in-reply-to:references; bh=ZaDRiTPjVa1Anl4T2VVQ2GRUehpPbTvGxCVtIB2pHIU=; b=rpiDVtPVyBJzUz/cytk6fBJYV3fU7H1JrXla0G3l4oNk7M33AZaeBZtLbh56YpFKFX yO/kmvrbD8B2x/ABMcdBDQhT4+ay5SsCGqoNJrWl2PGnMFYYO6We5TR+2ekG3ca0h1iD GdL0yIg3RFx0pAosShrj/kUXyqPEI60HHu2eJ5ViZd8P7huOwv1n8uMQ05vvsCqxBPAL ZJu0al4/WSNWZ1/49wh1eMvInMrZHVzknHlP44YwhkyDY8Dip9usN8vIIFrrkp6J+FnY FiLB7MHUjsl3Hyh95HoCN+XFzsQMlEN6mZlCIonExKRAQpSOrHLqhAN4xH6dsaOVQJpk fnwA== 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:in-reply-to :references; bh=ZaDRiTPjVa1Anl4T2VVQ2GRUehpPbTvGxCVtIB2pHIU=; b=kAG5UY+/56pTZlqFGz/+Q/j5jP65rEK6Ht30lL/iuRmE7uoeJkQVKx0j06BZ6fr9i3 JCuzq21lh6x3A/RlGd2pFR7Glzu5P2KyG9QS9DhbWzh1+Mz7OvEH7hysKuaf2SxmNTR0 R+d2/Vzx2nT0J8X/xJDvwLcy1y1hbJ4c4X8qcMukpiFIfogGmLiPSUjxpEYvV0MCl53S z9oQY20g9RPSCDQ1U46QkCkDWzXkYiQE/VIWQOPbCfKd4jX99XfjwukpCIywIRHRy4J2 Cpnw19cqZK2qCtOVEhkt06lVTvss6GOmNtrsMsEioKORU3ce+F7tZV/ZnpVR0pNdArJ7 l8nA== X-Gm-Message-State: AElRT7HokBRTISffOdWAA6HD29Fc5gneexk2JanMIG42DMlF8/MJOgvk /NViuSUGio4kc2DGARJ0K/uQig== X-Google-Smtp-Source: AG47ELsRGUpcsSpBh1jOSLaA2HJYL8sprZdp/KExxbv9N2/GmFAlste5/wB3ZDror4y2XMP8DfYZEg== X-Received: by 10.99.110.129 with SMTP id j123mr19964661pgc.65.1522087703334; Mon, 26 Mar 2018 11:08:23 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id q6sm27150368pga.37.2018.03.26.11.08.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 11:08:22 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, Akihiro Tsukada Subject: [PATCH v3 1/5] dvb-frontends/dvb-pll: add i2c driver support Date: Tue, 27 Mar 2018 03:06:48 +0900 Message-Id: <20180326180652.5385-2-tskd08@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180326180652.5385-1-tskd08@gmail.com> References: <20180326180652.5385-1-tskd08@gmail.com> 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 registers the module as an i2c driver, but keeps dvb_pll_attach() untouched for compatibility. Signed-off-by: Akihiro Tsukada --- drivers/media/dvb-frontends/dvb-pll.c | 49 +++++++++++++++++++++++++++++++++++ drivers/media/dvb-frontends/dvb-pll.h | 6 +++++ 2 files changed, 55 insertions(+) diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c index 5553b89b804..614a5ea3b00 100644 --- a/drivers/media/dvb-frontends/dvb-pll.c +++ b/drivers/media/dvb-frontends/dvb-pll.c @@ -827,6 +827,55 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, } EXPORT_SYMBOL(dvb_pll_attach); + +static int +dvb_pll_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct dvb_pll_config *cfg; + struct dvb_frontend *fe; + unsigned int desc_id; + + cfg = client->dev.platform_data; + fe = cfg->fe; + i2c_set_clientdata(client, fe); + desc_id = cfg->desc_id; + + if (!dvb_pll_attach(fe, client->addr, client->adapter, desc_id)) + return -ENOMEM; + + dev_info(&client->dev, "DVB Simple Tuner attached.\n"); + return 0; +} + +static int dvb_pll_remove(struct i2c_client *client) +{ + struct dvb_frontend *fe; + + fe = i2c_get_clientdata(client); + dvb_pll_release(fe); + return 0; +} + + +static const struct i2c_device_id dvb_pll_id[] = { + {"dvb_pll", 0}, + {} +}; + + +MODULE_DEVICE_TABLE(i2c, dvb_pll_id); + +static struct i2c_driver dvb_pll_driver = { + .driver = { + .name = "dvb_pll", + }, + .probe = dvb_pll_probe, + .remove = dvb_pll_remove, + .id_table = dvb_pll_id, +}; + +module_i2c_driver(dvb_pll_driver); + MODULE_DESCRIPTION("dvb pll library"); MODULE_AUTHOR("Gerd Knorr"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb-frontends/dvb-pll.h b/drivers/media/dvb-frontends/dvb-pll.h index ca885e71d2f..15bda0d0c15 100644 --- a/drivers/media/dvb-frontends/dvb-pll.h +++ b/drivers/media/dvb-frontends/dvb-pll.h @@ -30,6 +30,12 @@ #define DVB_PLL_TDEE4 18 #define DVB_PLL_THOMSON_DTT7520X 19 +struct dvb_pll_config { + struct dvb_frontend *fe; + + unsigned int desc_id; +}; + #if IS_REACHABLE(CONFIG_DVB_PLL) /** * Attach a dvb-pll to the supplied frontend structure.