From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Dongchun Zhu <dongchun.zhu@mediatek.com>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
devicetree <devicetree@vger.kernel.org>,
"Nicolas Boichat" <drinkcat@chromium.org>,
srv_heupstream <srv_heupstream@mediatek.com>,
"Shengnan Wang (王圣男)" <shengnan.wang@mediatek.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Tomasz Figa" <tfiga@chromium.org>,
"Louis Kuo" <louis.kuo@mediatek.com>,
"Sj Huang" <sj.huang@mediatek.com>,
"Rob Herring" <robh+dt@kernel.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Bingbu Cao" <bingbu.cao@intel.com>,
matrix.zhu@aliyun.com,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"linux-arm Mailing List" <linux-arm-kernel@lists.infradead.org>,
"Linux Media Mailing List" <linux-media@vger.kernel.org>
Subject: Re: [PATCH v14 2/2] media: i2c: Add OV02A10 image sensor driver
Date: Fri, 4 Sep 2020 17:05:53 +0300 [thread overview]
Message-ID: <CAHp75Ve8WNuCuRmFcXaZHLjHMGfsvM=69ii5g4H+NYud6N95eQ@mail.gmail.com> (raw)
In-Reply-To: <1599225767.4733.64.camel@mhfsdcap03>
On Fri, Sep 4, 2020 at 4:48 PM Dongchun Zhu <dongchun.zhu@mediatek.com> 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-09-04 14:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-02 12:01 [PATCH v14 0/2] media: i2c: Add support for OV02A10 sensor Dongchun Zhu
2020-09-02 12:01 ` [PATCH v14 1/2] media: dt-bindings: media: i2c: Document OV02A10 bindings Dongchun Zhu
2020-09-03 16:13 ` Rob Herring
2020-09-04 3:24 ` Dongchun Zhu
2020-09-02 12:01 ` [PATCH v14 2/2] media: i2c: Add OV02A10 image sensor driver Dongchun Zhu
2020-09-02 13:44 ` Andy Shevchenko
2020-09-02 13:51 ` Andy Shevchenko
2020-09-04 13:32 ` Dongchun Zhu
2020-09-04 13:55 ` Andy Shevchenko
2020-09-08 9:46 ` Sakari Ailus
2020-09-04 13:22 ` Dongchun Zhu
2020-09-04 14:05 ` Andy Shevchenko [this message]
2020-09-07 13:15 ` Tomasz Figa
2020-09-07 13:51 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHp75Ve8WNuCuRmFcXaZHLjHMGfsvM=69ii5g4H+NYud6N95eQ@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bingbu.cao@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dongchun.zhu@mediatek.com \
--cc=drinkcat@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=louis.kuo@mediatek.com \
--cc=mark.rutland@arm.com \
--cc=matrix.zhu@aliyun.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=shengnan.wang@mediatek.com \
--cc=sj.huang@mediatek.com \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).