]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: adv7180: Move adv7180_set_power() and init_device()
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Thu, 28 Aug 2025 16:06:44 +0000 (18:06 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 4 Sep 2025 08:06:13 +0000 (10:06 +0200)
Move the two functions adv7180_set_power() and init_device() earlier in
the file so they in future changes can be used from .querystd and
.s_stream as the driver is reworked to drop the usage of .s_power.

While at it fix two style issues in init_device() that checkpatch
complains about.

  - Two cases of indentation issues for function arguments split over
    multiple lines.

  - The repetition of the word 'interrupts' in a comment.

Apart from these style fixes the functions are moved verbatim and there
are no functional changes.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/adv7180.c

index 5d90b8ab9b6df1191b9ee9dba837132d3fade4d0..ef63b0ee9b8d1c1e54d093b486af9c6102ed7bc2 100644 (file)
@@ -274,6 +274,38 @@ static int adv7180_vpp_write(struct adv7180_state *state, unsigned int reg,
        return i2c_smbus_write_byte_data(state->vpp_client, reg, value);
 }
 
+static int adv7180_set_power(struct adv7180_state *state, bool on)
+{
+       u8 val;
+       int ret;
+
+       if (on)
+               val = ADV7180_PWR_MAN_ON;
+       else
+               val = ADV7180_PWR_MAN_OFF;
+
+       ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
+       if (ret)
+               return ret;
+
+       if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
+               if (on) {
+                       adv7180_csi_write(state, 0xDE, 0x02);
+                       adv7180_csi_write(state, 0xD2, 0xF7);
+                       adv7180_csi_write(state, 0xD8, 0x65);
+                       adv7180_csi_write(state, 0xE0, 0x09);
+                       adv7180_csi_write(state, 0x2C, 0x00);
+                       if (state->field == V4L2_FIELD_NONE)
+                               adv7180_csi_write(state, 0x1D, 0x80);
+                       adv7180_csi_write(state, 0x00, 0x00);
+               } else {
+                       adv7180_csi_write(state, 0x00, 0x80);
+               }
+       }
+
+       return 0;
+}
+
 static v4l2_std_id adv7180_std_to_v4l2(u8 status1)
 {
        /* in case V4L2_IN_ST_NO_SIGNAL */
@@ -514,38 +546,6 @@ static void adv7180_set_reset_pin(struct adv7180_state *state, bool on)
        }
 }
 
-static int adv7180_set_power(struct adv7180_state *state, bool on)
-{
-       u8 val;
-       int ret;
-
-       if (on)
-               val = ADV7180_PWR_MAN_ON;
-       else
-               val = ADV7180_PWR_MAN_OFF;
-
-       ret = adv7180_write(state, ADV7180_REG_PWR_MAN, val);
-       if (ret)
-               return ret;
-
-       if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
-               if (on) {
-                       adv7180_csi_write(state, 0xDE, 0x02);
-                       adv7180_csi_write(state, 0xD2, 0xF7);
-                       adv7180_csi_write(state, 0xD8, 0x65);
-                       adv7180_csi_write(state, 0xE0, 0x09);
-                       adv7180_csi_write(state, 0x2C, 0x00);
-                       if (state->field == V4L2_FIELD_NONE)
-                               adv7180_csi_write(state, 0x1D, 0x80);
-                       adv7180_csi_write(state, 0x00, 0x00);
-               } else {
-                       adv7180_csi_write(state, 0x00, 0x80);
-               }
-       }
-
-       return 0;
-}
-
 static int adv7180_s_power(struct v4l2_subdev *sd, int on)
 {
        struct adv7180_state *state = to_state(sd);
@@ -874,6 +874,62 @@ static int adv7180_g_tvnorms(struct v4l2_subdev *sd, v4l2_std_id *norm)
        return 0;
 }
 
+static int init_device(struct adv7180_state *state)
+{
+       int ret;
+
+       mutex_lock(&state->mutex);
+
+       adv7180_set_power_pin(state, true);
+       adv7180_set_reset_pin(state, false);
+
+       adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
+       usleep_range(5000, 10000);
+
+       ret = state->chip_info->init(state);
+       if (ret)
+               goto out_unlock;
+
+       ret = adv7180_program_std(state);
+       if (ret)
+               goto out_unlock;
+
+       adv7180_set_field_mode(state);
+
+       /* register for interrupts */
+       if (state->irq > 0) {
+               /* config the Interrupt pin to be active low */
+               ret = adv7180_write(state, ADV7180_REG_ICONF1,
+                                   ADV7180_ICONF1_ACTIVE_LOW |
+                                   ADV7180_ICONF1_PSYNC_ONLY);
+               if (ret < 0)
+                       goto out_unlock;
+
+               ret = adv7180_write(state, ADV7180_REG_IMR1, 0);
+               if (ret < 0)
+                       goto out_unlock;
+
+               ret = adv7180_write(state, ADV7180_REG_IMR2, 0);
+               if (ret < 0)
+                       goto out_unlock;
+
+               /* enable AD change interrupts */
+               ret = adv7180_write(state, ADV7180_REG_IMR3,
+                                   ADV7180_IRQ3_AD_CHANGE);
+               if (ret < 0)
+                       goto out_unlock;
+
+               ret = adv7180_write(state, ADV7180_REG_IMR4, 0);
+               if (ret < 0)
+                       goto out_unlock;
+       }
+
+out_unlock:
+       mutex_unlock(&state->mutex);
+
+       return ret;
+}
+
 static int adv7180_s_stream(struct v4l2_subdev *sd, int enable)
 {
        struct adv7180_state *state = to_state(sd);
@@ -1343,62 +1399,6 @@ static const struct adv7180_chip_info adv7282_m_info = {
        .select_input = adv7182_select_input,
 };
 
-static int init_device(struct adv7180_state *state)
-{
-       int ret;
-
-       mutex_lock(&state->mutex);
-
-       adv7180_set_power_pin(state, true);
-       adv7180_set_reset_pin(state, false);
-
-       adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
-       usleep_range(5000, 10000);
-
-       ret = state->chip_info->init(state);
-       if (ret)
-               goto out_unlock;
-
-       ret = adv7180_program_std(state);
-       if (ret)
-               goto out_unlock;
-
-       adv7180_set_field_mode(state);
-
-       /* register for interrupts */
-       if (state->irq > 0) {
-               /* config the Interrupt pin to be active low */
-               ret = adv7180_write(state, ADV7180_REG_ICONF1,
-                                               ADV7180_ICONF1_ACTIVE_LOW |
-                                               ADV7180_ICONF1_PSYNC_ONLY);
-               if (ret < 0)
-                       goto out_unlock;
-
-               ret = adv7180_write(state, ADV7180_REG_IMR1, 0);
-               if (ret < 0)
-                       goto out_unlock;
-
-               ret = adv7180_write(state, ADV7180_REG_IMR2, 0);
-               if (ret < 0)
-                       goto out_unlock;
-
-               /* enable AD change interrupts interrupts */
-               ret = adv7180_write(state, ADV7180_REG_IMR3,
-                                               ADV7180_IRQ3_AD_CHANGE);
-               if (ret < 0)
-                       goto out_unlock;
-
-               ret = adv7180_write(state, ADV7180_REG_IMR4, 0);
-               if (ret < 0)
-                       goto out_unlock;
-       }
-
-out_unlock:
-       mutex_unlock(&state->mutex);
-
-       return ret;
-}
-
 static int adv7180_probe(struct i2c_client *client)
 {
        struct device_node *np = client->dev.of_node;