[PATCH v1 3/5] fbtft: Drop useless #ifdef CONFIG_OF and dead code
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Nov 20 15:28:50 UTC 2019
On Wed, Nov 20, 2019 at 04:04:17PM +0100, Noralf Trønnes wrote:
> Den 20.11.2019 15.43, skrev Noralf Trønnes:
> > Den 20.11.2019 10.57, skrev Andy Shevchenko:
> >> First of all there is no need to guard GPIO request by CONFIG_OF.
> >> It works for everybody independently on resource provider. While here,
> >> rename the function to reflect the above.
> >>
> >> Moreover, since we have a global dependency to OF, the rest of
> >> conditional compilation is no-op, i.e. it's always be true.
> >>
> >> Due to above drop useless #ifdef CONFIG_OF and therefore dead code.
> >>
> >> Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
> >> ---
> >> drivers/staging/fbtft/fbtft-core.c | 19 ++-----------------
> >> 1 file changed, 2 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
> >
> > <snip>
> >
> >> @@ -1184,17 +1176,10 @@ static struct fbtft_platform_data *fbtft_probe_dt(struct device *dev)
> >> pdata->display.backlight = 1;
> >> if (of_find_property(node, "init", NULL))
> >> pdata->display.fbtftops.init_display = fbtft_init_display_dt;
> >> - pdata->display.fbtftops.request_gpios = fbtft_request_gpios_dt;
> >> + pdata->display.fbtftops.request_gpios = fbtft_request_gpios;
> >
> > You can ditch the .request_gpios callback and call fbtft_request_gpios()
> > directly in fbtft_register_framebuffer(). That will make it safe to drop
> > the OF dependency, otherwise .request_gpios will be NULL in the non-DT
> > case. This is one of the bugs that follwed the gpio refactoring.
>
> Really difficult to read this fbtft code (that I wrote...).
> The NULL deref can only happen when dev->platform_data is set. That
> can't happen, in mainline at least, now that fbtft_device is gone.
Hmm... If I read code correctly this patch doesn't change this logic. We have
non-NULL ->request_gpios() in case of pdata != NULL if and only if supplier
gives it to us.
The above assignment happens only for DT case (fbtft_properties_read() is
guarded against non-DT, okay non-fwnode, cases).
> > You can also ditch the .request_gpios_match callback if you want, it
> > isn't called anymore (it is set in fb_agm1264k-fl).
I guess both improvements can be done later since they are not affecting the
logic in this series.
--
With Best Regards,
Andy Shevchenko
More information about the dri-devel
mailing list