From patchwork Wed Jan 7 13:20:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5584591 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 948BEBF6C3 for ; Wed, 7 Jan 2015 13:21:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B00BA20270 for ; Wed, 7 Jan 2015 13:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D44F72025B for ; Wed, 7 Jan 2015 13:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753061AbbAGNVI (ORCPT ); Wed, 7 Jan 2015 08:21:08 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:49989 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753048AbbAGNVH (ORCPT ); Wed, 7 Jan 2015 08:21:07 -0500 Received: by mail-pa0-f54.google.com with SMTP id fb1so4805519pad.13 for ; Wed, 07 Jan 2015 05:21:07 -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=lI1HO7Db0eMpykBINqjMAElrxIV+p5LzGw6y2OAffH4=; b=0NPxvMfuBUj1E+w3CPCHVQLbSHMn9xR0PR3QVuhANaeVWe+NDuAIbobkKpIRjQjNQf m8Xu4dtWwAlmTo4GmamutkAp2fZPYBLgHr2Qm8q8UYeDhZ2Rp/HQk462wrfv7pqdU/N5 jXp78YWyOachjpC3l4JeOc7wKCbMk5Im/ZRAcpmWiEeOtPT1X5y4sch9Y58xXuk+r8S6 igGkh2Ep+Ju+1wyzk3mXQ9djkTvWT1JrRXJMAxTo1qmYP/Vpn0obi1IrR4CF2KwrqjZN z4lExsgRKywaamqXF90hn2BjIHJKz46GABBziQ9mvKTEcbNeXC+bH5Xh3sqQcj+fhZF8 OpYQ== X-Received: by 10.69.26.130 with SMTP id iy2mr5228428pbd.93.1420636867028; Wed, 07 Jan 2015 05:21:07 -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.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 05:21:06 -0800 (PST) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, Akihiro Tsukada Subject: [PATCH v2 2/4] dvb: mxl301rf: use dvb-core i2c binding model template Date: Wed, 7 Jan 2015 22:20:42 +0900 Message-Id: <1420636844-32553-3-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/mxl301rf.c | 50 +++++++++++------------------------------ drivers/media/tuners/mxl301rf.h | 2 +- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/drivers/media/tuners/mxl301rf.c b/drivers/media/tuners/mxl301rf.c index 1575a5d..d94a692 100644 --- a/drivers/media/tuners/mxl301rf.c +++ b/drivers/media/tuners/mxl301rf.c @@ -29,6 +29,8 @@ */ #include +#include "dvb_i2c.h" + #include "mxl301rf.h" struct mxl301rf_state { @@ -36,11 +38,6 @@ struct mxl301rf_state { struct i2c_client *i2c; }; -static struct mxl301rf_state *cfg_to_state(struct mxl301rf_config *c) -{ - return container_of(c, struct mxl301rf_state, cfg); -} - static int raw_write(struct mxl301rf_state *state, const u8 *buf, int len) { int ret; @@ -295,54 +292,33 @@ static const struct dvb_tuner_ops mxl301rf_ops = { static int mxl301rf_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct dvb_i2c_tuner_config *cfg; struct mxl301rf_state *state; - struct mxl301rf_config *cfg; - struct dvb_frontend *fe; - state = kzalloc(sizeof(*state), GFP_KERNEL); - if (!state) - return -ENOMEM; - - state->i2c = client; cfg = client->dev.platform_data; + state = cfg->fe->tuner_priv; + state->i2c = client; - memcpy(&state->cfg, cfg, sizeof(state->cfg)); - fe = cfg->fe; - fe->tuner_priv = state; - memcpy(&fe->ops.tuner_ops, &mxl301rf_ops, sizeof(mxl301rf_ops)); + memcpy(&state->cfg, cfg->devcfg.priv_cfg, sizeof(state->cfg)); - i2c_set_clientdata(client, &state->cfg); dev_info(&client->dev, "MaxLinear MxL301RF attached.\n"); return 0; } -static int mxl301rf_remove(struct i2c_client *client) -{ - struct mxl301rf_state *state; - - state = cfg_to_state(i2c_get_clientdata(client)); - state->cfg.fe->tuner_priv = NULL; - kfree(state); - return 0; -} - - static const struct i2c_device_id mxl301rf_id[] = { {"mxl301rf", 0}, {} }; -MODULE_DEVICE_TABLE(i2c, mxl301rf_id); -static struct i2c_driver mxl301rf_driver = { - .driver = { - .name = "mxl301rf", - }, - .probe = mxl301rf_probe, - .remove = mxl301rf_remove, - .id_table = mxl301rf_id, +static const struct dvb_i2c_module_param mxl301rf_param = { + .ops.tuner_ops = &mxl301rf_ops, + .priv_probe = mxl301rf_probe, + + .priv_size = sizeof(struct mxl301rf_state), + .is_tuner = true, }; -module_i2c_driver(mxl301rf_driver); +DEFINE_DVB_I2C_MODULE(mxl301rf, mxl301rf_id, mxl301rf_param); MODULE_DESCRIPTION("MaxLinear MXL301RF tuner"); MODULE_AUTHOR("Akihiro TSUKADA"); diff --git a/drivers/media/tuners/mxl301rf.h b/drivers/media/tuners/mxl301rf.h index 19e6840..069a6a0 100644 --- a/drivers/media/tuners/mxl301rf.h +++ b/drivers/media/tuners/mxl301rf.h @@ -20,7 +20,7 @@ #include "dvb_frontend.h" struct mxl301rf_config { - struct dvb_frontend *fe; + /* none now */ }; #endif /* MXL301RF_H */