]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (6006): tuner: move last_div to tuner-simple private data
authorMichael Krufky <mkrufky@linuxtv.org>
Sat, 11 Aug 2007 18:42:12 +0000 (15:42 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 01:05:01 +0000 (22:05 -0300)
tuner-simple is the only sub-driver that uses last_div, so we
can free up two bytes of memory for all other tuners, by moving
this into tuner-simple's private data area.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/tuner-driver.h
drivers/media/video/tuner-simple.c

index 0334a9125077939d859989649491487e90391f42..fa51b7cec691a91e3d69a2953234e7cbe4e35b69 100644 (file)
@@ -49,7 +49,6 @@ struct tuner {
 
        unsigned int tv_freq;   /* keep track of the current settings */
        unsigned int radio_freq;
-       u16          last_div;
        unsigned int audmode;
        v4l2_std_id  std;
 
index 10a7d36a26468dc7aab8378e386fecd0ebc2da46..572f22423b98e0cef0b6c0c40da7fb2bc38c8ea0 100644 (file)
@@ -82,6 +82,10 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
 #define TUNER_PLL_LOCKED   0x40
 #define TUNER_STEREO_MK3   0x04
 
+struct tuner_simple_priv {
+       u16 last_div;
+};
+
 /* ---------------------------------------------------------------------- */
 
 static int tuner_getstatus(struct i2c_client *c)
@@ -126,6 +130,7 @@ static int tuner_stereo(struct i2c_client *c)
 static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
 {
        struct tuner *t = i2c_get_clientdata(c);
+       struct tuner_simple_priv *priv = t->priv;
        u8 config, cb, tuneraddr;
        u16 div;
        struct tunertype *tun;
@@ -291,7 +296,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                break;
        }
 
-       if (params->cb_first_if_lower_freq && div < t->last_div) {
+       if (params->cb_first_if_lower_freq && div < priv->last_div) {
                buffer[0] = config;
                buffer[1] = cb;
                buffer[2] = (div>>8) & 0x7f;
@@ -302,7 +307,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                buffer[2] = config;
                buffer[3] = cb;
        }
-       t->last_div = div;
+       priv->last_div = div;
        if (params->has_tda9887) {
                int config = 0;
                int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
@@ -399,6 +404,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
 {
        struct tunertype *tun;
        struct tuner *t = i2c_get_clientdata(c);
+       struct tuner_simple_priv *priv = t->priv;
        u8 buffer[4];
        u16 div;
        int rc, j;
@@ -464,7 +470,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
           freq * (1/800) */
        div = (freq + 400) / 800;
 
-       if (params->cb_first_if_lower_freq && div < t->last_div) {
+       if (params->cb_first_if_lower_freq && div < priv->last_div) {
                buffer[0] = buffer[2];
                buffer[1] = buffer[3];
                buffer[2] = (div>>8) & 0x7f;
@@ -476,7 +482,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
 
        tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
               buffer[0],buffer[1],buffer[2],buffer[3]);
-       t->last_div = div;
+       priv->last_div = div;
 
        if (params->has_tda9887) {
                int config = 0;
@@ -498,16 +504,31 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
                tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
 }
 
+static void tuner_release(struct i2c_client *c)
+{
+       struct tuner *t = i2c_get_clientdata(c);
+
+       kfree(t->priv);
+       t->priv = NULL;
+}
+
 static struct tuner_operations simple_tuner_ops = {
        .set_tv_freq    = default_set_tv_freq,
        .set_radio_freq = default_set_radio_freq,
        .has_signal     = tuner_signal,
        .is_stereo      = tuner_stereo,
+       .release        = tuner_release,
 };
 
 int default_tuner_init(struct i2c_client *c)
 {
        struct tuner *t = i2c_get_clientdata(c);
+       struct tuner_simple_priv *priv = NULL;
+
+       priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL);
+       if (priv == NULL)
+               return -ENOMEM;
+       t->priv = priv;
 
        tuner_info("type set to %d (%s)\n",
                   t->type, tuners[t->type].name);