]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/media/i2c/tvp5150.c
Merge branch 'acpi-hotplug'
[karo-tx-linux.git] / drivers / media / i2c / tvp5150.c
index 485159a3c0b72f1739a7cd12feab3d6453910a1d..89c0b13463b73354b3fa56ce5bcc57b2fe989613 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <media/v4l2-device.h>
 #include <media/tvp5150.h>
-#include <media/v4l2-chip-ident.h>
 #include <media/v4l2-ctrls.h>
 
 #include "tvp5150_reg.h"
@@ -727,13 +726,11 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
 
        /* First tests should be against specific std */
 
-       if (std == V4L2_STD_ALL) {
-               fmt = VIDEO_STD_AUTO_SWITCH_BIT;        /* Autodetect mode */
-       } else if (std & V4L2_STD_NTSC_443) {
+       if (std == V4L2_STD_NTSC_443) {
                fmt = VIDEO_STD_NTSC_4_43_BIT;
-       } else if (std & V4L2_STD_PAL_M) {
+       } else if (std == V4L2_STD_PAL_M) {
                fmt = VIDEO_STD_PAL_M_BIT;
-       } else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) {
+       } else if (std == V4L2_STD_PAL_N || std == V4L2_STD_PAL_Nc) {
                fmt = VIDEO_STD_PAL_COMBINATION_N_BIT;
        } else {
                /* Then, test against generic ones */
@@ -1031,31 +1028,11 @@ static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f
        return 0;
 }
 
-static int tvp5150_g_chip_ident(struct v4l2_subdev *sd,
-                               struct v4l2_dbg_chip_ident *chip)
-{
-       int rev;
-       struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-       rev = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER) << 8 |
-             tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
-
-       return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVP5150,
-                                         rev);
-}
-
-
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
 {
        int res;
 
-       struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-       if (!v4l2_chip_match_i2c_client(client, &reg->match))
-               return -EINVAL;
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
        res = tvp5150_read(sd, reg->reg & 0xff);
        if (res < 0) {
                v4l2_err(sd, "%s: failed with error = %d\n", __func__, res);
@@ -1069,12 +1046,6 @@ static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *
 
 static int tvp5150_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg)
 {
-       struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-       if (!v4l2_chip_match_i2c_client(client, &reg->match))
-               return -EINVAL;
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
        tvp5150_write(sd, reg->reg & 0xff, reg->val & 0xff);
        return 0;
 }
@@ -1098,7 +1069,6 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
        .log_status = tvp5150_log_status,
        .s_std = tvp5150_s_std,
        .reset = tvp5150_reset,
-       .g_chip_ident = tvp5150_g_chip_ident,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        .g_register = tvp5150_g_register,
        .s_register = tvp5150_s_register,
@@ -1152,10 +1122,9 @@ static int tvp5150_probe(struct i2c_client *c,
             I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
                return -EIO;
 
-       core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
-       if (!core) {
+       core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
+       if (!core)
                return -ENOMEM;
-       }
        sd = &core->sd;
        v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
 
@@ -1166,7 +1135,7 @@ static int tvp5150_probe(struct i2c_client *c,
        for (i = 0; i < 4; i++) {
                res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
                if (res < 0)
-                       goto free_core;
+                       return res;
                tvp5150_id[i] = res;
        }
 
@@ -1209,7 +1178,7 @@ static int tvp5150_probe(struct i2c_client *c,
        if (core->hdl.error) {
                res = core->hdl.error;
                v4l2_ctrl_handler_free(&core->hdl);
-               goto free_core;
+               return res;
        }
        v4l2_ctrl_handler_setup(&core->hdl);
 
@@ -1225,10 +1194,6 @@ static int tvp5150_probe(struct i2c_client *c,
        if (debug > 1)
                tvp5150_log_status(sd);
        return 0;
-
-free_core:
-       kfree(core);
-       return res;
 }
 
 static int tvp5150_remove(struct i2c_client *c)
@@ -1242,7 +1207,6 @@ static int tvp5150_remove(struct i2c_client *c)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&decoder->hdl);
-       kfree(to_tvp5150(sd));
        return 0;
 }