[PATCH] drm/mipi-dsi: Reduce driver bloat of mipi_dsi_*_write_seq()

Dmitry Baryshkov dmitry.baryshkov at linaro.org
Fri Apr 26 15:42:25 UTC 2024


On Fri, 26 Apr 2024 at 18:41, Doug Anderson <dianders at chromium.org> wrote:
>
> Hi,
>
> On Thu, Apr 25, 2024 at 8:03 PM Dmitry Baryshkov
> <dmitry.baryshkov at linaro.org> wrote:
> >
> > On Thu, Apr 25, 2024 at 10:04:49AM -0700, Doug Anderson wrote:
> > > Hi,
> > >
> > > On Thu, Apr 25, 2024 at 1:19 AM Jani Nikula <jani.nikula at linux.intel.com> wrote:
> > > >
> > > > > @@ -279,6 +281,8 @@ enum mipi_dsi_dcs_tear_mode {
> > > > >
> > > > >  ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
> > > > >                                 const void *data, size_t len);
> > > > > +ssize_t mipi_dsi_dcs_write_buffer_chatty(struct mipi_dsi_device *dsi,
> > > > > +                                      const void *data, size_t len);
> > > > >  ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
> > > > >                          const void *data, size_t len);
> > > > >  ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
> > > > > @@ -317,14 +321,10 @@ int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi,
> > > > >  #define mipi_dsi_generic_write_seq(dsi, seq...)                                \
> > > > >       do {                                                                   \
> > > > >               static const u8 d[] = { seq };                                 \
> > > > > -             struct device *dev = &dsi->dev;                                \
> > > > >               int ret;                                                       \
> > > > > -             ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d));           \
> > > > > -             if (ret < 0) {                                                 \
> > > > > -                     dev_err_ratelimited(dev, "transmit data failed: %d\n", \
> > > > > -                                         ret);                              \
> > > > > +             ret = mipi_dsi_generic_write_chatty(dsi, d, ARRAY_SIZE(d));    \
> > > > > +             if (ret < 0)                                                   \
> > > > >                       return ret;                                            \
> > > > > -             }                                                              \
> > > > >       } while (0)
> >
> >
> > Reading the thread makes me wonder whether we should be going into
> > slightly other direction:
> >
> > Add __must_check() to mipi_dsi_ writing functions,
> >
> > #define mipi_dsi_dcs_whatever_write(dsi, cmd, seq...)   \
> >         ({                                              \
> >                 static const u8 d[] = { cmd, seq };     \
> >                 mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));    \
> >         })
> >
> > Then in panel drivers we actually have to explicitly handle the return
> > code (either by dropping to the error label or by just returning an
> > error).
>
> Given the sheer number of init commands needed by some panels (see
> j606f_boe_init_sequence() for instance) I'm still convinced that we
> want something that allows people to write their init code in a way
> that's not quite so verbose. It sounds as if Jani is OK w/ the
> proposal of using the "accumulated return value" (proposal #2 I had).
> I'm hoping you're OK w/ that too...

Yes, I'm fine with that.

-- 
With best wishes
Dmitry


More information about the dri-devel mailing list