From af294867a52bf718df835a688e8c786d550bee26 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 May 2008 20:49:40 +0200 Subject: i2c: Convert remaining new-style drivers to use module aliasing Update all the remaining new-style i2c drivers to use standard module aliasing instead of the old driver_name/type driver matching scheme. Note that the tuner driver is a bit quirky at the moment, as it overwrites i2c_client.name with arbitrary strings. We write "tuner" back on remove, to make sure that driver cycling will work properly, but there may still be troublesome corner cases. Signed-off-by: Jean Delvare --- drivers/media/video/tuner-core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'drivers/media/video/tuner-core.c') diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 5a75788b92ae..198f0afb812e 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -1115,7 +1115,6 @@ static int tuner_probe(struct i2c_client *client, if (NULL == t) return -ENOMEM; t->i2c = client; - strlcpy(client->name, "(tuner unset)", sizeof(client->name)); i2c_set_clientdata(client, t); t->type = UNSET; t->audmode = V4L2_TUNER_MODE_STEREO; @@ -1273,11 +1272,26 @@ static int tuner_remove(struct i2c_client *client) list_del(&t->list); kfree(t); + + /* The probing code has overwritten the device name, restore it so + that reloading the driver will work. Ideally the device name + should not be overwritten in the first place, but for now that + will do. */ + strlcpy(client->name, "tuner", I2C_NAME_SIZE); return 0; } /* ----------------------------------------------------------------------- */ +/* This driver supports many devices and the idea is to let the driver + detect which device is present. So rather than listing all supported + devices here, we pretend to support a single, fake device type. */ +static const struct i2c_device_id tuner_id[] = { + { "tuner", }, /* autodetect */ + { } +}; +MODULE_DEVICE_TABLE(i2c, tuner_id); + static struct v4l2_i2c_driver_data v4l2_i2c_data = { .name = "tuner", .driverid = I2C_DRIVERID_TUNER, @@ -1287,6 +1301,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = { .suspend = tuner_suspend, .resume = tuner_resume, .legacy_probe = tuner_legacy_probe, + .id_table = tuner_id, }; -- cgit v1.2.3 From 7271e60a950b3677f136a31e084bc4b0463c7018 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 26 May 2008 16:08:40 +0200 Subject: tuner: Do not alter i2c_client.name The tuner driver used to change i2c_client.name for its own needs, but it really shouldn't, as this field is used by i2c-core to do the device/driver matching. So, create and use a separate field for the tuner driver needs. Signed-off-by: Michael Krufky Signed-off-by: Jean Delvare --- drivers/media/video/tuner-core.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'drivers/media/video/tuner-core.c') diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 198f0afb812e..a0f7bc1edaa2 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -92,6 +92,7 @@ struct tuner { unsigned int type; /* chip type id */ unsigned int config; int (*tuner_callback) (void *dev, int command, int arg); + const char *name; }; /* standard i2c insmod options */ @@ -330,13 +331,13 @@ static void tuner_i2c_address_check(struct tuner *t) tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n"); tuner_warn("will soon be dropped. This message indicates that your\n"); tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n", - t->i2c->name, t->i2c->addr); + t->name, t->i2c->addr); tuner_warn("To ensure continued support for your device, please\n"); tuner_warn("send a copy of this message, along with full dmesg\n"); tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", - t->i2c->adapter->name, t->i2c->addr, t->type, t->i2c->name); + t->i2c->adapter->name, t->i2c->addr, t->type, t->name); tuner_warn("====================== WARNING! ======================\n"); } @@ -470,19 +471,17 @@ static void set_type(struct i2c_client *c, unsigned int type, if ((NULL == analog_ops->set_params) && (fe_tuner_ops->set_analog_params)) { - strlcpy(t->i2c->name, fe_tuner_ops->info.name, - sizeof(t->i2c->name)); + t->name = fe_tuner_ops->info.name; t->fe.analog_demod_priv = t; memcpy(analog_ops, &tuner_core_ops, sizeof(struct analog_demod_ops)); } else { - strlcpy(t->i2c->name, analog_ops->info.name, - sizeof(t->i2c->name)); + t->name = analog_ops->info.name; } - tuner_dbg("type set to %s\n", t->i2c->name); + tuner_dbg("type set to %s\n", t->name); if (t->mode_mask == T_UNINITIALIZED) t->mode_mask = new_mode_mask; @@ -1115,6 +1114,7 @@ static int tuner_probe(struct i2c_client *client, if (NULL == t) return -ENOMEM; t->i2c = client; + t->name = "(tuner unset)"; i2c_set_clientdata(client, t); t->type = UNSET; t->audmode = V4L2_TUNER_MODE_STEREO; @@ -1272,12 +1272,6 @@ static int tuner_remove(struct i2c_client *client) list_del(&t->list); kfree(t); - - /* The probing code has overwritten the device name, restore it so - that reloading the driver will work. Ideally the device name - should not be overwritten in the first place, but for now that - will do. */ - strlcpy(client->name, "tuner", I2C_NAME_SIZE); return 0; } -- cgit v1.2.3 From 4d3437df25325d517ee310d55989ce9630ff529e Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Mon, 26 May 2008 14:03:02 -0300 Subject: V4L/DVB (7904): v4l/tuner-core: consistent handling of return values change check_mode and set_mode to return negative errors and fix all callers Signed-off-by: Marcin Slusarz Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/tuner-core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/media/video/tuner-core.c') diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index a0f7bc1edaa2..1a9117457c8e 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -536,7 +536,7 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) static inline int check_mode(struct tuner *t, char *cmd) { if ((1 << t->mode & t->mode_mask) == 0) { - return EINVAL; + return -EINVAL; } switch (t->mode) { @@ -730,11 +730,11 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, t->mode = mode; - if (check_mode(t, cmd) == EINVAL) { + if (check_mode(t, cmd) == -EINVAL) { t->mode = T_STANDBY; if (analog_ops->standby) analog_ops->standby(&t->fe); - return EINVAL; + return -EINVAL; } return 0; } @@ -776,13 +776,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) break; case AUDC_SET_RADIO: if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO") - == EINVAL) + == -EINVAL) return 0; if (t->radio_freq) set_freq(client, t->radio_freq); break; case TUNER_SET_STANDBY: - if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) + if (check_mode(t, "TUNER_SET_STANDBY") == -EINVAL) return 0; t->mode = T_STANDBY; if (analog_ops->standby) @@ -790,7 +790,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) break; #ifdef CONFIG_VIDEO_ALLOW_V4L1 case VIDIOCSAUDIO: - if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) + if (check_mode(t, "VIDIOCSAUDIO") == -EINVAL) return 0; if (check_v4l2(t) == EINVAL) return 0; @@ -813,7 +813,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_v4l2(t) == EINVAL) return 0; - if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL) + if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==-EINVAL) return 0; if (vc->norm < ARRAY_SIZE(map)) @@ -827,7 +827,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { unsigned long *v = arg; - if (check_mode(t, "VIDIOCSFREQ") == EINVAL) + if (check_mode(t, "VIDIOCSFREQ") == -EINVAL) return 0; if (check_v4l2(t) == EINVAL) return 0; @@ -839,7 +839,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct video_tuner *vt = arg; - if (check_mode(t, "VIDIOCGTUNER") == EINVAL) + if (check_mode(t, "VIDIOCGTUNER") == -EINVAL) return 0; if (check_v4l2(t) == EINVAL) return 0; @@ -883,7 +883,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct video_audio *va = arg; - if (check_mode(t, "VIDIOCGAUDIO") == EINVAL) + if (check_mode(t, "VIDIOCGAUDIO") == -EINVAL) return 0; if (check_v4l2(t) == EINVAL) return 0; @@ -925,7 +925,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) v4l2_std_id *id = arg; if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD") - == EINVAL) + == -EINVAL) return 0; switch_v4l2(); @@ -941,7 +941,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) struct v4l2_frequency *f = arg; if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY") - == EINVAL) + == -EINVAL) return 0; switch_v4l2(); set_freq(client,f->frequency); @@ -952,7 +952,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_frequency *f = arg; - if (check_mode(t, "VIDIOC_G_FREQUENCY") == EINVAL) + if (check_mode(t, "VIDIOC_G_FREQUENCY") == -EINVAL) return 0; switch_v4l2(); f->type = t->mode; @@ -973,7 +973,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner *tuner = arg; - if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL) + if (check_mode(t, "VIDIOC_G_TUNER") == -EINVAL) return 0; switch_v4l2(); @@ -1020,7 +1020,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct v4l2_tuner *tuner = arg; - if (check_mode(t, "VIDIOC_S_TUNER") == EINVAL) + if (check_mode(t, "VIDIOC_S_TUNER") == -EINVAL) return 0; switch_v4l2(); -- cgit v1.2.3 From 427aad6fda607914945022e916827037d2d0db3d Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sun, 11 May 2008 19:58:59 -0300 Subject: V4L/DVB (7905): check_v4l2 should return -EINVAL on error check_v4l2 always returns 0, so this change is an noop for now, but a comment says it will return something else in the future Signed-off-by: Marcin Slusarz Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/tuner-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/media/video/tuner-core.c') diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 1a9117457c8e..0d12ace61665 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -792,7 +792,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) case VIDIOCSAUDIO: if (check_mode(t, "VIDIOCSAUDIO") == -EINVAL) return 0; - if (check_v4l2(t) == EINVAL) + if (check_v4l2(t) == -EINVAL) return 0; /* Should be implemented, since bttv calls it */ @@ -810,7 +810,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) }; struct video_channel *vc = arg; - if (check_v4l2(t) == EINVAL) + if (check_v4l2(t) == -EINVAL) return 0; if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==-EINVAL) @@ -829,7 +829,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_mode(t, "VIDIOCSFREQ") == -EINVAL) return 0; - if (check_v4l2(t) == EINVAL) + if (check_v4l2(t) == -EINVAL) return 0; set_freq(client, *v); @@ -841,7 +841,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_mode(t, "VIDIOCGTUNER") == -EINVAL) return 0; - if (check_v4l2(t) == EINVAL) + if (check_v4l2(t) == -EINVAL) return 0; if (V4L2_TUNER_RADIO == t->mode) { @@ -885,7 +885,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (check_mode(t, "VIDIOCGAUDIO") == -EINVAL) return 0; - if (check_v4l2(t) == EINVAL) + if (check_v4l2(t) == -EINVAL) return 0; if (V4L2_TUNER_RADIO == t->mode) { -- cgit v1.2.3