From rea-fbsd@codelabs.ru  Tue Dec 12 14:53:50 2006
Return-Path: <rea-fbsd@codelabs.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 8CB8C16A4AB
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Dec 2006 14:53:50 +0000 (UTC)
	(envelope-from rea-fbsd@codelabs.ru)
Received: from pobox.codelabs.ru (pobox.codelabs.ru [144.206.177.45])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 89DBE43CDA
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Dec 2006 14:49:03 +0000 (GMT)
	(envelope-from rea-fbsd@codelabs.ru)
Received: from localdomain
	by pobox.codelabs.ru with local
	id 1Gu8xJ-000IgB-58 for FreeBSD-gnats-submit@freebsd.org; Tue, 12 Dec 2006 17:50:05 +0300
Message-Id: <E1Gu8xJ-000IgB-58@pobox.codelabs.ru>
Date: Tue, 12 Dec 2006 17:50:05 +0300
From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Sender: rea-fbsd@codelabs.ru
Reply-To: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: uart device description in 7-CURRENT is sometimes overwritten
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         106645
>Category:       kern
>Synopsis:       [uart] [patch] uart device description in 7-CURRENT is sometimes overwritten
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 12 15:00:17 GMT 2006
>Closed-Date:    
>Last-Modified:  Tue Dec 12 15:21:06 GMT 2006
>Originator:     Eygene Ryabinkin
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
Code Labs
>Environment:
System: FreeBSD XXX 7.0-CURRENT FreeBSD 7.0-CURRENT #2: Sun Dec 10 21:49:11 MSK 2006 root@XXX:/usr/src/sys/i386/compile/XXX-7 i386
>Description:
The uart driver sets PCMCIA card description (for example, in uart_bus_pci.c),
but it is the overwritten by the base ns8250 code in uart_dev_ns8250.c.
>How-To-Repeat:
Take some PCMCIA card that is supported by the uart driver and insert it.
Then watch for the kernel messages.
>Fix:
Simple patch: check if description is already here.

--- uart_dev_ns8250.c.orig	Sun Dec 10 21:47:23 2006
+++ uart_dev_ns8250.c	Sun Dec 10 21:48:47 2006
@@ -634,7 +634,9 @@
 		uart_setreg(bas, REG_MCR, mcr);
 		uart_barrier(bas);
 		sc->sc_rxfifosz = sc->sc_txfifosz = 1;
-		device_set_desc(sc->sc_dev, "8250 or 16450 or compatible");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev,
+			    "8250 or 16450 or compatible");
 		return (0);
 	}
 
@@ -694,20 +696,25 @@
  describe:
 	if (count >= 14 && count <= 16) {
 		sc->sc_rxfifosz = 16;
-		device_set_desc(sc->sc_dev, "16550 or compatible");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev, "16550 or compatible");
 	} else if (count >= 28 && count <= 32) {
 		sc->sc_rxfifosz = 32;
-		device_set_desc(sc->sc_dev, "16650 or compatible");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev, "16650 or compatible");
 	} else if (count >= 56 && count <= 64) {
 		sc->sc_rxfifosz = 64;
-		device_set_desc(sc->sc_dev, "16750 or compatible");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev, "16750 or compatible");
 	} else if (count >= 112 && count <= 128) {
 		sc->sc_rxfifosz = 128;
-		device_set_desc(sc->sc_dev, "16950 or compatible");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev, "16950 or compatible");
 	} else {
 		sc->sc_rxfifosz = 16;
-		device_set_desc(sc->sc_dev,
-		    "Non-standard ns8250 class UART with FIFOs");
+		if (device_get_desc(sc->sc_dev) == NULL)
+			device_set_desc(sc->sc_dev,
+			    "Non-standard ns8250 class UART with FIFOs");
 	}
 
 	/*
>Release-Note:
>Audit-Trail:
>Unformatted:
