Re: [PATCH v7 1/3] backlight: Add IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)

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

 



On Tue, Oct 03, 2017 at 09:51:49AM +0100, Daniel Thompson wrote:
> On 03/10/17 09:03, Daniel Vetter wrote:
> > On Mon, Oct 02, 2017 at 12:00:54PM +0300, Jani Nikula wrote:
> > > On Mon, 02 Oct 2017, Daniel Thompson <daniel.thompson@xxxxxxxxxx> wrote:
> > > > So I'm coming to this patchset cold but can you explain *why* something
> > > > wants to call of_find_backlight_by_node() when there is no backlight
> > > > support enabled. Why isn't the code that called is conditional on
> > > > BACKLIGHT_CLASS_DEVICE?
> > > > 
> > > > The undefined symbol issue is a pain but to be honest I'd rather solve
> > > > the use of undefined symbols by avoiding declaring them; this making
> > > > them into compile errors rather than link errors.
> > > 
> > > Typically the kernel header files define static inline stubs of the
> > > functions when the actual functions aren't configured/built. The code
> > > using the functions looks the same regardless of the config option, and
> > > handles the -ENODEV or NULL or whatever returns from the stubs
> > > gracefully. With the inlines, the compiler can usually throw out much of
> > > the code anyway.
> > > 
> > > In this regard, the backlight interface is an exception, forcing the
> > > callers to wrap the code around IS_ENABLED(BACKLIGHT_CLASS_DEVICE), not
> > > the rule.
> > 
> > fwiw, I think it'd be great if we can move backlight over to the common
> > pattern, like everyone else. It's pretty big pain as-is ...
> 
> For sure, after Jani's mail yesterday I looked at the GMA500 driver and
> concluded I didn't want code related to backlight having to look like that!
> 
> Currently the three main patterns of use are:
> 
>  1. Standalone drivers simple depend on BACKLIGHT_CLASS_DEVICE,
>  2. Some compound drivers select BACKLIGHT_CLASS_DEVICE (the AMD DRM
>     driver is an example of this),
>  3. Other compound drivers perform heroics with the pre-processor.
> 
> The main reason I'm not just agreeing straight away is that, to adopt the
> static inline pattern for the whole API, we have to believe that #3 above is
> desirable. Given the size and scope of the compound drivers in #3 above, I
> don't entirely understand why they want to avoid the select.

People love to over-configure their kernels and shave off a few bytes. And
big gpu drivers might have backlight support, but not always need it (e.g.
if you run without a panel as e.g. a tv set-top-box). Same with e.g. a
driver that supports both OF/DT and pci to find its devices.

On the desktop gpu driver side we don't really subscribe to this idea of
making everything optional, hence select (mostly), except select is a huge
pain. On the mobile/soc gpu side, #3 seems to be the desired outcome.
Doing static inline helpers for backlights would make both easier (since
in the end for desktop you just get a distro kernel that enables
everything anyway).

So yeah, imo if you think backlight should be a Kconfig, then it should
have static inline dummy functions to make life simpler for everyone. Only
exception are pure driver-only subsystem code which aren't ever called by
anything outside of your subsystem. But since the point of the backlight
subsystem is to provide backlight support to other drivers (there's still
the dream that we don't offload this onto userspace, that just doesn't
work well) we really should have these static inline helpers.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux