linux-mips
[Top] [All Lists]

Re: [PATCH] Suppress compiler warnings

To: Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH] Suppress compiler warnings
From: Thomas Koeller <thomas@koeller.dyndns.org>
Date: Mon, 28 Aug 2006 23:16:07 +0200
Cc: Linux/MIPS Development <linux-mips@linux-mips.org>, Ralf Baechle <ralf@linux-mips.org>, Thomas Köller <thomas.koeller@baslerweb.com>
In-reply-to: <Pine.LNX.4.62.0608281018050.25303@pademelon.sonytel.be>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200608271353.16681.thomas@koeller.dyndns.org> <200608271800.27441.thomas@koeller.dyndns.org> <Pine.LNX.4.62.0608281018050.25303@pademelon.sonytel.be>
Sender: linux-mips-bounce@linux-mips.org
User-agent: KMail/1.9.3
On Monday 28 August 2006 11:19, Geert Uytterhoeven wrote:
> On Sun, 27 Aug 2006, Thomas Koeller wrote:
> > On Sunday 27 August 2006 14:12, Geert Uytterhoeven wrote:
> > >
> > > How can a driver look them up, if they are not linked in in some
> > > structure?
> >
> > It uses the standard platform device/driver mechanism: the platform
> > registers a platform device (to which the resources are attached) with
> > the platform bus. The driver registers a platform driver with the
> > platform bus. The bus matches drivers and devices and calls the probe
> > routine of any matching driver, at which point the driver can look up the
> > resources using platform_get_resource_byname().
>
> I know that.
>

Sorry, I see that my explanation missed your point.

> I mean, since they are static, no one uses them yet. So each possible
> driver that will want to use them should add some code to this single
> source file?
>

No, just the opposite.

The platform has a set of static 'struct resource' instances that reflect the
actual h/w resources present. Their purpose is to enforce nonconflicting use
of h/w resources. Resources that the platform attaches to platform devices it
creates are allocated from these static structs.

For example, the processor has six h/w counter/timer units, so there is a
'struct resource excite_ctr_resource' ranging from 0 to 5. The platform
wants to create a platform device for a watchdog driver to use, which
(among other things) requires a counter, so it allocates one from the static
resource, and attaches it to the platform device. The watchdog driver can then
retrieve it by its name.

Now, to save some code and data, the allocation described above is only done
if a watchdog driver is actually configured. If not (since the WD currently is
the only driver for an integrated RM9K peripheral that requires a counter), then
the static 'struct resource excite_ctr_resource' becomes unused. I could exclude
it as well in this case, but this would get messy if more drivers requiring
counters were written. In general terms, I could exclude any of the static
resource structs if _no_ driver using this particular kind of resource is
configured, but this would require the conditions for inclusion of a
particular resource struct to be modified for every new driver written, for a
gain of just a few (sizeof (struct resource)) bytes.

If you find these rather lengthy explanations confusing (which I am afraid they
are), then I suggest you have a look at the code, which is really simple.

Thomas

-- 
Thomas Koeller
thomas@koeller.dyndns.org

<Prev in Thread] Current Thread [Next in Thread>