Re: [PATCH v14 2/2] media: i2c: Add OV02A10 image sensor driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 4, 2020 at 4:48 PM Dongchun Zhu <dongchun.zhu@xxxxxxxxxxxx> wrote:
> On Wed, 2020-09-02 at 16:44 +0300, Andy Shevchenko wrote:
> > On Wed, Sep 02, 2020 at 08:01:22PM +0800, Dongchun Zhu wrote:

...

> > > +   struct i2c_client *client = to_i2c_client(dev);
> > > +   struct v4l2_subdev *sd = i2c_get_clientdata(client);
> >
> >       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> >
> > Same for the rest similar cases.
>
> We've discussed the issue in DW9768 V2.
>
> For V4L2 sub-device drivers, dev_get_drvdata() shouldn't be used
> directly.
>
> More details please check the Google Issue:
> https://partnerissuetracker.corp.google.com/issues/147957975

This is not a public link. Can you remind me what was the issue?

...

> > > +   if (!bus_cfg.nr_of_link_frequencies) {
> > > +           dev_err(dev, "no link frequencies defined\n");
> > > +           ret = -EINVAL;
> > > +           goto check_hwcfg_error;
> > > +   }
> >
> > If it's 0, the below will break on 'if (j == 0)' with slightly different but
> > informative enough message. What do you keep above check for?
>
> I still prefer to the original version.
> If 'bus_cfg.nr_of_link_frequencies' is 0, shouldn't we directly return
> error?

But that will happen anyway. I will leave this to Sakari and
maintainers to decide.

> > > +   for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) {
> > > +           for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) {
> > > +                   if (link_freq_menu_items[i] ==
> > > +                           bus_cfg.link_frequencies[j]) {
> > > +                           ov02a10->freq_index = i;
> > > +                           break;
> > > +                   }
> > > +           }
> > > +
> > > +           if (j == bus_cfg.nr_of_link_frequencies) {
> > > +                   dev_err(dev, "no link frequency %lld supported\n",
> > > +                           link_freq_menu_items[i]);
> > > +                   ret = -EINVAL;
> >
> > > +                   goto check_hwcfg_error;
> >
> > 'break;' won't work?
> >
> > > +           }
> > > +   }
> > > +
> > > +check_hwcfg_error:
> >
> > out_endpoint_free:
>
> It seems that OV8856 keeps the same pattern.

So, we can do better than that, right?

> > > +   v4l2_fwnode_endpoint_free(&bus_cfg);

...

> > > +   /* Optional indication of physical rotation of sensor */
> > > +   ret = fwnode_property_read_u32(dev_fwnode(dev), "rotation", &rotation);
> > > +   if (!ret && rotation == 180) {
> >
> > Can be simplified (but I'm fine with above):
> >
> >       unsigned int rotation = 0;
> >       ...
> >       fwnode_property_read_u32(..., &rotation);
> >       if (rotation == 180) {
> >               ...
> >       }
> >
>
> Sounds like the readability is improved using the latter style :-)

Yes and makes it clear that this is an optional one.
Also you may consider the following

      unsigned int rotation;
      ...
      /* Optional ... */
      rotation = 0;
      fwnode_property_read_u32(..., &rotation);
      if (rotation == 180) {
          ...
      }

> > > +           ov02a10->upside_down = true;
> > > +           ov02a10->fmt.code = MEDIA_BUS_FMT_SRGGB10_1X10;
> > > +   }

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux