From: tskd08@gmail.com
To: linux-media@vger.kernel.org
Cc: m.chehab@samsung.com, Akihiro Tsukada <tskd08@gmail.com>
Subject: [PATCH v2 2/4] dvb: mxl301rf: use dvb-core i2c binding model template
Date: Wed, 7 Jan 2015 22:20:42 +0900 [thread overview]
Message-ID: <1420636844-32553-3-git-send-email-tskd08@gmail.com> (raw)
In-Reply-To: <1420636844-32553-1-git-send-email-tskd08@gmail.com>
From: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
---
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 <linux/kernel.h>
+#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 */
--
2.2.1
next prev parent reply other threads:[~2015-01-07 13:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 13:20 [PATCH v2 0/4] modify earth-pt3 and its dependees to use i2c template tskd08
2015-01-07 13:20 ` [PATCH v2 1/4] dvb: qm1d1c0042: use dvb-core i2c binding model template tskd08
2015-01-07 13:20 ` tskd08 [this message]
2015-01-07 13:20 ` [PATCH v2 3/4] dvb: tc90522: " tskd08
2015-01-07 13:20 ` [PATCH v2 4/4] dvb: earth-pt3: " tskd08
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420636844-32553-3-git-send-email-tskd08@gmail.com \
--to=tskd08@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.