1

media: i2c: max96717: coding style fixes

Coding style fixes suggested by Sakari during the
driver review.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Julien Massot 2024-07-01 11:31:42 +02:00 committed by Hans Verkuil
parent 19b5e5511c
commit 24fe3eb1a5

View File

@ -25,6 +25,7 @@
#define MAX96717_PORTS 2 #define MAX96717_PORTS 2
#define MAX96717_PAD_SINK 0 #define MAX96717_PAD_SINK 0
#define MAX96717_PAD_SOURCE 1 #define MAX96717_PAD_SOURCE 1
#define MAX96717_CSI_NLANES 4
#define MAX96717_DEFAULT_CLKOUT_RATE 24000000UL #define MAX96717_DEFAULT_CLKOUT_RATE 24000000UL
@ -495,7 +496,6 @@ static int max96717_enable_streams(struct v4l2_subdev *sd,
u64 streams_mask) u64 streams_mask)
{ {
struct max96717_priv *priv = sd_to_max96717(sd); struct max96717_priv *priv = sd_to_max96717(sd);
struct device *dev = &priv->client->dev;
u64 sink_streams; u64 sink_streams;
int ret; int ret;
@ -516,11 +516,8 @@ static int max96717_enable_streams(struct v4l2_subdev *sd,
ret = v4l2_subdev_enable_streams(priv->source_sd, ret = v4l2_subdev_enable_streams(priv->source_sd,
priv->source_sd_pad, priv->source_sd_pad,
sink_streams); sink_streams);
if (ret) { if (ret)
dev_err(dev, "Fail to start streams:%llu on remote subdev\n",
sink_streams);
goto stop_csi; goto stop_csi;
}
} }
priv->enabled_source_streams |= streams_mask; priv->enabled_source_streams |= streams_mask;
@ -530,6 +527,7 @@ static int max96717_enable_streams(struct v4l2_subdev *sd,
stop_csi: stop_csi:
if (!priv->enabled_source_streams) if (!priv->enabled_source_streams)
max96717_start_csi(priv, false); max96717_start_csi(priv, false);
return ret; return ret;
} }
@ -769,11 +767,8 @@ max96717_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
static unsigned int max96717_clk_find_best_index(struct max96717_priv *priv, static unsigned int max96717_clk_find_best_index(struct max96717_priv *priv,
unsigned long rate) unsigned long rate)
{ {
unsigned int i, idx; unsigned int i, idx = 0;
unsigned long diff_new, diff_old; unsigned long diff_new, diff_old = U32_MAX;
diff_old = U32_MAX;
idx = 0;
for (i = 0; i < ARRAY_SIZE(max96717_predef_freqs); i++) { for (i = 0; i < ARRAY_SIZE(max96717_predef_freqs); i++) {
diff_new = abs(rate - max96717_predef_freqs[i].freq); diff_new = abs(rate - max96717_predef_freqs[i].freq);
@ -860,8 +855,7 @@ static int max96717_register_clkout(struct max96717_priv *priv)
struct clk_init_data init = { .ops = &max96717_clk_ops }; struct clk_init_data init = { .ops = &max96717_clk_ops };
int ret; int ret;
init.name = kasprintf(GFP_KERNEL, "max96717.%s.clk_out", init.name = kasprintf(GFP_KERNEL, "max96717.%s.clk_out", dev_name(dev));
dev_name(dev));
if (!init.name) if (!init.name)
return -ENOMEM; return -ENOMEM;
@ -944,8 +938,9 @@ static int max96717_init_csi_lanes(struct max96717_priv *priv)
* Unused lanes need to be mapped as well to not have * Unused lanes need to be mapped as well to not have
* the same lanes mapped twice. * the same lanes mapped twice.
*/ */
for (; lane < 4; lane++) { for (; lane < MAX96717_CSI_NLANES; lane++) {
unsigned int idx = find_first_zero_bit(&lanes_used, 4); unsigned int idx = find_first_zero_bit(&lanes_used,
MAX96717_CSI_NLANES);
val |= idx << (lane * 2); val |= idx << (lane * 2);
lanes_used |= BIT(idx); lanes_used |= BIT(idx);
@ -999,9 +994,7 @@ static int max96717_hw_init(struct max96717_priv *priv)
static int max96717_parse_dt(struct max96717_priv *priv) static int max96717_parse_dt(struct max96717_priv *priv)
{ {
struct device *dev = &priv->client->dev; struct device *dev = &priv->client->dev;
struct v4l2_fwnode_endpoint vep = { struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
.bus_type = V4L2_MBUS_CSI2_DPHY
};
struct fwnode_handle *ep_fwnode; struct fwnode_handle *ep_fwnode;
unsigned char num_data_lanes; unsigned char num_data_lanes;
int ret; int ret;
@ -1019,11 +1012,11 @@ static int max96717_parse_dt(struct max96717_priv *priv)
return dev_err_probe(dev, ret, "Failed to parse sink endpoint"); return dev_err_probe(dev, ret, "Failed to parse sink endpoint");
num_data_lanes = vep.bus.mipi_csi2.num_data_lanes; num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
if (num_data_lanes < 1 || num_data_lanes > 4) if (num_data_lanes < 1 || num_data_lanes > MAX96717_CSI_NLANES)
return dev_err_probe(dev, -EINVAL, return dev_err_probe(dev, -EINVAL,
"Invalid data lanes must be 1 to 4\n"); "Invalid data lanes must be 1 to 4\n");
memcpy(&priv->mipi_csi2, &vep.bus.mipi_csi2, sizeof(priv->mipi_csi2)); priv->mipi_csi2 = vep.bus.mipi_csi2;
return 0; return 0;
} }