NetBSD Problem Report #50672

From www@NetBSD.org  Sun Jan 17 21:34:32 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E7D2D7A219
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 17 Jan 2016 21:34:31 +0000 (UTC)
Message-Id: <20160117213430.A61A97ACC6@mollari.NetBSD.org>
Date: Sun, 17 Jan 2016 21:34:30 +0000 (UTC)
From: avos@FreeBSD.org
Reply-To: avos@FreeBSD.org
To: gnats-bugs@NetBSD.org
Subject: urtwn: fix a typo in urtwn_chip_stop()
X-Send-Pr-Version: www-1.0

>Number:         50672
>Category:       kern
>Synopsis:       urtwn: fix a typo in urtwn_chip_stop()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 17 21:35:00 +0000 2016
>Closed-Date:    Sun Jan 17 22:44:20 +0000 2016
>Last-Modified:  Sun Jan 17 22:44:20 +0000 2016
>Originator:     Andriy Voskoboinyk
>Release:        
>Organization:
>Environment:
>Description:
There is a (probably, copy-paste) typo:

static void
urtwn_chip_stop(struct urtwn_softc *sc)
{
...
	urtwn_write_4(sc, R92C_GPIO_PIN_CTRL, reg);

	/* Disable GPIO[10:8] */
	urtwn_write_1(sc, R92C_GPIO_MUXCFG + 3, 0x00);

	reg = urtwn_read_2(sc, R92C_GPIO_MUXCFG + 2) & ~0x00f0;
	reg |= (((reg & 0x000f) << 4) | 0x0780);
	urtwn_write_2(sc, R92C_GPIO_PIN_CTRL+2, reg);  << wrong register is used here (0x044+2 instead of 0x040+2)
...
}

Vendor's driver implementation:

static VOID
_DisableGPIO(
...
        //2. Disable GPIO[10:8]
        rtw_write8(Adapter, REG_GPIO_MUXCFG+3, 0x00);
            value16 = rtw_read16(Adapter, REG_GPIO_MUXCFG+2) & 0xFF0F;
        value8 = (u8) (value16&0x000F);
        value16 |= ((value8<<4) | 0x0780);
        rtw_write16(Adapter, REG_GPIO_MUXCFG+2, value16);
...
}
>How-To-Repeat:

>Fix:
Replace R92C_GPIO_PIN_CTRL+2 in the last copied line with R92C_GPIO_MUXCFG + 2 (or with R92C_GPIO_IO_SEL)

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50672 CVS commit: src/sys/dev/usb
Date: Sun, 17 Jan 2016 17:32:09 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sun Jan 17 22:32:09 UTC 2016

 Modified Files:
 	src/sys/dev/usb: if_urtwn.c

 Log Message:
 PR/50672: Andriy Voskoboinyk: fix write to the wrong register.


 To generate a diff of this commit:
 cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/if_urtwn.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sun, 17 Jan 2016 22:44:20 +0000
State-Changed-Why:
Christos fixed it. Thanks for the bug report!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.