Re: [PATCH v3 1/5] dvb-frontends/dvb-pll: add i2c driver support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/26/2018 09:06 PM, tskd08@xxxxxxxxx wrote:
From: Akihiro Tsukada <tskd08@xxxxxxxxx>

registers the module as an i2c driver,
but keeps dvb_pll_attach() untouched for compatibility.

Signed-off-by: Akihiro Tsukada <tskd08@xxxxxxxxx>
---
  drivers/media/dvb-frontends/dvb-pll.c | 49 +++++++++++++++++++++++++++++++++++
  drivers/media/dvb-frontends/dvb-pll.h |  6 +++++
  2 files changed, 55 insertions(+)

diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c
index 5553b89b804..614a5ea3b00 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -827,6 +827,55 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
  }
  EXPORT_SYMBOL(dvb_pll_attach);
+
+static int
+dvb_pll_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+	struct dvb_pll_config *cfg;
+	struct dvb_frontend *fe;
+	unsigned int desc_id;
+
+	cfg = client->dev.platform_data;
+	fe = cfg->fe;
+	i2c_set_clientdata(client, fe);
+	desc_id = cfg->desc_id;
+
+	if (!dvb_pll_attach(fe, client->addr, client->adapter, desc_id))
+		return -ENOMEM;
+
+	dev_info(&client->dev, "DVB Simple Tuner attached.\n");
+	return 0;
+}
+
+static int dvb_pll_remove(struct i2c_client *client)
+{
+	struct dvb_frontend *fe;
+
+	fe = i2c_get_clientdata(client);
+	dvb_pll_release(fe);
+	return 0;
+}
+
+
+static const struct i2c_device_id dvb_pll_id[] = {
+	{"dvb_pll", 0},
+	{}
+};
+
+
+MODULE_DEVICE_TABLE(i2c, dvb_pll_id);
+
+static struct i2c_driver dvb_pll_driver = {
+	.driver = {
+		.name = "dvb_pll",
+	},
+	.probe    = dvb_pll_probe,
+	.remove   = dvb_pll_remove,
+	.id_table = dvb_pll_id,
+};
+
+module_i2c_driver(dvb_pll_driver);
+
  MODULE_DESCRIPTION("dvb pll library");
  MODULE_AUTHOR("Gerd Knorr");
  MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dvb-pll.h b/drivers/media/dvb-frontends/dvb-pll.h
index ca885e71d2f..15bda0d0c15 100644
--- a/drivers/media/dvb-frontends/dvb-pll.h
+++ b/drivers/media/dvb-frontends/dvb-pll.h
@@ -30,6 +30,12 @@
  #define DVB_PLL_TDEE4		       18
  #define DVB_PLL_THOMSON_DTT7520X       19
+struct dvb_pll_config {
+	struct dvb_frontend *fe;
+
+	unsigned int desc_id;
+};
+
  #if IS_REACHABLE(CONFIG_DVB_PLL)
  /**
   * Attach a dvb-pll to the supplied frontend structure.


Hello
Idea is correct, but I would use pll chip names for passing correct pll type for driver - that field is just for that.

Like that:
static const struct i2c_device_id dvb_pll_id[] = {
	{"PLL-NAME1", 0},
	{"PLL-NAME2", 1},
	{"PLL-NAME3", 2},
	{}
};

See si2157 for example.

regards
Antti


--
http://palosaari.fi/



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux