mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Allow arch to veto PC speaker beeper initialization
@ 2005-11-15  2:02 Paul Mackerras
  2005-11-15  3:55 ` Andrew Morton
  2005-11-15  9:08 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Mackerras @ 2005-11-15  2:02 UTC (permalink / raw)
  To: vojtech; +Cc: linux-kernel, Michael Neuling

From: Michael Neuling <mikey@neuling.org>

This patch provides an arch hook in the PC speaker beeper driver which
gives the arch code an opportunity to determine whether the machine
has an i8253 timer or not.  If it doesn't we don't want the driver to
go poking at the i8253's ports; there might be nothing there or there
might be something else there which would be upset by being poked at.

We want to be able to build ppc64 kernels which work both on machines
that have an i8253 equivalent (e.g. some pSeries) and on machines that
don't (e.g. G5 powermacs), which is why we don't just remove it from
the config.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
---

Could this go in please, preferably for 2.6.15?  Some people are
finding that their G5 powermacs lock up when this driver pokes the PIT
registers.

 drivers/input/misc/pcspkr.c   |    5 +++++
 include/asm-powerpc/8253pit.h |   13 +++++++++++++
 2 files changed, 18 insertions(+)

Index: linux-2.6/drivers/input/misc/pcspkr.c
===================================================================
--- linux-2.6.orig/drivers/input/misc/pcspkr.c	2005-10-31 15:16:39.000000000 +1100
+++ linux-2.6/drivers/input/misc/pcspkr.c	2005-10-31 15:21:13.000000000 +1100
@@ -66,6 +66,11 @@
 
 static int __init pcspkr_init(void)
 {
+#ifdef HAS_PCSPKR_ARCH_INIT
+	int rc = pcspkr_arch_init();
+	if (rc)
+		return rc;
+#endif
 	pcspkr_dev = input_allocate_device();
 	if (!pcspkr_dev)
 		return -ENOMEM;
Index: linux-2.6/include/asm-powerpc/8253pit.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/8253pit.h	2005-10-31 15:02:18.000000000 +1100
+++ linux-2.6/include/asm-powerpc/8253pit.h	2005-10-31 15:20:30.000000000 +1100
@@ -5,6 +5,19 @@
  * 8253/8254 Programmable Interval Timer
  */
 
+#include <asm/prom.h>
+
 #define PIT_TICK_RATE	1193182UL
 
+#define HAS_PCSPKR_ARCH_INIT
+
+static inline int pcspkr_arch_init(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
+	of_node_put(np);
+	return np ? 0 : -ENODEV;
+}
+
 #endif	/* _ASM_POWERPC_8253PIT_H */

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

* Re: [PATCH] Allow arch to veto PC speaker beeper initialization
  2005-11-15  2:02 [PATCH] Allow arch to veto PC speaker beeper initialization Paul Mackerras
@ 2005-11-15  3:55 ` Andrew Morton
  2005-11-15  4:00   ` Paul Mackerras
  2005-11-15  9:08 ` Christoph Hellwig
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2005-11-15  3:55 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: vojtech, linux-kernel, mikey

Paul Mackerras <paulus@samba.org> wrote:
>
> Index: linux-2.6/drivers/input/misc/pcspkr.c
> ===================================================================
> --- linux-2.6.orig/drivers/input/misc/pcspkr.c	2005-10-31 15:16:39.000000000 +1100
> +++ linux-2.6/drivers/input/misc/pcspkr.c	2005-10-31 15:21:13.000000000 +1100
> @@ -66,6 +66,11 @@
>  
>  static int __init pcspkr_init(void)
>  {
> +#ifdef HAS_PCSPKR_ARCH_INIT
> +	int rc = pcspkr_arch_init();
> +	if (rc)
> +		return rc;
> +#endif
>  	pcspkr_dev = input_allocate_device();
>  	if (!pcspkr_dev)
>  		return -ENOMEM;
> Index: linux-2.6/include/asm-powerpc/8253pit.h
> ===================================================================
> --- linux-2.6.orig/include/asm-powerpc/8253pit.h	2005-10-31 15:02:18.000000000 +1100
> +++ linux-2.6/include/asm-powerpc/8253pit.h	2005-10-31 15:20:30.000000000 +1100
> @@ -5,6 +5,19 @@
>   * 8253/8254 Programmable Interval Timer
>   */
>  
> +#include <asm/prom.h>
> +
>  #define PIT_TICK_RATE	1193182UL
>  
> +#define HAS_PCSPKR_ARCH_INIT
> +
> +static inline int pcspkr_arch_init(void)
> +{
> +	struct device_node *np;
> +
> +	np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
> +	of_node_put(np);
> +	return np ? 0 : -ENODEV;
> +}
> +
>  #endif	/* _ASM_POWERPC_8253PIT_H */

We can avoid all the ifdef nasties by adding

static int pcspkr_arch_init(void) __attribute__((weak))
{
	return 0;
}

in pcspkr.c.

It'll bloat the kernel by a few bytes.

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

* Re: [PATCH] Allow arch to veto PC speaker beeper initialization
  2005-11-15  3:55 ` Andrew Morton
@ 2005-11-15  4:00   ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2005-11-15  4:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: vojtech, linux-kernel, mikey

Andrew Morton writes:

> We can avoid all the ifdef nasties by adding
> 
> static int pcspkr_arch_init(void) __attribute__((weak))
> {
> 	return 0;
> }
> 
> in pcspkr.c.
> 
> It'll bloat the kernel by a few bytes.

I like it.  We'll do a new patch, if you haven't made the change
already yourself.

Paul.

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

* Re: [PATCH] Allow arch to veto PC speaker beeper initialization
  2005-11-15  2:02 [PATCH] Allow arch to veto PC speaker beeper initialization Paul Mackerras
  2005-11-15  3:55 ` Andrew Morton
@ 2005-11-15  9:08 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2005-11-15  9:08 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: vojtech, linux-kernel, Michael Neuling

On Tue, Nov 15, 2005 at 01:02:00PM +1100, Paul Mackerras wrote:
> From: Michael Neuling <mikey@neuling.org>
> 
> This patch provides an arch hook in the PC speaker beeper driver which
> gives the arch code an opportunity to determine whether the machine
> has an i8253 timer or not.  If it doesn't we don't want the driver to
> go poking at the i8253's ports; there might be nothing there or there
> might be something else there which would be upset by being poked at.
> 
> We want to be able to build ppc64 kernels which work both on machines
> that have an i8253 equivalent (e.g. some pSeries) and on machines that
> don't (e.g. G5 powermacs), which is why we don't just remove it from
> the config.

Wrong way around.  The architecture should provide a way to find it, not
to veto it.  It should probably use the plattform_device infrastructure.


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

end of thread, other threads:[~2005-11-15  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-15  2:02 [PATCH] Allow arch to veto PC speaker beeper initialization Paul Mackerras
2005-11-15  3:55 ` Andrew Morton
2005-11-15  4:00   ` Paul Mackerras
2005-11-15  9:08 ` Christoph Hellwig

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®