From patchwork Wed Jan 7 13:20:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5584581 Return-Path: X-Original-To: patchwork-linux-media@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 7EC73BF6C3 for ; Wed, 7 Jan 2015 13:21:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6785F2025B for ; Wed, 7 Jan 2015 13:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE01920274 for ; Wed, 7 Jan 2015 13:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753041AbbAGNVF (ORCPT ); Wed, 7 Jan 2015 08:21:05 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:58442 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753003AbbAGNVE (ORCPT ); Wed, 7 Jan 2015 08:21:04 -0500 Received: by mail-pa0-f41.google.com with SMTP id rd3so4886396pab.0 for ; Wed, 07 Jan 2015 05:21:03 -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:in-reply-to:references; bh=v+pgTyW5BFLkC/WjNM0QuKcA4Bnx2R82njKekk2UQKo=; b=EuUjO6c+yOQTmNvHX3tSrc9alEjoL9cXE83iCwascOZjPei9a0g7+GZSaTqBAFREh0 uiBqHaErkooY5GYRpTNpQtnUTOEXRWgzIizyrmEeYYFEC1DctTIli4KdZ24EUL7t/dRM Zz4gXGV4QT02KpQb89U2HowBozS77mzix9NODDP9cTXnWwQ4LBtLQVHQjsi4U6K96j5b 8biOE0oERFjg5Zh/eJfsVXMGhXql7AQQDbfTqOdbCiSjoLQG20cKy1SpOp4fS/Bl0sfd tCb/RRESsE06z7GEX5hnsFjdkIge9dZo2GPrCV36C6RsFoS9VTMQx0DRnBFFczTZkBUC eb9g== X-Received: by 10.68.129.134 with SMTP id nw6mr5435428pbb.132.1420636863501; Wed, 07 Jan 2015 05:21:03 -0800 (PST) Received: from seabird.localdomain.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by mx.google.com with ESMTPSA id jd1sm1836928pbd.49.2015.01.07.05.21.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 05:21:02 -0800 (PST) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, Akihiro Tsukada Subject: [PATCH v2 1/4] dvb: qm1d1c0042: use dvb-core i2c binding model template Date: Wed, 7 Jan 2015 22:20:41 +0900 Message-Id: <1420636844-32553-2-git-send-email-tskd08@gmail.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1420636844-32553-1-git-send-email-tskd08@gmail.com> References: <1420636844-32553-1-git-send-email-tskd08@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Akihiro Tsukada Signed-off-by: Akihiro Tsukada --- drivers/media/tuners/qm1d1c0042.c | 60 +++++++++++++-------------------------- drivers/media/tuners/qm1d1c0042.h | 2 -- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/drivers/media/tuners/qm1d1c0042.c b/drivers/media/tuners/qm1d1c0042.c index 18bc745..b6d637d 100644 --- a/drivers/media/tuners/qm1d1c0042.c +++ b/drivers/media/tuners/qm1d1c0042.c @@ -29,6 +29,7 @@ #include #include +#include "dvb_i2c.h" #include "qm1d1c0042.h" #define QM1D1C0042_NUM_REGS 0x20 @@ -55,11 +56,6 @@ struct qm1d1c0042_state { u8 regs[QM1D1C0042_NUM_REGS]; }; -static struct qm1d1c0042_state *cfg_to_state(struct qm1d1c0042_config *c) -{ - return container_of(c, struct qm1d1c0042_state, cfg); -} - static int reg_write(struct qm1d1c0042_state *state, u8 reg, u8 val) { u8 wbuf[2] = { reg, val }; @@ -106,10 +102,12 @@ static int qm1d1c0042_set_srch_mode(struct qm1d1c0042_state *state, bool fast) return reg_write(state, 0x03, state->regs[0x03]); } -static int qm1d1c0042_wakeup(struct qm1d1c0042_state *state) +static int qm1d1c0042_wakeup(struct dvb_frontend *fe) { + struct qm1d1c0042_state *state; int ret; + state = fe->tuner_priv; state->regs[0x01] |= 1 << 3; /* BB_Reg_enable */ state->regs[0x01] &= (~(1 << 0)) & 0xff; /* NORMAL (wake-up) */ state->regs[0x05] &= (~(1 << 3)) & 0xff; /* pfd_rst NORMAL */ @@ -119,7 +117,7 @@ static int qm1d1c0042_wakeup(struct qm1d1c0042_state *state) if (ret < 0) dev_warn(&state->i2c->dev, "(%s) failed. [adap%d-fe%d]\n", - __func__, state->cfg.fe->dvb->num, state->cfg.fe->id); + __func__, fe->dvb->num, fe->id); return ret; } @@ -133,9 +131,6 @@ static int qm1d1c0042_set_config(struct dvb_frontend *fe, void *priv_cfg) state = fe->tuner_priv; cfg = priv_cfg; - if (cfg->fe) - state->cfg.fe = cfg->fe; - if (cfg->xtal_freq != QM1D1C0042_CFG_XTAL_DFLT) dev_warn(&state->i2c->dev, "(%s) changing xtal_freq not supported. ", __func__); @@ -359,7 +354,7 @@ static int qm1d1c0042_init(struct dvb_frontend *fe) goto failed; } - ret = qm1d1c0042_wakeup(state); + ret = qm1d1c0042_wakeup(fe); if (ret < 0) goto failed; @@ -395,33 +390,18 @@ static const struct dvb_tuner_ops qm1d1c0042_ops = { static int qm1d1c0042_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct qm1d1c0042_state *state; - struct qm1d1c0042_config *cfg; + struct dvb_i2c_tuner_config *cfg; struct dvb_frontend *fe; - - state = kzalloc(sizeof(*state), GFP_KERNEL); - if (!state) - return -ENOMEM; - state->i2c = client; + struct qm1d1c0042_state *state; cfg = client->dev.platform_data; fe = cfg->fe; - fe->tuner_priv = state; - qm1d1c0042_set_config(fe, cfg); - memcpy(&fe->ops.tuner_ops, &qm1d1c0042_ops, sizeof(qm1d1c0042_ops)); + state = fe->tuner_priv; + state->i2c = client; - i2c_set_clientdata(client, &state->cfg); - dev_info(&client->dev, "Sharp QM1D1C0042 attached.\n"); - return 0; -} + qm1d1c0042_set_config(fe, (void *)cfg->devcfg.priv_cfg); -static int qm1d1c0042_remove(struct i2c_client *client) -{ - struct qm1d1c0042_state *state; - - state = cfg_to_state(i2c_get_clientdata(client)); - state->cfg.fe->tuner_priv = NULL; - kfree(state); + dev_info(&client->dev, "Sharp QM1D1C0042 attached.\n"); return 0; } @@ -430,18 +410,16 @@ static const struct i2c_device_id qm1d1c0042_id[] = { {"qm1d1c0042", 0}, {} }; -MODULE_DEVICE_TABLE(i2c, qm1d1c0042_id); -static struct i2c_driver qm1d1c0042_driver = { - .driver = { - .name = "qm1d1c0042", - }, - .probe = qm1d1c0042_probe, - .remove = qm1d1c0042_remove, - .id_table = qm1d1c0042_id, +static const struct dvb_i2c_module_param qm1d1c0042_param = { + .ops.tuner_ops = &qm1d1c0042_ops, + .priv_probe = qm1d1c0042_probe, + + .priv_size = sizeof(struct qm1d1c0042_state), + .is_tuner = true, }; -module_i2c_driver(qm1d1c0042_driver); +DEFINE_DVB_I2C_MODULE(qm1d1c0042, qm1d1c0042_id, qm1d1c0042_param); MODULE_DESCRIPTION("Sharp QM1D1C0042 tuner"); MODULE_AUTHOR("Akihiro TSUKADA"); diff --git a/drivers/media/tuners/qm1d1c0042.h b/drivers/media/tuners/qm1d1c0042.h index 4f5c188..043787e 100644 --- a/drivers/media/tuners/qm1d1c0042.h +++ b/drivers/media/tuners/qm1d1c0042.h @@ -21,8 +21,6 @@ struct qm1d1c0042_config { - struct dvb_frontend *fe; - u32 xtal_freq; /* [kHz] */ /* currently ignored */ bool lpf; /* enable LPF */ bool fast_srch; /* enable fast search mode, no LPF */