Re: Device driver configuration and driver_data distinction.

Marcus Shawcroft <marcus.shawcroft@...>

On 6 October 2016 at 12:06, Tomasz Bursztyka
<tomasz.bursztyka(a)> wrote:
Hi Marcus,

I believe we did not make it const at the beginning due to PCI enumeration
on Galileo.
This was early days, and things changed then.

Actually there have been plans to move it to const, at least I remember
hearing such idea
from Daniel Kalowsky, for the same exact reasons you noted, it might even be
in the git history,
somewhere. But we were too busy to follow up at that time.

So this would indeed be very welcome, if you want to propose a patch for it.
Note, however, that some device drivers may be using such configuration
structure wrongly.
(aka: accessing and changing its data). So you would probably need to change
things there as well.

Thanks for the background information.

Switching to const config_info will require the following:
1) Update ~50 drivers with an explicit const in any pointers they
construct when accessing their config_info structure. This change is
safe to make even when struct device {} has a a non const *config_info
2) Update a small subset of the above 50 to make their config
structures static. Not strictly necessary, but seems like the right
thing to do for all those drivers that are self contained within one
3) Update ~12 drivers that currently have RW data within their RO
config data structure. This should be a straight forward mechanical
move of each RW object within config to the corresponding driver_data
4) Update ~12 drivers to put explict const in any pointers they
construct when accessing config_info
5) Update device {} to make config_info const.
6) Update all ~60 odd drivers to add const to their config structure

All of this is mechanical, most trivial, some slightly more involved.
The hard part is likely to be figuring out how to make sure everything
modified gets compiled / tested as appropriate. Each of these steps
can be executed individually and incrementally without breaking the

3) Is not as difficult as it might first appear since each driver
instance has a RO config structure and a RW driver data structure, it
is essentially a trivial exercise of moving objects from one structure
to the other.

Sound sane?


Join to automatically receive all group messages.