From owner-svn-src-head@FreeBSD.ORG Mon Mar 9 20:48:57 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CFEA1065900; Mon, 9 Mar 2009 20:48:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89ADD8FC22; Mon, 9 Mar 2009 20:48:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n29Kmvom037051; Mon, 9 Mar 2009 20:48:57 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n29KmvWf037048; Mon, 9 Mar 2009 20:48:57 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200903092048.n29KmvWf037048@svn.freebsd.org> From: Alexander Motin Date: Mon, 9 Mar 2009 20:48:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189600 - head/sys/dev/ata X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 20:49:01 -0000 Author: mav Date: Mon Mar 9 20:48:57 2009 New Revision: 189600 URL: http://svn.freebsd.org/changeset/base/189600 Log: Add type specific suspend/resume ata channel functions. Add checks to avoid crash on detached channel resume. Add placeholder for possible type-specific suspend/resume routines. Modified: head/sys/dev/ata/ata-cbus.c head/sys/dev/ata/ata-isa.c head/sys/dev/ata/ata-pci.c Modified: head/sys/dev/ata/ata-cbus.c ============================================================================== --- head/sys/dev/ata/ata-cbus.c Mon Mar 9 20:08:08 2009 (r189599) +++ head/sys/dev/ata/ata-cbus.c Mon Mar 9 20:48:57 2009 (r189600) @@ -314,6 +314,28 @@ ata_cbuschannel_detach(device_t dev) } static int +ata_cbuschannel_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_cbuschannel_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + +static int ata_cbuschannel_banking(device_t dev, int flags) { struct ata_cbus_controller *ctlr = device_get_softc(device_get_parent(dev)); @@ -360,8 +382,8 @@ static device_method_t ata_cbuschannel_m DEVMETHOD(device_probe, ata_cbuschannel_probe), DEVMETHOD(device_attach, ata_cbuschannel_attach), DEVMETHOD(device_detach, ata_cbuschannel_detach), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_cbuschannel_suspend), + DEVMETHOD(device_resume, ata_cbuschannel_resume), /* ATA methods */ DEVMETHOD(ata_locking, ata_cbuschannel_banking), Modified: head/sys/dev/ata/ata-isa.c ============================================================================== --- head/sys/dev/ata/ata-isa.c Mon Mar 9 20:08:08 2009 (r189599) +++ head/sys/dev/ata/ata-isa.c Mon Mar 9 20:48:57 2009 (r189600) @@ -163,13 +163,36 @@ ata_isa_detach(device_t dev) return (error); } +static int +ata_isa_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_isa_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + + static device_method_t ata_isa_methods[] = { /* device interface */ DEVMETHOD(device_probe, ata_isa_probe), DEVMETHOD(device_attach, ata_isa_attach), DEVMETHOD(device_detach, ata_isa_detach), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_isa_suspend), + DEVMETHOD(device_resume, ata_isa_resume), { 0, 0 } }; Modified: head/sys/dev/ata/ata-pci.c ============================================================================== --- head/sys/dev/ata/ata-pci.c Mon Mar 9 20:08:08 2009 (r189599) +++ head/sys/dev/ata/ata-pci.c Mon Mar 9 20:48:57 2009 (r189600) @@ -581,6 +581,28 @@ ata_pcichannel_detach(device_t dev) return (0); } +static int +ata_pcichannel_suspend(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_suspend(dev); +} + +static int +ata_pcichannel_resume(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + + if (!ch->attached) + return (0); + + return ata_resume(dev); +} + static int ata_pcichannel_locking(device_t dev, int mode) @@ -629,8 +651,8 @@ static device_method_t ata_pcichannel_me DEVMETHOD(device_attach, ata_pcichannel_attach), DEVMETHOD(device_detach, ata_pcichannel_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, ata_suspend), - DEVMETHOD(device_resume, ata_resume), + DEVMETHOD(device_suspend, ata_pcichannel_suspend), + DEVMETHOD(device_resume, ata_pcichannel_resume), /* ATA methods */ DEVMETHOD(ata_setmode, ata_pcichannel_setmode),