]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/media/i2c/msp3400-driver.c
Merge tag 'for-linus-4.10-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-bionic-kernel.git] / drivers / media / i2c / msp3400-driver.c
index 503b7c4f0a9bbd0929bdf59dcfa690851e0d0396..201a9800ea52a8e8860acec804ac7a989e54b596 100644 (file)
@@ -146,11 +146,11 @@ int msp_reset(struct i2c_client *client)
                },
        };
 
-       v4l_dbg(3, msp_debug, client, "msp_reset\n");
+       dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_reset\n");
        if (i2c_transfer(client->adapter, &reset[0], 1) != 1 ||
            i2c_transfer(client->adapter, &reset[1], 1) != 1 ||
            i2c_transfer(client->adapter, test, 2) != 2) {
-               v4l_err(client, "chip reset failed\n");
+               dev_err(&client->dev, "chip reset failed\n");
                return -1;
        }
        return 0;
@@ -182,17 +182,17 @@ static int msp_read(struct i2c_client *client, int dev, int addr)
        for (err = 0; err < 3; err++) {
                if (i2c_transfer(client->adapter, msgs, 2) == 2)
                        break;
-               v4l_warn(client, "I/O error #%d (read 0x%02x/0x%02x)\n", err,
+               dev_warn(&client->dev, "I/O error #%d (read 0x%02x/0x%02x)\n", err,
                       dev, addr);
                schedule_timeout_interruptible(msecs_to_jiffies(10));
        }
        if (err == 3) {
-               v4l_warn(client, "resetting chip, sound will go off.\n");
+               dev_warn(&client->dev, "resetting chip, sound will go off.\n");
                msp_reset(client);
                return -1;
        }
        retval = read[0] << 8 | read[1];
-       v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n",
+       dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_read(0x%x, 0x%x): 0x%x\n",
                        dev, addr, retval);
        return retval;
 }
@@ -218,17 +218,17 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
        buffer[3] = val  >> 8;
        buffer[4] = val  &  0xff;
 
-       v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n",
+       dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_write(0x%x, 0x%x, 0x%x)\n",
                        dev, addr, val);
        for (err = 0; err < 3; err++) {
                if (i2c_master_send(client, buffer, 5) == 5)
                        break;
-               v4l_warn(client, "I/O error #%d (write 0x%02x/0x%02x)\n", err,
+               dev_warn(&client->dev, "I/O error #%d (write 0x%02x/0x%02x)\n", err,
                       dev, addr);
                schedule_timeout_interruptible(msecs_to_jiffies(10));
        }
        if (err == 3) {
-               v4l_warn(client, "resetting chip, sound will go off.\n");
+               dev_warn(&client->dev, "resetting chip, sound will go off.\n");
                msp_reset(client);
                return -1;
        }
@@ -301,7 +301,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
        } else
                state->acb = 0xf60; /* Mute Input and SCART 1 Output */
 
-       v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n",
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "scart switch: %s => %d (ACB=0x%04x)\n",
                                        scart_names[in], out, state->acb);
        msp_write_dsp(client, 0x13, state->acb);
 
@@ -359,7 +359,7 @@ static int msp_s_ctrl(struct v4l2_ctrl *ctrl)
                if (!reallymuted)
                        val = (val * 0x7f / 65535) << 8;
 
-               v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
+               dev_dbg_lvl(&client->dev, 1, msp_debug, "mute=%s scanning=%s volume=%d\n",
                                state->muted->val ? "on" : "off",
                                state->scan_in_progress ? "yes" : "no",
                                state->volume->val);
@@ -426,7 +426,7 @@ static int msp_s_radio(struct v4l2_subdev *sd)
        if (state->radio)
                return 0;
        state->radio = 1;
-       v4l_dbg(1, msp_debug, client, "switching to radio mode\n");
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "switching to radio mode\n");
        state->watch_stereo = 0;
        switch (state->opmode) {
        case OPMODE_MANUAL:
@@ -461,7 +461,7 @@ static int msp_querystd(struct v4l2_subdev *sd, v4l2_std_id *id)
 
        *id &= state->detected_std;
 
-       v4l_dbg(2, msp_debug, client,
+       dev_dbg_lvl(&client->dev, 2, msp_debug,
                "detected standard: %s(0x%08Lx)\n",
                msp_standard_std_name(state->std), state->detected_std);
 
@@ -555,7 +555,7 @@ static int msp_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq)
        struct msp_state *state = to_state(sd);
        struct i2c_client *client = v4l2_get_subdevdata(sd);
 
-       v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", freq);
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "Setting I2S speed to %d\n", freq);
 
        switch (freq) {
                case 1024000:
@@ -579,7 +579,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
 
        if (state->opmode == OPMODE_AUTOSELECT)
                msp_detect_stereo(client);
-       v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n",
+       dev_info(&client->dev, "%s rev1 = 0x%04x rev2 = 0x%04x\n",
                        client->name, state->rev1, state->rev2);
        snprintf(prefix, sizeof(prefix), "%s: Audio:    ", sd->name);
        v4l2_ctrl_handler_log_status(&state->hdl, prefix);
@@ -596,23 +596,23 @@ static int msp_log_status(struct v4l2_subdev *sd)
                default: p = "unknown"; break;
        }
        if (state->mode == MSP_MODE_EXTERN) {
-               v4l_info(client, "Mode:     %s\n", p);
+               dev_info(&client->dev, "Mode:     %s\n", p);
        } else if (state->opmode == OPMODE_MANUAL) {
-               v4l_info(client, "Mode:     %s (%s%s)\n", p,
+               dev_info(&client->dev, "Mode:     %s (%s%s)\n", p,
                                (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
                                (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
        } else {
                if (state->opmode == OPMODE_AUTODETECT)
-                       v4l_info(client, "Mode:     %s\n", p);
-               v4l_info(client, "Standard: %s (%s%s)\n",
+                       dev_info(&client->dev, "Mode:     %s\n", p);
+               dev_info(&client->dev, "Standard: %s (%s%s)\n",
                                msp_standard_std_name(state->std),
                                (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
                                (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
        }
-       v4l_info(client, "Audmode:  0x%04x\n", state->audmode);
-       v4l_info(client, "Routing:  0x%08x (input) 0x%08x (output)\n",
+       dev_info(&client->dev, "Audmode:  0x%04x\n", state->audmode);
+       dev_info(&client->dev, "Routing:  0x%08x (input) 0x%08x (output)\n",
                        state->route_in, state->route_out);
-       v4l_info(client, "ACB:      0x%04x\n", state->acb);
+       dev_info(&client->dev, "ACB:      0x%04x\n", state->acb);
        return 0;
 }
 
@@ -620,7 +620,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
 static int msp_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
-       v4l_dbg(1, msp_debug, client, "suspend\n");
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "suspend\n");
        msp_reset(client);
        return 0;
 }
@@ -628,7 +628,7 @@ static int msp_suspend(struct device *dev)
 static int msp_resume(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
-       v4l_dbg(1, msp_debug, client, "resume\n");
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "resume\n");
        msp_wake_thread(client);
        return 0;
 }
@@ -670,6 +670,13 @@ static const struct v4l2_subdev_ops msp_ops = {
 
 /* ----------------------------------------------------------------------- */
 
+
+static const char * const opmode_str[] = {
+       [OPMODE_MANUAL] = "manual",
+       [OPMODE_AUTODETECT] = "autodetect",
+       [OPMODE_AUTOSELECT] = "autodetect and autoselect",
+};
+
 static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
        struct msp_state *state;
@@ -689,7 +696,7 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
                strlcpy(client->name, "msp3400", sizeof(client->name));
 
        if (msp_reset(client) == -1) {
-               v4l_dbg(1, msp_debug, client, "msp3400 not found\n");
+               dev_dbg_lvl(&client->dev, 1, msp_debug, "msp3400 not found\n");
                return -ENODEV;
        }
 
@@ -724,10 +731,10 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
        state->rev1 = msp_read_dsp(client, 0x1e);
        if (state->rev1 != -1)
                state->rev2 = msp_read_dsp(client, 0x1f);
-       v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n",
+       dev_dbg_lvl(&client->dev, 1, msp_debug, "rev1=0x%04x, rev2=0x%04x\n",
                        state->rev1, state->rev2);
        if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
-               v4l_dbg(1, msp_debug, client,
+               dev_dbg_lvl(&client->dev, 1, msp_debug,
                                "not an msp3400 (cannot read chip version)\n");
                return -ENODEV;
        }
@@ -791,7 +798,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
                msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
 
        state->opmode = opmode;
-       if (state->opmode == OPMODE_AUTO) {
+       if (state->opmode < OPMODE_MANUAL
+           || state->opmode > OPMODE_AUTOSELECT) {
                /* MSP revision G and up have both autodetect and autoselect */
                if (msp_revision >= 'G')
                        state->opmode = OPMODE_AUTOSELECT;
@@ -829,43 +837,35 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
        v4l2_ctrl_cluster(2, &state->volume);
        v4l2_ctrl_handler_setup(hdl);
 
-       /* hello world :-) */
-       v4l_info(client, "MSP%d4%02d%c-%c%d found @ 0x%x (%s)\n",
-                       msp_family, msp_product,
-                       msp_revision, msp_hard, msp_rom,
-                       client->addr << 1, client->adapter->name);
-       v4l_info(client, "%s ", client->name);
-       if (state->has_nicam && state->has_radio)
-               printk(KERN_CONT "supports nicam and radio, ");
-       else if (state->has_nicam)
-               printk(KERN_CONT "supports nicam, ");
-       else if (state->has_radio)
-               printk(KERN_CONT "supports radio, ");
-       printk(KERN_CONT "mode is ");
+       dev_info(&client->dev,
+                "MSP%d4%02d%c-%c%d found on %s: supports %s%s%s, mode is %s\n",
+                msp_family, msp_product,
+                msp_revision, msp_hard, msp_rom,
+                client->adapter->name,
+                (state->has_nicam) ? "nicam" : "",
+                (state->has_nicam && state->has_radio) ? " and " : "",
+                (state->has_radio) ? "radio" : "",
+                opmode_str[state->opmode]);
 
        /* version-specific initialization */
        switch (state->opmode) {
        case OPMODE_MANUAL:
-               printk(KERN_CONT "manual");
                thread_func = msp3400c_thread;
                break;
        case OPMODE_AUTODETECT:
-               printk(KERN_CONT "autodetect");
                thread_func = msp3410d_thread;
                break;
        case OPMODE_AUTOSELECT:
-               printk(KERN_CONT "autodetect and autoselect");
                thread_func = msp34xxg_thread;
                break;
        }
-       printk(KERN_CONT "\n");
 
        /* startup control thread if needed */
        if (thread_func) {
                state->kthread = kthread_run(thread_func, client, "msp34xx");
 
                if (IS_ERR(state->kthread))
-                       v4l_warn(client, "kernel_thread() failed\n");
+                       dev_warn(&client->dev, "kernel_thread() failed\n");
                msp_wake_thread(client);
        }
        return 0;