Subject: Re: Allowing ether_ifattach() to fail
To: David Brownlee <abs@netbsd.org>
From: John Hawkinson <jhawk@MIT.EDU>
List: tech-net
Date: 05/24/2000 14:35:40
In message <Pine.NEB.4.21.0005241349360.337-100000@oblivion.mono.org>, David Br
ownlee writes:
>On Wed, 24 May 2000, Lennart Augustsson wrote:

>> I would like to see a change in the config machinery so that
>> *_attach() can fail, which would then stop the device from being
>> accessible. As it is each driver (where attach can fail) needs to have
>> a flag indicating if it is really working.  Ideally, an attach should
>> never fail, but unfortunately that's now how the world works.  A
>> device can stop working at any time, even during attach.

"Hmm." This is a wider scope change than I'm willing to take on at this time,
and it probably bears further discussion on tech-kern, but that aside
for the moment, how do you envision this working? That is, what happens
when *_attach() returns failure? Should config_attach() return NULL? What
will the higher-level machinery do with that?

Presumably the intent here is so that *_detach() functions won't have
to be called on the device? That seems like it might be problematic
since drivers should be allowed to set up state and pull it down, even
if their attachment is "unsuccessful" (or so it seems to me). Also, if
there is every some degree of generic power management handling,
presumably such a layer might want to frob devices that are unattached
(?).

>> My proposed change is rather large.  Each device driver needs to be
>> modified, but in a very simple way.  Just change the return type to
>> `int' and add a `return 0'.
>
>	Presumably this would also allow for some of the panic()s at
>	attach time to be changed to simple failures to attach?

Err, I'm unclear on that. If they could be changed to simple failures,
it would seem like they could become printf()s now, as long as the
appropriate state was reverted.

--jhawk