Subject: Re: Separating softc and struct device?
To: None <tech-kern@netbsd.org>
From: Valeriy E. Ushakov <uwe@stderr.spb.ru>
List: tech-kern
Date: 08/30/2007 01:26:59
On Wed, Aug 29, 2007 at 23:09:25 +0200, Quentin Garnier wrote:

> On Thu, Aug 30, 2007 at 01:04:17AM +0400, Valeriy E. Ushakov wrote:
> > On Wed, Aug 29, 2007 at 22:22:20 +0200, Joerg Sonnenberger wrote:
> > 
> > > is there a good reason to keep all the pointer casts for
> > > device softc's to struct device and vice versa? I think it would be good
> > > to follow the changes in ifnet vs arpcom and use direct pointer.
> > > An additional goody would be that struct device could become an abstract
> > > type and modifying it gets easier.
> > 
> > And we already have void *device_private(device_t); that's currently
> > is a no-op (returns back its argument), but you can use it on existing
> > code to easily mark it up for split device/softc.
> 
> What is a pain is device_xname.  When I update my tree, most of the long
> time it takes to merge everything is spent on dv_xname related troubles.
> Having device_xname doesn't really help here because when it is used
> currently it's usually through device_xname(&sc->sc_dev), which has to
> change when struct device is split off softc.
> 
> Obviously it's not bad enough to make me work as much as needed towards
> integration, though :-)

device_private() hides the transition in device-to-softc direction,
it's just that device_xname() is the most common case of going from
softc to device and we don't have a shim that hides it currently.

Some functions have "device_t self" around and use that, some do
casting, some do &sc->sc_dev.  Introducing the shim here seems awkward
and perhaps a better first step would be to make drivers introduce a
real back pointer to device, which will be pointing back to softc for
now and so redundant, but that will make the driver code independent
of the way device/softc are connected, and should make it easier for
you to change the implementation without touching every driver.

Give us something that works for you and I'm sure folks gonna be
cooperative ;)

SY, Uwe
-- 
uwe@stderr.spb.ru                       |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen