From patchwork Fri Jan 16 11:24:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5647461 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2571F9F357 for ; Fri, 16 Jan 2015 11:25:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21FDD201EF for ; Fri, 16 Jan 2015 11:25:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 085F5201C0 for ; Fri, 16 Jan 2015 11:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754103AbbAPLZB (ORCPT ); Fri, 16 Jan 2015 06:25:01 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:53905 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754070AbbAPLZA (ORCPT ); Fri, 16 Jan 2015 06:25:00 -0500 Received: by mail-pd0-f169.google.com with SMTP id z10so22256012pdj.0 for ; Fri, 16 Jan 2015 03:25:00 -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=3UyG42NtLdE/2lcCiWXqEd2MjH4JChJVzuAx92U7EiU=; b=0hHep8o8BY6zEocT/lvchQ6etFAJ9sidckbCsFDs+6AxbgsPOUM9OmHUJz7Rf9Uo4b iu17xUbyGvxtiW1ZGpQ0kllyYpkB9bUBu0d7N1DOmr3pp6NRVdAlAgmzjSajBtYNdNM7 EEoSxVkx829wz1EWL3em8EIf8S5M/fp2va7jUviCTsAs3SaIfWVZsfID1LF3DKTiJ8IS dVRa9NF2obqP7xHgX90Rwyupn4jVV58psa6ZeIm9XT0Qe5RWpEIOtp8ZP0NOV9+heMnC ocoanb8kh9ygzt2rDAGT5th9wHzoXuquZGKFwhTV7iE5U8UuLbhVbB5/Wt/5jmpktFfU WLCw== X-Received: by 10.70.43.165 with SMTP id x5mr21511634pdl.107.1421407500074; Fri, 16 Jan 2015 03:25:00 -0800 (PST) Received: from seabird.localdomain.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by mx.google.com with ESMTPSA id c9sm1060415pdm.51.2015.01.16.03.24.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 03:24:59 -0800 (PST) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, Akihiro Tsukada Subject: [PATCH v3 3/4] dvb: tc90522: use dvb-core i2c binding model template Date: Fri, 16 Jan 2015 20:24:39 +0900 Message-Id: <1421407480-9122-4-git-send-email-tskd08@gmail.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421407480-9122-1-git-send-email-tskd08@gmail.com> References: <1421407480-9122-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=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 From: Akihiro Tsukada Signed-off-by: Akihiro Tsukada --- drivers/media/dvb-frontends/tc90522.c | 64 ++++++++++++++++------------------- drivers/media/dvb-frontends/tc90522.h | 8 ++--- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c index b35d65c..123f42d 100644 --- a/drivers/media/dvb-frontends/tc90522.c +++ b/drivers/media/dvb-frontends/tc90522.c @@ -30,6 +30,7 @@ #include #include #include +#include "dvb_i2c.h" #include "dvb_math.h" #include "tc90522.h" @@ -39,7 +40,6 @@ struct tc90522_state { struct tc90522_config cfg; - struct dvb_frontend fe; struct i2c_client *i2c_client; struct i2c_adapter tuner_i2c; @@ -98,11 +98,6 @@ static int reg_read(struct tc90522_state *state, u8 reg, u8 *val, u8 len) return ret; } -static struct tc90522_state *cfg_to_state(struct tc90522_config *c) -{ - return container_of(c, struct tc90522_state, cfg); -} - static int tc90522s_set_tsid(struct dvb_frontend *fe) { @@ -512,7 +507,7 @@ static int tc90522_set_frontend(struct dvb_frontend *fe) return 0; failed: - dev_warn(&state->tuner_i2c.dev, "(%s) failed. [adap%d-fe%d]\n", + dev_warn(&state->i2c_client->dev, "(%s) failed. [adap%d-fe%d]\n", __func__, fe->dvb->num, fe->id); return ret; } @@ -587,7 +582,7 @@ static int tc90522_sleep(struct dvb_frontend *fe) } } if (ret < 0) - dev_warn(&state->tuner_i2c.dev, + dev_warn(&state->i2c_client->dev, "(%s) failed. [adap%d-fe%d]\n", __func__, fe->dvb->num, fe->id); return ret; @@ -620,7 +615,7 @@ static int tc90522_init(struct dvb_frontend *fe) } } if (ret < 0) { - dev_warn(&state->tuner_i2c.dev, + dev_warn(&state->i2c_client->dev, "(%s) failed. [adap%d-fe%d]\n", __func__, fe->dvb->num, fe->id); return ret; @@ -640,6 +635,7 @@ static int tc90522_init(struct dvb_frontend *fe) static int tc90522_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { + struct dvb_frontend *fe; struct tc90522_state *state; struct i2c_msg *new_msgs; int i, j; @@ -658,7 +654,8 @@ tc90522_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (!new_msgs) return -ENOMEM; - state = i2c_get_adapdata(adap); + fe = i2c_get_adapdata(adap); + state = fe->demodulator_priv; p = wbuf; bufend = wbuf + sizeof(wbuf); for (i = 0, j = 0; i < num; i++, j++) { @@ -766,51 +763,51 @@ static const struct dvb_frontend_ops tc90522_ops_ter = { static int tc90522_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct dvb_frontend *fe; struct tc90522_state *state; - struct tc90522_config *cfg; + struct dvb_i2c_dev_config *cfg; const struct dvb_frontend_ops *ops; struct i2c_adapter *adap; int ret; - state = kzalloc(sizeof(*state), GFP_KERNEL); - if (!state) - return -ENOMEM; + fe = i2c_get_clientdata(client); + state = fe->demodulator_priv; state->i2c_client = client; cfg = client->dev.platform_data; - memcpy(&state->cfg, cfg, sizeof(state->cfg)); - cfg->fe = state->cfg.fe = &state->fe; + if (cfg && cfg->priv_cfg) + memcpy(&state->cfg, cfg->priv_cfg, sizeof(state->cfg)); ops = id->driver_data == 0 ? &tc90522_ops_sat : &tc90522_ops_ter; - memcpy(&state->fe.ops, ops, sizeof(*ops)); - state->fe.demodulator_priv = state; + memcpy(&fe->ops, ops, sizeof(*ops)); adap = &state->tuner_i2c; adap->owner = THIS_MODULE; adap->algo = &tc90522_tuner_i2c_algo; adap->dev.parent = &client->dev; strlcpy(adap->name, "tc90522_sub", sizeof(adap->name)); - i2c_set_adapdata(adap, state); ret = i2c_add_adapter(adap); if (ret < 0) - goto err; - cfg->tuner_i2c = state->cfg.tuner_i2c = adap; + goto err_mem; + if (cfg && cfg->out) + *cfg->out = (struct tc90522_out *)adap; + i2c_set_adapdata(adap, fe); /* used in tc90522_master_xfer() */ - i2c_set_clientdata(client, &state->cfg); dev_info(&client->dev, "Toshiba TC90522 attached.\n"); return 0; -err: +err_mem: kfree(state); return ret; } static int tc90522_remove(struct i2c_client *client) { + struct dvb_frontend *fe; struct tc90522_state *state; - state = cfg_to_state(i2c_get_clientdata(client)); + fe = i2c_get_clientdata(client); + state = fe->demodulator_priv; i2c_del_adapter(&state->tuner_i2c); - kfree(state); return 0; } @@ -820,18 +817,17 @@ static const struct i2c_device_id tc90522_id[] = { { TC90522_I2C_DEV_TER, 1 }, {} }; -MODULE_DEVICE_TABLE(i2c, tc90522_id); -static struct i2c_driver tc90522_driver = { - .driver = { - .name = "tc90522", - }, - .probe = tc90522_probe, - .remove = tc90522_remove, - .id_table = tc90522_id, +static const struct dvb_i2c_module_param tc90522_param = { + .ops.fe_ops = NULL, + .priv_probe = tc90522_probe, + .priv_remove = tc90522_remove, + + .priv_size = sizeof(struct tc90522_state), + .is_tuner = false, }; -module_i2c_driver(tc90522_driver); +DEFINE_DVB_I2C_MODULE(tc90522, tc90522_id, tc90522_param); MODULE_DESCRIPTION("Toshiba TC90522 frontend"); MODULE_AUTHOR("Akihiro TSUKADA"); diff --git a/drivers/media/dvb-frontends/tc90522.h b/drivers/media/dvb-frontends/tc90522.h index b1cbddf..4b69d03 100644 --- a/drivers/media/dvb-frontends/tc90522.h +++ b/drivers/media/dvb-frontends/tc90522.h @@ -32,11 +32,11 @@ #define TC90522_I2C_DEV_TER "tc90522ter" struct tc90522_config { - /* [OUT] frontend returned by driver */ - struct dvb_frontend *fe; + /* none now */ +}; - /* [OUT] tuner I2C adapter returned by driver */ - struct i2c_adapter *tuner_i2c; +struct tc90522_out { + struct i2c_adapter demod_bus; }; #endif /* TC90522_H */