Message ID | 20230401145926.596216-14-hdegoede@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: atomisp: Further sensor rework + exotic features removal | expand |
On Sat, Apr 1, 2023 at 5:00 PM Hans de Goede <hdegoede@redhat.com> wrote: > > Add error_unlock label + goto error_unlock on error to remove separate > unlock-s in all the error-exit paths. Another possible solution is to have a separate (unlocked) version of the function. And hence call it from the callback like lock ret = ... unlock return ret; > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > .../media/atomisp/i2c/atomisp-gc0310.c | 28 ++++++++----------- > 1 file changed, 12 insertions(+), 16 deletions(-) > > diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c > index 6c0877ab96e3..239fc9012910 100644 > --- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c > +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c > @@ -432,31 +432,27 @@ static int gc0310_s_stream(struct v4l2_subdev *sd, int enable) > if (enable) { > /* enable per frame MIPI and sensor ctrl reset */ > ret = i2c_smbus_write_byte_data(client, 0xFE, 0x30); > - if (ret) { > - mutex_unlock(&dev->input_lock); > - return ret; > - } > + if (ret) > + goto error_unlock; > } > > ret = i2c_smbus_write_byte_data(client, GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_3); > - if (ret) { > - mutex_unlock(&dev->input_lock); > - return ret; > - } > + if (ret) > + goto error_unlock; > > ret = i2c_smbus_write_byte_data(client, GC0310_SW_STREAM, > enable ? GC0310_START_STREAMING : GC0310_STOP_STREAMING); > - if (ret) { > - mutex_unlock(&dev->input_lock); > - return ret; > - } > + if (ret) > + goto error_unlock; > > ret = i2c_smbus_write_byte_data(client, GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_0); > - if (ret) { > - mutex_unlock(&dev->input_lock); > - return ret; > - } > + if (ret) > + goto error_unlock; > + > + mutex_unlock(&dev->input_lock); > + return 0; > > +error_unlock: > mutex_unlock(&dev->input_lock); > return ret; > } > -- > 2.39.1 >
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c index 6c0877ab96e3..239fc9012910 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c @@ -432,31 +432,27 @@ static int gc0310_s_stream(struct v4l2_subdev *sd, int enable) if (enable) { /* enable per frame MIPI and sensor ctrl reset */ ret = i2c_smbus_write_byte_data(client, 0xFE, 0x30); - if (ret) { - mutex_unlock(&dev->input_lock); - return ret; - } + if (ret) + goto error_unlock; } ret = i2c_smbus_write_byte_data(client, GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_3); - if (ret) { - mutex_unlock(&dev->input_lock); - return ret; - } + if (ret) + goto error_unlock; ret = i2c_smbus_write_byte_data(client, GC0310_SW_STREAM, enable ? GC0310_START_STREAMING : GC0310_STOP_STREAMING); - if (ret) { - mutex_unlock(&dev->input_lock); - return ret; - } + if (ret) + goto error_unlock; ret = i2c_smbus_write_byte_data(client, GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_0); - if (ret) { - mutex_unlock(&dev->input_lock); - return ret; - } + if (ret) + goto error_unlock; + + mutex_unlock(&dev->input_lock); + return 0; +error_unlock: mutex_unlock(&dev->input_lock); return ret; }
Add error_unlock label + goto error_unlock on error to remove separate unlock-s in all the error-exit paths. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- .../media/atomisp/i2c/atomisp-gc0310.c | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-)