From patchwork Fri Jan 16 11:24:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5647451 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 70076C058D for ; Fri, 16 Jan 2015 11:25:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91043201EF for ; Fri, 16 Jan 2015 11:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6DD0201C0 for ; Fri, 16 Jan 2015 11:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680AbbAPLY5 (ORCPT ); Fri, 16 Jan 2015 06:24:57 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33761 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbbAPLY5 (ORCPT ); Fri, 16 Jan 2015 06:24:57 -0500 Received: by mail-pd0-f169.google.com with SMTP id z10so22255794pdj.0 for ; Fri, 16 Jan 2015 03:24:56 -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=BywmzcXixlaQORLeHk/011r3gwQSq1koRlN0toVt0Mo=; b=zeVfuBLBAkLVCt2Nh5soG6UA9LTDyJRzbQ7svuj+zWaFwHLRd7fXHY4FkqPvqqiszb qLMtEtuGb5UgYlkLQsi49C4SR8kMFPi6Z9VGI6MCFK3QjiWdXP9iWfZhqbYoNR3pV3i5 sn1Dza4iGUfJQyPmjKEGxu3aP5iXU2/dxS7BkAB3AHEkjnzEGaFMEocTG00UhOSCjYjF EFoJO8M+Q/j1ZXLHySSU0mH/WPCItbDEOe+m7WSzQNZcKH5e5Yfz4+hW03SoRQ7qqIlK bTBJWMoOCaHiZDdaQfNR9LfeSQG4tSxc1obOT+W8EzDO3KDKS+vkFq9CHKobeca+3Tu4 Chpg== X-Received: by 10.68.219.231 with SMTP id pr7mr11372902pbc.73.1421407496706; Fri, 16 Jan 2015 03:24:56 -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.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 03:24:55 -0800 (PST) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, Akihiro Tsukada Subject: [PATCH v3 2/4] dvb: mxl301rf: use dvb-core i2c binding model template Date: Fri, 16 Jan 2015 20:24:38 +0900 Message-Id: <1421407480-9122-3-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/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 */