[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1547009361.20070329025215@gmail.com>
Date: Thu, 29 Mar 2007 02:52:15 +0300
From: Paul Sokolovsky <pmiscml@...il.com>
To: "H. Peter Anvin" <hpa@...or.com>
CC: linux-kernel@...r.kernel.org, kernel-discuss@...dhelds.org,
Anton Vorontsov <cbou@...l.ru>
Subject: Re: [RFC] Virtual methods for devices and generalized GPIO support using it
Hello H.,
Wednesday, March 28, 2007, 7:32:57 PM, you wrote:
> Paul Sokolovsky wrote:
>>
>> In this respect, VTABLE(), METHOD() macros serve the same purpose as
>> container_of() and list_for_each() - they are besides offering (more)
>> convenient syntax, also carry important annotattion and educational
>> messages, like "it's ok, and encouraged to embed one structure into
>> another - use it!" or "list manipulation is a trivial operation for kernel,
>> and we want you to treat it as such and use in standard, easily
>> distinguishable way".
>>
> You realize, right, that the Linux kernel already have a much cleaner
> way to do vtables in the kernel, without this kind of macro crappage?
> It's called an _ops table, and is used in a patternized way:
foo->x_ops->func(foo, ...);
> ... all over the kernel. We like it that way.
Sure! I wrote it's nothing really new. And I hope it's clear why
those macros appeared in the first place: with the type of structures
the device virtual methods are intended to be used, there're always
pretty comprehensive member selection and typecasting is required. In
this regard, there were 3 choices:
1. Use long but explicit expressions, like
((struct dev_pdata*)pdev.dev->platform_device)->x_ops->func(dev)
2. Use temporary variables:
struct dev_pdata *tmp = (struct dev_pdata*)pdev.dev->platform_device;
tmp->x_ops->func(dev);
3. Introduce macros which would hide guts and would provide syntax
more resembling usual function call (especially for folks who remember
that preprocessor is unalienable part of C ;-) ).
As I also noted in the original mail, macros are also nice device
for in-place annotation - to emphasize the fact that this is not just
a mundane case of pointer manipulation, but paradigmatic thing.
By this criteria I happened to choose macros syntax. But it's still
merely a syntax, and I don't pledge for it. If there's more movement
towards using explicit low-level forms like 1) or 2) instead of
introducing new syntactic pattern, then macro syntax can be considered
to have fulfilled its introductory role and can be dropped.
> -hpa
--
Best regards,
Paul mailto:pmiscml@...il.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists