Message ID | 20231220085609.2595732-2-tomm.merciai@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: i2c: alvium: store frame interval in subdev | expand |
Hi Tommaso, Thank you for the patch. On Wed, Dec 20, 2023 at 09:56:06AM +0100, Tommaso Merciai wrote: > The dft_fr, min_fr and max_fr fields of the alvium_dev structure are > only used to pass results from alvium_get_frame_interval() to its > caller. Replace them with function parameters. > > Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > Changes Since v1: > - Fixed commit body as suggested by LPinchart > - Fixed alvium_get_frame_interval just return ret as suggested by LPinchart > - Removed unrelated chnages from the commit as suggested by LPinchart > > drivers/media/i2c/alvium-csi2.c | 27 +++++++++------------------ > drivers/media/i2c/alvium-csi2.h | 3 --- > 2 files changed, 9 insertions(+), 21 deletions(-) > > diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c > index 34ff7fad3877..0dcd69bf9f92 100644 > --- a/drivers/media/i2c/alvium-csi2.c > +++ b/drivers/media/i2c/alvium-csi2.c > @@ -1170,25 +1170,19 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium, > return 0; > } > > -static int alvium_get_frame_interval(struct alvium_dev *alvium) > +static int alvium_get_frame_interval(struct alvium_dev *alvium, > + u64 *dft_fr, u64 *min_fr, u64 *max_fr) > { > - u64 dft_fr, min_fr, max_fr; > int ret = 0; > > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, > - &dft_fr, &ret); > + dft_fr, &ret); > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R, > - &min_fr, &ret); > + min_fr, &ret); > alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R, > - &max_fr, &ret); > - if (ret) > - return ret; > - > - alvium->dft_fr = dft_fr; > - alvium->min_fr = min_fr; > - alvium->max_fr = max_fr; > + max_fr, &ret); > > - return 0; > + return ret; > } > > static int alvium_set_frame_rate(struct alvium_dev *alvium) > @@ -1670,21 +1664,18 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium, > struct v4l2_subdev_frame_interval *fi) > { > struct device *dev = &alvium->i2c_client->dev; > - u64 req_fr, min_fr, max_fr; > + u64 req_fr, dft_fr, min_fr, max_fr; > int ret; > > if (fi->interval.denominator == 0) > return -EINVAL; > > - ret = alvium_get_frame_interval(alvium); > + ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr); > if (ret) { > dev_err(dev, "Fail to get frame interval\n"); > return ret; > } > > - min_fr = alvium->min_fr; > - max_fr = alvium->max_fr; > - > dev_dbg(dev, "fi->interval.numerator = %d\n", > fi->interval.numerator); > dev_dbg(dev, "fi->interval.denominator = %d\n", > @@ -1694,7 +1685,7 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium, > fi->interval.numerator); > > if (req_fr >= max_fr && req_fr <= min_fr) > - req_fr = alvium->dft_fr; > + req_fr = dft_fr; > > alvium->fr = req_fr; > alvium->frame_interval.numerator = fi->interval.numerator; > diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h > index b85a25169e79..17f0bbbd1839 100644 > --- a/drivers/media/i2c/alvium-csi2.h > +++ b/drivers/media/i2c/alvium-csi2.h > @@ -443,9 +443,6 @@ struct alvium_dev { > > struct alvium_mode mode; > struct v4l2_fract frame_interval; > - u64 dft_fr; > - u64 min_fr; > - u64 max_fr; > u64 fr; > > u8 h_sup_csi_lanes;
diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c index 34ff7fad3877..0dcd69bf9f92 100644 --- a/drivers/media/i2c/alvium-csi2.c +++ b/drivers/media/i2c/alvium-csi2.c @@ -1170,25 +1170,19 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium, return 0; } -static int alvium_get_frame_interval(struct alvium_dev *alvium) +static int alvium_get_frame_interval(struct alvium_dev *alvium, + u64 *dft_fr, u64 *min_fr, u64 *max_fr) { - u64 dft_fr, min_fr, max_fr; int ret = 0; alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, - &dft_fr, &ret); + dft_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R, - &min_fr, &ret); + min_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R, - &max_fr, &ret); - if (ret) - return ret; - - alvium->dft_fr = dft_fr; - alvium->min_fr = min_fr; - alvium->max_fr = max_fr; + max_fr, &ret); - return 0; + return ret; } static int alvium_set_frame_rate(struct alvium_dev *alvium) @@ -1670,21 +1664,18 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium, struct v4l2_subdev_frame_interval *fi) { struct device *dev = &alvium->i2c_client->dev; - u64 req_fr, min_fr, max_fr; + u64 req_fr, dft_fr, min_fr, max_fr; int ret; if (fi->interval.denominator == 0) return -EINVAL; - ret = alvium_get_frame_interval(alvium); + ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr); if (ret) { dev_err(dev, "Fail to get frame interval\n"); return ret; } - min_fr = alvium->min_fr; - max_fr = alvium->max_fr; - dev_dbg(dev, "fi->interval.numerator = %d\n", fi->interval.numerator); dev_dbg(dev, "fi->interval.denominator = %d\n", @@ -1694,7 +1685,7 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium, fi->interval.numerator); if (req_fr >= max_fr && req_fr <= min_fr) - req_fr = alvium->dft_fr; + req_fr = dft_fr; alvium->fr = req_fr; alvium->frame_interval.numerator = fi->interval.numerator; diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h index b85a25169e79..17f0bbbd1839 100644 --- a/drivers/media/i2c/alvium-csi2.h +++ b/drivers/media/i2c/alvium-csi2.h @@ -443,9 +443,6 @@ struct alvium_dev { struct alvium_mode mode; struct v4l2_fract frame_interval; - u64 dft_fr; - u64 min_fr; - u64 max_fr; u64 fr; u8 h_sup_csi_lanes;
The dft_fr, min_fr and max_fr fields of the alvium_dev structure are only used to pass results from alvium_get_frame_interval() to its caller. Replace them with function parameters. Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com> --- Changes Since v1: - Fixed commit body as suggested by LPinchart - Fixed alvium_get_frame_interval just return ret as suggested by LPinchart - Removed unrelated chnages from the commit as suggested by LPinchart drivers/media/i2c/alvium-csi2.c | 27 +++++++++------------------ drivers/media/i2c/alvium-csi2.h | 3 --- 2 files changed, 9 insertions(+), 21 deletions(-)