From phk@critter.freebsd.dk  Mon Apr 23 11:56:51 2007
Return-Path: <phk@critter.freebsd.dk>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 2303B16A404
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Apr 2007 11:56:51 +0000 (UTC)
	(envelope-from phk@critter.freebsd.dk)
Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222])
	by mx1.freebsd.org (Postfix) with ESMTP id D7EB413C43E
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Apr 2007 11:56:50 +0000 (UTC)
	(envelope-from phk@critter.freebsd.dk)
Received: from critter.freebsd.dk (unknown [192.168.61.3])
	by phk.freebsd.dk (Postfix) with ESMTP id 48956173B5;
	Mon, 23 Apr 2007 11:37:52 +0000 (UTC)
Received: from critter.freebsd.dk (localhost [127.0.0.1])
	by critter.freebsd.dk (8.13.8/8.13.8) with ESMTP id l3N6ZHZZ001020;
	Mon, 23 Apr 2007 06:35:17 GMT
	(envelope-from phk@critter.freebsd.dk)
Message-Id: <1019.1177310117@critter.freebsd.dk>
Date: Mon, 23 Apr 2007 06:35:17 +0000
From: "Poul-Henning Kamp" <phk@phk.freebsd.dk>
Sender: phk@critter.freebsd.dk
To: Henrik Brix Andersen <henrik@brixandersen.dk>
Cc: FreeBSD-gnats-submit@freebsd.org
In-Reply-To: Your message of "Sun, 22 Apr 2007 16:06:14 +0200."
             <20070422140614.496C71141F@lothlorien.brixandersen.dk> 
Subject: Re: [led(4)] [patch] led_create() unconditionally turns off the annunciator 

>Number:         112031
>Category:       kern
>Synopsis:       Re: [led(4)] [patch] led_create() unconditionally turns off the annunciator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 23 12:00:07 GMT 2007
>Closed-Date:    Mon Apr 23 22:59:29 GMT 2007
>Last-Modified:  Mon Apr 23 22:59:29 GMT 2007
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 >>Description:
 >The current implementation of led_create() in led(4) uncondionally
 >turns off the annunciator - there is currently no way for the caller
 >to specify the initial state of the annunciator.
 
 Thanks for the patch, but I'd prefer not to redefine the API more than
 necessary, so would this patch work for you instead ?
 
 
 Index: led.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/led/led.c,v
 retrieving revision 1.16
 diff -u -u -r1.16 led.c
 --- led.c	7 Mar 2005 11:05:46 -0000	1.16
 +++ led.c	23 Apr 2007 06:34:31 -0000
 @@ -242,6 +242,12 @@
  struct cdev *
  led_create(led_t *func, void *priv, char const *name)
  {
 +
 +	return (led_create_state(func, priv, name, 0));
 +}
 +struct cdev *
 +led_create_state(led_t *func, void *priv, char const *name, int state)
 +{
  	struct ledsc	*sc;
  
  	sc = malloc(sizeof *sc, M_LED, M_WAITOK | M_ZERO);
 @@ -259,7 +265,7 @@
  	if (LIST_EMPTY(&led_list))
  		callout_reset(&led_ch, hz / 10, led_timeout, NULL);
  	LIST_INSERT_HEAD(&led_list, sc, list);
 -	sc->func(sc->private, 0);
 +	sc->func(sc->private, state != 0);
  	mtx_unlock(&led_mtx);
  
  	return (sc->dev);
 Index: led.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/led/led.h,v
 retrieving revision 1.5
 diff -u -u -r1.5 led.h
 --- led.h	16 Jun 2004 09:46:49 -0000	1.5
 +++ led.h	23 Apr 2007 06:34:03 -0000
 @@ -14,6 +14,7 @@
  
  typedef	void led_t(void *, int);
  
 +struct cdev *led_create_state(led_t *, void *, char const *, int);
  struct cdev *led_create(led_t *, void *, char const *);
  void	led_destroy(struct cdev *);
  
 
 -- 
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Mon Apr 23 22:58:52 UTC 2007 
State-Changed-Why:  
Misfiled followup to kern/112008, already committed. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Apr 23 22:58:52 UTC 2007 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=112031 
>Unformatted:
