From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dyn_array: using %pF instead of print_fn_descriptor_symbol
Date: Fri, 29 Aug 2008 15:32:58 -0700 [thread overview]
Message-ID: <86802c440808291532r15dd581cj3f69755985578c2b@mail.gmail.com> (raw)
In-Reply-To: <20080829152053.92fa6fd4.akpm@linux-foundation.org>
On Fri, Aug 29, 2008 at 3:20 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Fri, 29 Aug 2008 15:07:49 -0700
> Yinghai Lu <yhlu.kernel@gmail.com> wrote:
>
>> + printk(KERN_DEBUG "per_cpu_dyn_array %pF ==> [%#lx - %#lx]\n",
>> + da->name, phys, phys + size);
>
> This:
>
> struct dyn_array {
> void **name;
>
> is a bit confusing. One normally expects a variable called "name" to
> point at a character string.
>
> What _does_ this thing point at? There are no code comments which I
> can find, it's unobvious from the source code, the type is the
> information-free void** and the identifier is misleading.
>
> I find that documenting the data structures is the best way of making
> code understandable (and hence maintainable).
struct dyn_array {
void **name;
unsigned long size;
unsigned int *nr;
unsigned long align;
void (*init_work)(void *);
};
extern struct dyn_array *__dyn_array_start[], *__dyn_array_end[];
extern struct dyn_array *__per_cpu_dyn_array_start[],
*__per_cpu_dyn_array_end[];
#define DEFINE_DYN_ARRAY_ADDR(nameX, addrX, sizeX, nrX, alignX, init_workX) \
static struct dyn_array __dyn_array_##nameX __initdata = \
{ .name = (void **)&(nameX),\
.size = sizeX,\
.nr = &(nrX),\
.align = alignX,\
.init_work = init_workX,\
}; \
static struct dyn_array *__dyn_array_ptr_##nameX __used \
__attribute__((__section__(".dyn_array.init"))) = \
&__dyn_array_##nameX
#define DEFINE_DYN_ARRAY(nameX, sizeX, nrX, alignX, init_workX) \
DEFINE_DYN_ARRAY_ADDR(nameX, nameX, sizeX, nrX, alignX, init_workX)
and use is
struct irq_desc *sparse_irqs;
DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc,
PAGE_SIZE, init_work);
then sparse_irqs is pointer, and .name store the address of that pointer.
later use
*da->name = phys_to_virt(phys);
to take back the dyn address.
YH
next prev parent reply other threads:[~2008-08-29 22:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-29 22:07 Yinghai Lu
2008-08-29 22:20 ` Andrew Morton
2008-08-29 22:32 ` Yinghai Lu [this message]
2008-08-29 22:45 ` Andrew Morton
2008-08-29 22:53 ` Andrew Morton
2008-08-29 23:34 ` Yinghai Lu
2008-08-30 0:23 ` Andrew Morton
2008-09-06 17:09 ` Ingo Molnar
2008-09-06 17:16 ` Yinghai Lu
2008-09-06 17:18 ` Ingo Molnar
2008-09-06 17:27 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86802c440808291532r15dd581cj3f69755985578c2b@mail.gmail.com \
--to=yhlu.kernel@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®