linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* _extending_ platform support options?
@ 2010-12-01 13:25 Joachim Foerster
  2010-12-01 13:47 ` Josh Boyer
  0 siblings, 1 reply; 3+ messages in thread
From: Joachim Foerster @ 2010-12-01 13:25 UTC (permalink / raw)
  To: linuxppc-dev

Hi all,

currently I'm wondering what the preferred/recommend way of _extending_ an existing 
"Platform support" option is?

We are working with custom design/boards based on Virtex4/5. So we are primarily using the 
  CONFIG_XILINX_VIRTEX*_GENERIC_BOARD options. In our case we have some special needs, 
like custom ppc_md.restart(), ppc_md.power_off() or ppc_md.show_cpuinfo().

Till now, we just duplicated arch/powerpc/platforms/4?x/virtex.c and added our special 
stuff. Properly renaming everything, etc ...

An alternative could be to add a virtex_my.c which extends virtex.c, like this
(also like virtex_ml510.c extends virtex.c):

static void virtex_my_show_cpuinfo(struct seq_file *m)
{
	seq_printf(m, something);
}

static int __init virtex_mle_init(void)
{
	ppc_md.show_cpuinfo = virtex_my_show_cpuinfo;
	return 0;
}
machine_core_initcall(virtex, virtex_my_init);

Though, to me, it does not seem really OK to assign ppc_md members that way. The original 
struct machdep for "virtex" (which is defined in virtex.c with define_machine()) is not 
adjusted either. Ok, we could modify that one, too.
Especially I'm not sure if it is OK to use machine_core_initcall() for such modifications.

So my question is: Is there any recommended way for doing such "extensions"? Or is it OK 
to just duplicate virtex.c (which does not seem really OK, too)?

Thanks,
  Joachim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: _extending_ platform support options?
  2010-12-01 13:25 _extending_ platform support options? Joachim Foerster
@ 2010-12-01 13:47 ` Josh Boyer
  2010-12-01 20:57   ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Boyer @ 2010-12-01 13:47 UTC (permalink / raw)
  To: Joachim Foerster; +Cc: linuxppc-dev

On Wed, Dec 01, 2010 at 02:25:43PM +0100, Joachim Foerster wrote:
>Hi all,
>
>currently I'm wondering what the preferred/recommend way of
>_extending_ an existing "Platform support" option is?
>
>We are working with custom design/boards based on Virtex4/5. So we
>are primarily using the  CONFIG_XILINX_VIRTEX*_GENERIC_BOARD options.
>In our case we have some special needs, like custom ppc_md.restart(),
>ppc_md.power_off() or ppc_md.show_cpuinfo().
>
>Till now, we just duplicated arch/powerpc/platforms/4?x/virtex.c and
>added our special stuff. Properly renaming everything, etc ...
>
>An alternative could be to add a virtex_my.c which extends virtex.c, like this
>(also like virtex_ml510.c extends virtex.c):
>
>static void virtex_my_show_cpuinfo(struct seq_file *m)
>{
>	seq_printf(m, something);
>}
>
>static int __init virtex_mle_init(void)
>{
>	ppc_md.show_cpuinfo = virtex_my_show_cpuinfo;
>	return 0;
>}
>machine_core_initcall(virtex, virtex_my_init);
>
>Though, to me, it does not seem really OK to assign ppc_md members
>that way. The original struct machdep for "virtex" (which is defined
>in virtex.c with define_machine()) is not adjusted either. Ok, we
>could modify that one, too.
>Especially I'm not sure if it is OK to use machine_core_initcall() for such modifications.
>
>So my question is: Is there any recommended way for doing such
>"extensions"? Or is it OK to just duplicate virtex.c (which does not
>seem really OK, too)?

Duplicate it as you have done, naming the file something unique.  We try
to prevent unnecessary duplication of code, but sometimes it's cleaner
to just have a separate board file instead.

josh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: _extending_ platform support options?
  2010-12-01 13:47 ` Josh Boyer
@ 2010-12-01 20:57   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2010-12-01 20:57 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Joachim Foerster

On Wed, 2010-12-01 at 08:47 -0500, Josh Boyer wrote:
> >Though, to me, it does not seem really OK to assign ppc_md members
> >that way. The original struct machdep for "virtex" (which is defined
> >in virtex.c with define_machine()) is not adjusted either. Ok, we
> >could modify that one, too.
> >Especially I'm not sure if it is OK to use machine_core_initcall()
> for such modifications.
> >
> >So my question is: Is there any recommended way for doing such
> >"extensions"? Or is it OK to just duplicate virtex.c (which does not
> >seem really OK, too)?
> 
> Duplicate it as you have done, naming the file something unique.  We
> try
> to prevent unnecessary duplication of code, but sometimes it's cleaner
> to just have a separate board file instead. 

Right. Best way is to turn the common code in virtex.c into "library"
code that you can hookup from your platform's ppc_md, so you avoid
duplication that way for most things.

You an do that by just linking in virtex.c and changing the stuff you
want to be non-static, or better if that becomes a habit, separate
virtex-lib.c (for example) from virtex-simple.c (generic platform for
example). You don't have to follow my proposed names :-)

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-01 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 13:25 _extending_ platform support options? Joachim Foerster
2010-12-01 13:47 ` Josh Boyer
2010-12-01 20:57   ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).